Sample Midterm

  1. What are the values of the integer variables x and y when the following program completes? (If either variable could have more than one value, say why.)
    
    	y = 2;
    	parbegin
    		x = y * 2;
    		y = 6;
    	parend;
    

  2. Is the following true or false? Justify your answer. “When several processes access shared information in primary storage, mutual exclusion must be enforced to prevent the production of indeterminant results.”

  3. Process A should finish before process B starts, and process B should finish before either of processes C or D start. Show how these processes may use two semaphores to provide the necessary synchronization.

  4. A bounded semaphore s is a counting semaphore that cannot exceed a given value smax > 0. The corresponding signal and wait operations are:

    signal(s): wait until s < SMAX; then increment s by 1
    wait(s): wait until s > 0; then decrement s by 1

    Write a monitor to implement bounded semaphores. (Hint: assume the semaphore is to be initialized to the constant SINIT and the maximum value is SMAX.)

  5. Suppose a scheduling algorithm favors those programs which have used little processor time in the recent past. Why will this algorithm favor I/O bound programs and yet not permanently starve CPU bound programs?

  6. Assume you have been given the following jobs with the indicated arrival and service times:

     name  arrival time  service time 
    A03
    B25
    C42
    D61
    E84
    1. When, and in what order, would these jobs run if the scheduling algorithm were first come first serve?
    2. When, and in what order, would these jobs run if the scheduling algorithm were shortest job next?
    3. When, and in what order, would these jobs run if the scheduling algorithm were round robin with a quantum of 2? Assume that if events are scheduled to happen at exactly the same time, that new arrivals precede terminations, which precede quantum expirations.

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 150, Operating Systems
Version of April 20, 2022 at 7:47PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh