Skip to content

Commit bccc751

Browse files
committed
Improved wording.
1 parent d907979 commit bccc751

File tree

1 file changed

+106
-108
lines changed

1 file changed

+106
-108
lines changed

proc.tex

Lines changed: 106 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,24 @@
119119
\end{slide}
120120

121121
\begin{itemize}
122-
\item A process will enter kernel model either by a
122+
\item A process will enter a kernel model either by a
123123
\emph{trap induced by the CPU} (page fault, unknown instruction, etc.)
124-
\emph{timer} (to invoke scheduler), \emph{interrupt} from peripheal device,
125-
or synchronous trap (standard library uses it to hand over the control
126-
to kernel to service \emph{system call}).
124+
\emph{timer} (to invoke scheduler), \emph{interrupt} from a peripheal device,
125+
or synchronous trap (a standard library uses it to hand over the control to
126+
the kernel to service a \emph{system call}).
127127
\item There is only one copy of the kernel text and data in the memory,
128-
shared by all processes. Kernel text as a whole is resident in memory,
129-
it is not swapped out to disk.
130-
\item \emph{kernel text} \dots{} code of operating system kernel,
131-
loaded when the system is booting and is always resident in memory.
132-
Some implementations allow to add modules to the kernel during runtime.
128+
shared by all processes. The kernel text as a whole is resident in memory and
129+
not swapped out to disk.
130+
\item \emph{kernel text} \dots{} code of the operating system kernel,
131+
loaded when the system is booting up and is always resident in memory.
132+
Some implementations allow to add modules to the kernel during runtime
133133
(e.g. when a device is connected, matching device driver module is
134134
automatically loaded), it is therefore not necessary to regenerate
135135
the kernel and reboot the system whenever a change is needed.
136136
\item \emph{data and kernel bss} \dots{} contain data structures used
137-
by kernel, contains the u-area of currently running process.
137+
by the kernel, contains the u-area of a currently running process.
138138
\item \emph{kernel stack} \dots{} independent for each process, is empty
139-
when the process is in user mode (and therefore uses user stack).
139+
when the process is in the user mode (and therefore uses the user stack).
140140
\end{itemize}
141141

142142
%%%%%
@@ -152,19 +152,19 @@
152152

153153
\begin{itemize}
154154
\item This is how memory segments representation looks like in the kernel.
155-
\item The core feature of this architecture is \emph{memory object}, which is
156-
mapping abstractions between part of memory and place where data is normally
155+
\item The core feature of this architecture is a \emph{memory object}, a
156+
mapping abstraction between a part of memory and a place where data is normally
157157
stored (so called \emph{backing store} or \emph{data object}). This place can
158-
be e.g. swap or a file. Address space of a process is set of mapping to different
159-
data objects. There exists also \emph{anonymous object}, which does not have
160-
persistent backing store (it is used e.g. for stack). Physical memory then
161-
serves as cache for data of these mapped objects.
158+
be e.g. swap space or a file. Address space of a process is a set of mappings to
159+
different data objects. There exists also an \emph{anonymous object} that does
160+
not have persistent backing store (it is used e.g. for a stack). Physical memory
161+
then serves as a cache for data of these mapped objects.
162162
\item This coarsely described architecture is called VM (\emph{Virtual
163163
Memory}), and was introduced in SunOS 4.0. The virtual memory architecture
164-
of SVR4 is based on this architecture.
165-
More information can be found in [Vahalia], the original whitepaper from
166-
1987 that introduced this architecture: Gingell, R. A., Moran J.
167-
P., Shannon, W. A. -- \emph{Virtual Memory Architecture in SunOS}.
164+
of SVR4 is based on this architecture. More information can be found in
165+
[Vahalia], the original whitepaper from 1987 that introduced this architecture:
166+
Gingell, R. A., Moran J. P., Shannon, W. A. -- \emph{Virtual Memory
167+
Architecture in SunOS}.
168168
\item To determine what memory segments a memory space of a process consists of,
169169
various tools can be used: \texttt{pmap(1)} on Solaris, NetBSD and in some Linux
170170
distributions, \texttt{procmap(1)} on OpenBSD, or \texttt{vmmap(1)} on macOS.
@@ -182,17 +182,18 @@
182182
\end{slide}
183183

