Some sample practice questions……


Q1

The following is a program fragment (a function)

int count;
myfunc ( int x )
{
    count ++;
    x = count * x;
    return(x)
}

What modifications would be needed if any (show modified code) in the following cases. State any assumptions you may choose to make.

  1. The function is a kernel function in a uniprocessor operating system
  2. The function is a kernel function in a multiprocessor operating system
  3. The function is a shared library (user level)  function in a uniprocessor operating system
  4. The function is a shared library (user level) function in a multiprocessor operating system

Q2

 

  1. Provide two programming examples of multithreading that do not improve performance over a single-threaded solution.
  2. Describe the actions taken by kernel to context switch between kernel-level threads.
  3. Describe the actions taken by a thread library to context switch between user-level threads.

 

Q3

Find a good algorithm for cache coherence in shared memory multiprocessors. Describe the algorithm and state (briefly) the positives and the negatives of the algorithm.


Q4

Supposed we are running three applications on a shared memory multiprocessor with 4 CPUs. Each application is "embarrassingly parallel" and consists of 3 threads, each thread running for 20 seconds. The CPU scheduler uses round robin scheduler, with a time quantum of 1 sec. 

What would be the performance (average time to completion) if the scheduler used co-scheduling versus if it did not.


Q5]

Write  a Linda program to do the following:

  1. There is one manager and five workers. The manager creates random numbers and sends them to the workers. Each worker repeatedly receives numbers and sums them. When the manager decides to stop generating numbers, all workers send their totals to the manager who then produces the final total. The final result, of course, is the sum of all the random numbers generated.
  2. How would you modify this program if the number of workers were not known when the manager starts running?