[ Pobierz całość w formacie PDF ]

by a call (2024) on \xswap" (4368).
ing in one of the following situations:
For those archaeologists who like to ponder the
\bones" of earlier versions of operating systems, it
A. (runout) None of the processes which are swap-
seems that originally \ sched" called \ swap" directly
ped out is ready to run, so that there is noth-
to \swap out" processes, rather than via \xswap".
ing to do. The situation may be changed by
The extra procedure (one of several to be found
a call to \ wakeup", or to \ xswap" called by
in the le \text.c") has been necessitated by the
either \newproc" or \ expand".
implementation of the sharable \text segments".
It is instructive to estimate howmuch extra code
B. (runin) There is at least one process swapped
has been necessitated by the text segment feature:
out and ready to run, but it hasn't been out
in \text.c" are four procedures \xswap", \xalloc",
more than 3 seconds and/or none of the pro-
\xfree" and \xccdec", which manipulate an array
cesses presently in main memory is inactive
of structures called \text", which is declared in the
or has been there more than 2 seconds. The
le \text.h". Additional code has also been added
situation may be changed by the e uxion of
to \sysl.c" and \slp.c".
time as measured by \ clock" or by a call to
\sleep".
14.1 Text Segments
When either of these situations terminate:
Text segments are segments which contain only
\pure" code and data i.e. code and data which
1958: With the processor running at priority six,
remain unaltered throughout the program execu-
so that the clock can't interrupt and change
tion, so that they may be shared amongst several
values of \ p time", a search is made for the
processes executing the same program.
process which is ready to run and has been
The resulting economies in space can be quite
swapped out for the longest time
substantial when many users of the system are ex-
ecuting the same program simultaneously e.g. the 1966: If there is no such process then situation A
editor or the \shell". holds
1976: Search for a main memory area of adequate a main memory address (ordinal number
size to hold the data segment. If an associ- of a 32 word block)
ated text segment must be present also but
a size (number of 32 word blocks to be
is not currently in main memory, the area is
transferred)
increased by the size of the text segment
a direction indicator (\B READ==1"
1982: If an area of adequate size is available the denotes \disk to main memory")
program branches to \found2" (2031). (Note
2042: Swap in the data segment and ...
that the program does not handle the case
where there is su cient space for both text
2044: Release the disk swap area to the available
and data segments but in distinct areas of
list, record the main memory address, set
main memory. Would it be worth while to
the \SLOAD" ag and reset the accumulated
extend the code to cover this possibility?)
time indicator.
1990: Search for a process which is in main mem-
ory, but which is not the scheduler or locked
14.3 xswap (4368)
(i.e. already being swapped out), and whose
4373: If \oldsize" data was not supplied, use the
state is \SWAIT" or \SSTOP" (but not
current size of the data segment stored in \ u"
\SSLEEP") (i.e. the process is waiting for an
event of low precedence, or has stopped dur-
4375: Find a space in the disk swap area for the
ing tracing (see Chapter Thirteen)). If such a
process's data segment. (Note that the disk
process is found, go to line 2021, to swap the
swap area is allocated in terms of 512 charac-
image out.
ter blocks)
Note that there seems to be a bias here
against processes whose \proc" entries are 4378: \xccdec" (4490) is called (unconditionally!)
early in the \ proc" array to decrease the count, associated with the text
segment, of the number of \in main memory"
2003: If the image to be swapped in has been out
processes which reference that text segment.
less than 3 seconds, then situation B holds
If the count becomes zero, the main memory
area occupied by the text segment is simply
2005: Search for the process which is loaded, but
returned to the available space. (There is no
is not the scheduler or locked, whose state
need to copy it out, since, as we shall see,
is \SRUN" or \SSLEEP" (i.e. ready to run,
there will be a copy already in the disk swap
or waiting for an event of high precedence)
area)
and which has been in main memory for the
longest time
4379: The \SLOCK" ag is set while the pro-
cess is being swapped out. This is to pre-
2013: If the process image to be swapped out has
vent \sched" from attempting to \ swap out"
been in main memory for less than 2 seconds,
a process which is already in the process of
then situation B holds.
being \swapped out". (This can only hap-
The constant \2" here (also the \3" on line
pen if \ swapping out" was started initially by
2003) is somewhat arbitrary. For some reason
some routine other than \sched" e.g. by \ex-
the programmer has departed from his usual
pand")
practice of naming such constants to empha-
4382: The main memory image is released except
sise their origins
when \xswap" is called by \newproc"
2022: The process image is agged as not loaded
4388: If \runout" is set, \sched" is waiting for
and is swapped out using \xswap" (4368).
something to \ swap in", so wake it up.
Note that the \SSWAP" ag is not set here
because the process swapped out is not the
14.4 xalloc (4433)
current process. (Cf. lines 1907, 2286)
\xalloc" is called by \exec" (3130), when a new
2032: Read the text segment into main memory if
program is being initiated, to handle the allocation
necessary. Note that the arguments for the
of, or linking to, the text segment. The argument,
\swap" procedure are:
\ip", is a pointer to the \mode" of the code le. At
an address within the swap area of the the time of this call, \u.u arg[1]" contains the text
disk segment size in bytes.
4439: If there is no text segment, return immedi- 14.5 xfree (4398)
ately
\xfree" is called by \ exit" (3233) when a process
is being terminated, and by \ exec" (3128), when a
4441: Look through the \text" array for both an
process is being transmogri ed. [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • uchidachi.htw.pl