184184
\begin{itemize}
185-
\item Each process sees its own address space as contiguous interval of
186-
(virtual) addresses from zero to some maximal value. The accessible addresses
185+
\item Each process sees its own address space as a contiguous interval of
186+
(virtual) addresses from zero to some maximal value. Accessible addresses
187187
are those for which there is a mapping, i.e. there is a memory
188-
segment (see previous slide).
189-
\item Kernel divides the memory to pages. Each page has its own location in
188+
segment (see the previous slide).
189+
\item The kernel divides the memory to pages. Each page has its own location in
190190
physical memory. This location is determined by kernel page tables and the
191-
pages can be arbitrarily mixed w.r.t. their placement in virtual address space.
192-
\item If a page is not used, it can be swapped out to disk.
193-
\item The kernel memory management ensures mapping between virtual addresses
194-
used by user processes and kernel to physical addresses and reading in pages
195-
from disk upon page fault.
191+
memory pages can be arbitrarily mixed w.r.t. their placement in the virtual
192+
address space of a process.
193+
\item If a page is not used it can be swapped out to disk.
194+
\item The kernel memory management ensures a mapping between virtual addresses
195+
used by processes and the kernel to physical addresses. It also reads in pages
196+
from a disk upon a page fault.
196197
\end{itemize}
197198

198199
%%%%%
@@ -207,19 +208,18 @@
207208
\end{slide}
208209

209210
\begin{itemize}
210-
\item After the process is terminated either using \texttt{exit} call or
211-
as a consequence of a signal, it will transition to zombie state because
212-
the kernel needs to store return value for the process. The whole memory
213-
of the process is freed, the only remaining piece is the \texttt{proc}
214-
structure. The process can go away for good only after its parent will
215-
retrieve its return value using the \texttt{wait} call. If the original
216-
parent is no longer available, the \texttt{init} process which became the
217-
new parent will call \texttt{wait}.
218-
\item In today's UNIX systems the processes are not swapped out as whole,
219-
only individual pages.
220-
\item The process is put to sleep if it requests it, e.g. when it is waiting
221-
on an operation with peripheal device to complete. The \emph{preemption} is
222-
on the other hand involuntary removal of CPU by the scheduler.
211+
\item After the process is terminated either using an \texttt{exit} call or as a
212+
consequence of a signal, it will transition to a zombie state as the kernel
213+
needs to store a return value for the process. The whole memory of the process is
214+
freed, the only remaining piece is the \texttt{proc} structure. The process can
215+
go away for good only after its parent will retrieve its return value using the
216+
\texttt{wait} call. If the original parent is no longer available, the
217+
\texttt{init} process which became the new parent will call \texttt{wait}.
218+
\item In today's Unix systems processes are usually not swapped out as whole,
219+
only individual pages are.
220+
\item A process is put to sleep if it requests it, e.g. when it is waiting on a
221+
completion of an operation with a peripheal device. The \emph{preemption} is on
222+
the other hand an involuntary removal of a CPU by the scheduler.
223223
\end{itemize}
224224

225225
%%%%%
@@ -229,13 +229,14 @@
229229
\begin{itemize}
230230
\item \emph{preemptive} -- if a process does not give up CPU
231231
(e.g. by entering a sleep to wait on some event), the CPU is taken away
232-
after time quantum expiration.
233-
\item processes are classified into queues according to priority,
234-
CPU is assigned to the first ready process from queue with biggest priority.
232+
after a time quantum expiration.
233+
\item processes are classified into queues according to a priority,
234+
a CPU is assigned to the first ready process from the queue with the biggest
235+
priority.
235236
\item SVR4 introduced priority queues and real-time support with guaranteed
236-
maximal response time.
237-
\item contrary to the previous versions, in SVR4 bigger number means
238-
bigger priority.
237+
maximal response time
238+
\item contrary to the previous versions, in SVR4 a bigger number means a bigger
239+
priority
239240
\end{itemize}
240241
\end{slide}
241242

