![]() |
![]() |
Having got the FCFS dispatcher going from last week - a working example is given in the course home directory (use the fcfs.txt file in that directory; e.g. >hostd fcfs.txt). We now need to develop a Round Robin dispatcher. Since the Feedback dispatcher required for the low priority job streams described in Project 2 is essentially multiple Round Robin dispatcher queues, it makes sense to walk before we can run.
To suspend and restart processes as required by the Round Robin dispatcher will require the use of the SIGTSTP and SIGCONT signals as well as SIGINT that we used for the FCFS dispatcher.(see below). To make the Round Robin dispatcher work in the same way as described in Stallings Figure 9.5 (RR q=1) the logic should be:
or something like that! Try this with the following job list with a quantum of 1 sec:
This should produce the sequence shown in Stallings Figure 9.5 (RR q=1):
SignalsSignals provide one way of communicating with and controlling processes. A standard process has 'handlers' to field all the UNIX/POSIX signals. The default action of these handlers is sometimes to do nothing, or, for others to suspend or terminate the process with or without a core dump etc. The program in sigtrap.c in the course home directory is an example of a program that traps some of the major process control signals and reports them on the terminal. This is in fact the process process that is to be executed by your dispatcher for project 2. sigtrap (& process) is similar to sleepy in that it takes a command line argument to signify how many ticks it should tock. However, when exec'ed with no arguments (as for the project) it will 'tick' for a maximum of 20 seconds. If you execute it as sigtrap 1000, and then apply the standard tcsh job control commands of ^Z, fg, ^Z, kill %1, etc you will get some idea of the signals that the shell is passing to it's execed children. If you start up another terminal, you can pass your own signals to the sigtrap process by using the system utility kill. Again if you start up sigtrap 1000 and it reports a process ID of nnnnn, then try the command lines:
while observing the terminal window running the sigtrap process. You can achieve the same effect inside a process that has forked sigtrap as a child:
It is these last three signals we should be using for process control in the HOST dispatcher. Code should be in 'straight' C using the compiler of your choice (cc or gcc). Always use nice to
execute your test programs at lower priority to ensure they do not inconvenience
other users if they go 'haywire'. e.g.: The descriptions of the system functions above are drawn from
sources that include |
![]() | ![]() | ![]() |
For use only by students and instructors using the supplementary material available with the text book: "Operating Systems - Internals and Design Principles", William Stallings, Prentice Hall, 5th Edition, 2004. Not to be printed out or copied by any other persons or used for any other purpose without written permission of the author(s).
©