Skip to content

Commit d907979

Browse files
committed
Improved wording.
1 parent 7ed88f2 commit d907979

File tree

1 file changed

+39
-43
lines changed

1 file changed

+39
-43
lines changed

proc.tex

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,51 +21,50 @@
2121
\end{slide}
2222

2323
\begin{itemize}
24-
\item each process has 3 basic segments (memory segments, not
24+
\item Each process has 3 basic segments (memory segments, not
2525
hardware segments):
2626
\begin{itemize}
2727
\item text \dots{} program code
2828
\item data \dots{} initialized variables
2929
\item stack
3030
\end{itemize}
3131
\item \texttt{text} and \texttt{data} sections are saved in executable file
32-
\item the sections for inicialized and non-initialized variables and heap are
32+
\item The sections for inicialized and non-initialized variables and heap are
3333
considered as data
34-
\item it is also possible to connect segments of shared memory
34+
\item It is also possible to connect segments of shared memory
3535
(\texttt{shmat}) or files (\texttt{mmap}) into the address space.
36-
\item the text is shared between all processes which execute the same code.
36+
\item The text is shared between all processes which execute the same code.
3737
The data segment and stack are private for each process.
38-
\item each system can use different layout of process address space
39-
(and typically it is indeed so). See next slide which also shows
38+
\item Each system can use a different layout of a process address space
39+
(and typically it is indeed so). See the next slide which also shows
4040
sections for \texttt{mmap} and \emph{heap}.
4141
\item \emph{bss} \dots{} non-initialized variables (\texttt{bss}
4242
comes from the IBM 7090 assembler and stands for \uv{block started by
4343
symbol}). While the program is running, the \texttt{data}, \texttt{bss} and heap
4444
sections (not shown in the picture) make up data segments of the process.
4545
Heap size can be changed using the \texttt{brk} and \texttt{sbrk} system calls.
46-
\item note -- non-initialized variables like static variables --
46+
\item Note -- by non-initialized variables are meant static variables --
4747
i.e. global variables or variables declared as \texttt{static} both in the
48-
functions and outside. All these variables are automatically initialized
49-
with zeroes before the program is started. Therefore it is not necessary
50-
to store their value in the binary. Once one of these variables is initialized,
51-
it will become part of the data segment on disk.
52-
\item \emph{(user) stack} \dots{} local non-static variables,
53-
function parameters (on certain architectures in certain modes - e.g. 32-bit x86),
54-
return addresses. Each process has 2 stacks -- one for user mode and another
55-
for kernel mode. User stack automatically grows according to its use
56-
(except for threads where each thread has its own limited stack).
57-
\item \emph{user area (u-area)} \dots{} contains process information used by
48+
functions and outside that are not set to a value. All these variables are
49+
automatically initialized with zeroes before the program is started. Therefore
50+
it is not necessary to store their value in the binary. Once one of these
51+
variables is initialized, it will become part of the data segment on disk.
52+
\item \emph{(User) stack} \dots{} local non-static variables, function
53+
parameters (on certain architectures in certain modes - e.g. 32-bit x86), return
54+
addresses. Each process has 2 stacks -- one for a user mode and another for
55+
kernel mode. The user stack automatically grows according to its use (except
56+
for threads where each thread has its own limited stack).
57+
\item \emph{User area (u-area)} \dots{} contains process information used by
5858
the kernel which are not needed when the process is swapped out to disk
5959
(number of open files, signal handling settings, number of shared memory segments,
6060
program arguments, environment variables, current working directory, etc.).
6161
This area is accessible only to the kernel which will see just the area
62-
of currently running process. The rest of data which is needed even if the
63-
process is not currently running or is swapped out to disk, is stored in
64-
\texttt{proc} structure. The \texttt{proc} structures for all processes
65-
are always resident in mempory and accessible in kernel modes.
62+
of a currently running process. The rest of the data needed even if the process
63+
is not currently running or while swapped out to disk is stored in the
64+
\texttt{proc} structure. \texttt{proc} structures for all processes are always
65+
resident in memory and accessible in a kernel mode.
6666
\end{itemize}
6767

68-
6968
\begin{slide}
7069
\sltitle{Example: Solaris 11 x86 32-bit}
7170
\begin{center}
@@ -76,43 +75,40 @@
7675
\label{SOLARIS_PROC_ADDR_SPACE}
7776

7877
\begin{itemize}
79-
\item the following is deductible from the image:
78+
\item The following is deductible from the image:
8079

8180
\begin{itemize}
8281
\item maximum size of kernel for Solaris 11 x86 32-bit is 256 megabytes
8382
\item there is free space between kernel and memory reserved for \texttt{mmap}
8483
\item stack grows towards lower addresses and its size is limited to 128 megabytes
8584
\end{itemize}
8685

87-
\item \emph{heap} is part of the memory that can be extended by the processes
88-
using the \texttt{brk} and \texttt{sbrk} syscalls and is used by
89-
the \texttt{malloc} function.
90-
The \texttt{malloc} allocator gradually extends the heap based on demand,
91-
and manages acquired memory and distributes to the process in chunks.
92-
When \texttt{free} is called, it does not mean that the memory is returned
93-
to the kernel; it is only returned to the allocator.
86+
\item A \emph{heap} is a part of the memory that can be extended by processes
87+
using the \texttt{brk} and \texttt{sbrk} syscalls and is used by the
88+
\texttt{malloc} function. The \texttt{malloc} allocator gradually extends the
89+
heap on demand, and manages acquired memory and distributes it to the process in
90+
chunks. When \texttt{free} is called, it does not mean that the memory is
91+
returned to the kernel; it is only returned to the allocator.
9492
\item The \texttt{mmap} area is used for mapping files into memory, i.e. also
9593
for shared libraries. Some allocators use also this memory internally,
96-
e.g. in case process requests larger chunks of memory at once.
97-
It is possible to exclusively use just \texttt{mmap}, it is transparent
98-
to the application. When using \texttt{mmap} it is possible to return the
99-
memory to the kernel (using \texttt{munmap}), compared to the
100-
\texttt{brk}/\texttt{sbrk} based implementation.
101-
\item The picture was taken from [McDougall-Mauro], and does not contain space
102-
for non-initialized variables. If you try to print the address of such variable
103-
on this system, you will find out that both initialized and non-initialized
104-
variables share common data segment, on the image visible as
105-
,,executable -- DATA''.
106-
Example: \example{pmap/proc-addr-space.c}
94+
e.g. in case a process requests larger chunks of memory at once. It is possible
95+
to exclusively use just \texttt{mmap}, and that is transparent to the
96+
application. When using \texttt{mmap} it is possible to return the memory to the
97+
kernel (using \texttt{munmap}), in contrast to the \texttt{brk}/\texttt{sbrk}
98+
based implementation.
99+
\item The picture was taken from [McDougall-Mauro] and does not contain space
100+
for non-initialized variables. If you try to print the address of such a
101+
variable on this system, you will find out that both initialized and
102+
non-initialized variables share a common data segment, labeled in the image as
103+
,,executable -- DATA''. Example: \example{pmap/proc-addr-space.c}.
107104
\item The kernel mapping is not necessary, for example on Solaris running on
108105
\emph{amd64} architecture (i.e. 64-bit) the kernel is no longer mapped into
109106
user space.
110107
\item \texttt{brk} nor \texttt{sbrk} are part of the standard, hence portable
111-
applications should not use them; if similar functionality is needed, they
108+
applications should not use them; if a similar functionality is needed, they
112109
should use \texttt{mmap}, see page \pageref{MMAP}.
113110
\end{itemize}
114111

115-
116112
%%%%%
117113

118114
\begin{slide}

0 commit comments

Comments
 (0)