Week 8 Tutorial Notes This weeks tutorial will mainly be a question and answer period for assignment 2. Some common questions about the assignment: Q) If the processes from the foreground queue are always scheduled before the processes from the background queue, how do any processes from the background queue ever get scheduled? A) The scheduler first attempts to schedule a process from the foreground queue. If the foreground queue is empty, then a process from the background queue is scheduled. NOTE: The foreground queue will tend to be empty since it mostly contains kernel processes and processes that have a low CPU time average. Kernel processes (daemons) spend most of their time sleeping (or waiting for something) and will not usually be in the ready queue. Now, consider processes with a low CPU time average. To get such a low average these processes are not running to the end of their quantum each time they are scheduled. This will usually mean that they regularly block on events. So these processes will also not be spending a lot of time in the ready queue. Thus the foreground queue will tend to be empty, so processes in the background queue can get scheduled. Q) Is yield some sort of procedure that we need to write? A) Yield is a SYSTEM CALL that you need to implement. This can be done using the generic system call facility described in the Minotaur external documentation. The sections that deal with this are: Section 10. Adding a New System Call Section 11. Generic System Call When the system call is called by a process, it will cause a trap to occur. When the kernel handles this trap, it will do whatever it needs to do to yield the process. This new kernel code to handle the yield trap should probably be added to Kernel/Process.b. Q) What is Condition A? A) This is the condition that is evaluated periodically for all processes in the background queue. If processes satisfy this condition, they will be moved to the foreground queue. This condition is that the average CPU time used per dispatching assignment for a process is less than the average CPU time per dispatching assignment for all processes in the system. "Average CPU time used per dispatching assignment" is the average amount of CPU time that expires between a process being dispatched (run by the dispatcher) and being switched out (either blocking or being put back onto the ready queue). The TOTAL CPU time used by a process is already calculated and maintained in the Stats section of its ProcStruct. You may need to add some new stats. Q) When is Condition A evaluated for the processes? A) You should probably implement some sort of daemon to periodically evaluate Condition A for all of the processes in the background queue and move those that satisfy this condition to the foreground queue. Q) Is this condition also to be evaluated when a process has finished executing and is about to be put back into one of the ready queues? (This was asked in one of the week 6 tutorial sessions.) A) No. The evaluation of condition A should NOT be evaluated at this point. Put new processes, kernel processes, and yielded processes in the foreground queue and all other processes in the background queue. If a process satisfies Condition A it will get moved later. If we have time, we'll go over the following review questions from Exercise 7.6: 3. Suppose in a system, a new process arrives at an average of 4 processes per minute and each such process requires an average of 12 seconds of service time. Estimate the fraction of time the CPU is busy in a system with a single processor. 4. Assume you have the following jobs to execute with one processor, with the jobs arriving in the order listed here: i t(pi) 0 80 1 20 2 10 3 20 4 50 A. Suppose a system uses FCFS scheduling. Give a Gantt chart illustrating the execution of these processes. B. What is the turnaround time for process p3? C. What is the average wait time for the processes? 5. Using the process load in the previous problem, suppose a system uses SJN scheduling. A. Give a Gantt chart illustrating the execution of these processes. Time Process 0-10 p0 10-30 p1 30-50 p2 50-100 p3 100-180 p4 B. What is the turnaround time for process p4?