@@ -247,26 +248,25 @@
247248
keeps running, until it gives up the CPU, i.e. until it calls such system call,
248249
that switches the context to different process. The downside of cooperative
249250
planning is that one process can block the CPU and other processes forever.
250-
\item UNIX uses only preemptive planning for user processes.
251+
\item Unix uses only preemptive planning for user processes.
251252
\item Traditional (historical) UNIX \emsl{kernel} uses cooperative planning,
252253
i.e. process running in kernel mode is not switched until it gives up the CPU
253254
by itself.
254-
\emsl{Modern UNIX kernels are preemtive} -- mainly because of real-time
255-
systems; there it is necessary to have the possibility to remove CPU from
256-
running process immediately, not waiting until it returns from kernel mode
257-
or enters sleep by itself. Note that UNIX was preemtive from its very beginning,
258-
just the kernel was non-preemptive.
259-
\item With preemptive planning processes can be interrupted at any time and
260-
the CPU given to another process. Therefore the process can never be sure
261-
that given operation (spanning more than one instruction, besides system calls
255+
\emsl{Modern Unix kernels are preemtive} -- mainly because of real-time
256+
systems; where it is necessary to have the possibility to remove a CPU from
257+
a running process immediately, and not waiting until it returns from a kernel
258+
mode or enters sleep by itself. Note that UNIX was preemtive from its very
259+
beginning but its kernel was non-preemptive in the beginning.
260+
\item With a preemptive planning processes can be interrupted at any time and
261+
the CPU given to another process. Therefore a process can never be sure
262+
that a given operation (spanning more than one instruction, besides system calls
262263
with guaranteed atomicity) will be executed atomically, without being
263-
influenced by other processes. If it is necessary to ensure atomicity of
264-
an operation, the processes must synchronize. This problem is avoided in
265-
cooperative planning -- the atomicity of given operation is simply ensured
266-
by not giving up the CPU while it is still in progress.
264+
influenced by other processes. If it is necessary to ensure atomicity of an
265+
operation, processes must synchronize. This problem is avoided in a cooperative
266+
planning -- the atomicity of a given operation is simply ensured by not giving
267+
up the CPU while the operation is still in progress.
267268
\end{itemize}
268269

269-
270270
%%%%%
271271

272272
\pdfbookmark[1]{Priority classes for process scheduling}{prioclasses}
@@ -299,29 +299,30 @@
299299
\end{slide}
300300

301301
\begin{itemize}
302-
\item The system class is used only by the kernel, user process running
303-
in kernel mode retains its own planning characteristics.
304-
\item Processes in the real time classs have the biggest priority,
305-
therefore most be configured correctly, otherwise they would block
306-
the rest of the system.
307-
\item If a process in time-shared class is put to sleep and is waiting
308-
on some event, the system priority is temporarily assigned to it.
309-
After wake up, such process will be assigned a CPU earlier than other
310-
non-sleeping processes.
302+
\item The system class is used only by the kernel, a user process running
303+
in a kernel mode retains its own planning characteristics.
304+
\item Processes in the real time class have the biggest priority,
305+
therefore most be configured correctly, otherwise they could block
306+
the rest of the system from getting any CPU time.
307+
\item If a process in a time-shared class is put to sleep and is waiting on an
308+
event, the system priority is temporarily assigned to it. After a wake-up, such
309+
a process will be assigned a CPU earlier than other non-sleeping processes to
310+
finish the operation as soon as possible as it could hold some locks later
311+
needed by other processes.
311312
\item Fixed part of the priority in the time-shared class can be set
312313
using\\
313314
\texttt{int \funnm{setpriority}(int \emph{which}, id\_t \emph{who},
314315
int \emph{prio});}\\ or \\ \texttt{int \funnm{nice}(int \emph{in{}cr});} \\
315316
The \emph{which} value determines what will be in the \emph{who} argument.
316317
If \emph{which} is e.g. \emph{PRIO\_PGRP}, the \emph{who} will store process
317-
group number.
318-
Note that \funnm{nice} call will return new nice value. Because -1 is valid
319-
variable, it is necessary to clear \texttt{errno} value and check it
320-
if the function returns -1.
321-
\item The prority class and nice value of given process can be displayed with
322-
the -l option of ps(1) or by specifying the values than should be written out.
323-
\item Example: the priority values have different scales on different systems.
324-
E.g. macOS~10.9 a process that had the priority value 30 will have the value
318+
group number. Note that \funnm{nice} call will return a new nice value. As
319+
-1 is a valid value, it is necessary to clear \texttt{errno} and then check if
320+
the function returns -1.
321+
\item The prority class and nice value of a given process can be displayed with
322+
the \texttt{-l} option of the \texttt{ps} command or by explicitly specifying
323+
the fields to be printed out (see the \texttt{-o} option).
324+
\item Example: priority values have different scales on different systems. E.g.
325+
on macOS~10.9 a process that had the priority value 30 will have the value
325326
decremented to 21 after increasing the nice value:
326327
\begin{verbatim}
327328
$ sleep 200 &
@@ -334,11 +335,11 @@
334335
PID PRI NI TT STAT TIME COMMAND
335336
36877 21 10 s003 SN 0:00.00 sleep 200
336337
\end{verbatim}
337-
On Linuxu 3.10 it will look differently -- the priority value will be increased
338-
after nice value increase. However this means that the process will be running
339-
with smaller priority.
340-
\end{itemize}
341338

339+
With Linux kernel 3.10 it will look differently -- the priority value will be
340+
increased after a nice value increases. However, that means the process will be
341+
running with a smaller priority.
342+
\end{itemize}
342343

343344
%%%%%
344345

@@ -363,29 +364,27 @@
363364
\end{slide}
364365

365366
\begin{itemize}
366-
\item When a user logs into system, new session is created. The session
367-
contains one process group that only has single process -- one with the
368-
user's shell. This process is also the leader of this single process group
369-
and session leader. In case job control is on, each command or
370-
colon of commands will create new process group, one process from each group
371-
will always become process group leader. One of the groups can be running
372-
in foreground, the rest will be running in the background.
373-
Signals which are generated from the keyboard (i.e. those triggered by
374-
combination of keys, not by executing the \texttt{kill} command),
375-
are sent only to the group running in the foreground.
376-
\item If job control is off, command execution in the foreground means
377-
that the shell will not be waiting for its completion. There exists only
378-
one group of processes, keyboard generated signals are sent to all processes
379-
running in the foreground and background. Processes cannot be moved to
380-
background from foreground or back and forth.
381-
\item When a process that has controlling terminal opens the \texttt{/dev/tty}
382-
file, it is associated with its controlling terminal, i.e. if 2 different
383-
processes open this file, they will be accessing 2 different terminals.
384-
\item In bash process group (job) can be stopped temporarily using
385-
\texttt{Ctrl-Z}, and be continued again using ,,\texttt{fg \%N}'' where
386-
\texttt{N} is the number from the \texttt{jobs} command listing.
387-
More information can be found in the ,,JOB CONTROL'' section in the bash
388-
man page.
367+
\item When a user logs into a system, a new session is created. The session
368+
contains one process group that only has a single process -- one with the user's
369+
shell. That process is also the leader of that single process group and also a
370+
session leader. In case a job control is on, each command or a pipeline will
371+
create a new process group, and one process from each group will always become a
372+
process group leader. One of the groups can be running in the foreground, the
373+
rest will be running in the background. Signals which are generated from the
374+
keyboard (i.e. those triggered by combination of keys, not by executing the
375+
\texttt{kill} command) are sent only to the group running in the foreground.
376+
\item If the job control is off, command execution in the background means that
377+
the shell will not be waiting for its completion. There exists only one group of
378+
processes, and keyboard generated signals are sent to all processes running in
379+
the foreground and background. Processes cannot be moved to the background from
380+
the foreground and vice versa.
381+
\item When a process that has a controlling terminal opens the \texttt{/dev/tty}
382+
file, it gets associated with its controlling terminal, i.e. if two different
383+
processes open this file, each will be accessing a different terminal.
384+
\item In bash a process group (job) can be stopped temporarily using
385+
\texttt{Ctrl-Z}, and can be resumed again using ,,\texttt{fg \%N}'' where
386+
\texttt{N} is the number from the \texttt{jobs} command listing. More
387+
information can be found in the ``JOB CONTROL'' section in the bash man page.
389388
\end{itemize}
390389

391390
\pdfbookmark[1]{fork}{fork}
@@ -423,7 +422,6 @@
423422
copy-on-write mechanism. See \example{fork/vfork.c} on how it works.
424423
\end{itemize}
425424

426-
427425
%%%%%
428426

429427
\pdfbookmark[1]{getpid, getpgrp, getppid, getsid}{getp}

0 commit comments

Comments
 (0)