CIS-4020 Homework #5: Locking

Due: Thursday, September 29, 2016

In the text read Chapter 10.

  1. How do spinlocks and mutexes in the kernel compare? Under what conditions does it make sense to use one over the other? See the Locking slides and Chapter 10 in the text.

  2. Suppose you are writing a kernel module that might be used by multiple threads (as most realistic modules are). Inside the module you have a fixed size pool of resources the threads need to to use. When a thread wishes to "check out" a resource from that pool, which synchronization primitive(s) would be appropriate: mutexes or a semaphores? Explain. What happens if there are no resources available and the thread sleeps? This problem is related to the producer/consumer problem, but it isn't identical. What's different about it?

  3. When Linux first started to support symmetric multiprocessors (in the early 2.x releases) a "big kernel lock" was introduced to lock the entire kernel against simultaneous access from multiple threads. Why was this necessary? Why wasn't it a major problem? What is bad about this approach?

  4. In Lab #3 multiple threads might try to fork at the same time. The lab did not ask you to use any locking. Is that correct? If so, explain why locks weren't needed. If not, explain where locks should be used and what kind of lock would be most appropriate.


Last Revised: 2016-09-18
© Copyright 2016 by Peter C. Chapin <PChapin@vtc.vsc.edu>