Home

About

Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network
FAQHELPSITE MAPCONTACT US


  Advanced Search  

 
Locks: OS Support Hardware support got us pretty far: working locks, and even
 

Summary: 28
Locks: OS Support
Hardware support got us pretty far: working locks, and even
(as with the case of the ticket lock) fairness in lock acquisition.
However, we still have a problem: what to do when a context
switch occurs in a critical section, and threads start to spin end-
lessly, waiting for the interrupt (lock-holding) thread to be run
again?
To
28.1 A Simple Approach: Just Yield, Baby
Our first try is a simple and friendly approach: when you are
going to spin, instead give up the CPU to another thread. Or, as
Al Davis might say, just yield, baby [D91]. Figure 28.1 presents
the approach.
In this approach, we assume an operating system primitive
yield() which a thread can call when it wants to give up the
CPU and let another thread run. Because a thread can be in one
of three states (running, ready, or blocked), you can think of this
as an OS system call that moves the caller from the running state
to the ready state, and thus promotes another thread to running.

  

Source: Arpaci-Dusseau, Remzi - Department of Computer Sciences, Department of Computer Sciences, University of Wisconsin at Madison

 

Collections: Computer Technologies and Information Sciences