This assignment relies on the first three assignments.
Modify the runsim
from assignment 3 as follows:
runsim
in a linked list.
For each process you should include:
runsim
detects the stop).
proc
file system).
output_list
which has
prototype:
void output_list(FILE *fp, list_t *p);The
output_list
function outputs the contents of the
linked list of processes to the file fp
. Use this
function to test that your linked list is working.
update_total_time
which
has prototype:
void update_total_time(list_t *p, timespec_t t, pid_t pid);The
update_total_time
function updates the time used
by process pid
update_stopped_time
which
has prototype:
void update_stopped_time(list_t *p, timespec_t t, pid_t pid);The
update_stopped_time
function updates the time that
the process pid
was last stopped.
Program Development and Testing Speciification
Insert the code for adding a process to the list when it is forked and deleting it from the list when the process terminates. Do not update any times in this step. Output the list after each insertion and deletion.
waitpid
detects that the process has stopped. For testing, output the entire
list each time you update.
SIGUSR1
to runsim
.
The signal handler will print the status information contained in the
linked list by calling output_list
. At this point
you will have to also insert code to block signals to protect critical
sections as discussed in class.
runsim
that gives the number of seconds between updates of the CPU time.
alarm
system call generates a SIGALARM
signal. Write a signal handler that will update the amount of CPU
time for each process that is managed by runsim
Read the status in proc
as in assignment 2.
SIGCONT
to them after outputting their status information and updating the
list.