TCSS 422 - Operating Systems

Call Traces

Below are examples of three types of kernel services that produce program discontinuities and lead to a call to the OS scheduler/dispatcher. These will be reviewed in class prior to the in-class exercise.

Timer Interrupt and Context Switch

The timer downcounts to zero and generates an interrupt signal. The CPU saves state on the system stack and starts the timer interrupt service routine (ISR) via the regular interrupt vector lookup. The ISR saves the state of the computation of the running process and puts the process pointer onto the tail of the ready queue. It then calls the scheduler. Here we treat the dispatching code as part of the scheduler. Upon completion of its work, i.e. preparing the next process for running, the scheduler executes a standard return from a function. This takes it back to the ISR which completes some clean up and then executes a return from interrupt (IRET). The question is: how does the IRET result in the next process (B) getting to run? What must be happening in the ISR to cause this non-standard return behavior?

In the figure are lower case letters, a through f. You should be prepared to discuss what the software is doing at each point so designated. Letter f: what happens in the ready queue?

 

A trace of threads of execution after a timer interrupt. Note the ready queue.

 

I/O Service Request and Context Switch

An I/O service request such as a call to the printf() function results in a system call that results in a TRAP to an I/O trap service routine in the kernel. This routine does some work and then calls the scheduler as above. Note that process C was waiting for an I/O service when process B made the request. Can you explain why the I/O queue shows these processes before and after the service request? Why does the scheduler remove process B from the running state and dispatch process A? Be able to explain what the code is doing at each of the lower case letters in the figure.

A trace of threads of execution after an I/O service request.

 

I/O Completion Interrupt w/o Context Switch

After an I/O device that had been requested by process C has completed its work it generates an interrupt that causes the CPU to save the processor state on the system stack as with the timer interrupt. In the case of such an interrupt, what does the scheduler have to do? Why does the dispatcher not do a context switch and let process D run? Using the same lettering as in the diagram above, tell what is happening at each of these points in this diagram.

A trace of threads of execution after an I/O service interrupt.