 
 
 
 
 
 
 Return to Contents
 
Return to Contents 
 
Process Synchronization
 Reference:  S&G, Chapter 6
 Reference:  S&G, Chapter 6 
 
  Concurrent Processes
-   several processes between starting and finishing
  Concurency
-   managing concurrent prcesses that share resources
  Mutual Exclusion
-   only one process is allowed access to a shared resource at the same time 
       (e.g. printer, processor, variable, data structure, semaphore)
-    Example: A train requires exclusive access to the track 
running through the tunnel.  
The shared variable is the single track going through the tunnel. 

  Resource Allocation
-   we will focus on shared variables
-    printers are actually controlled by one process called the  printer server or 
        printer daemon.  Modern operating systems do not use mutual exclusion techniques for controlling the printer.
 NOTE:
S&G, p. 167: ``we do assume that the basic machine-language instructions
(the primitive instructions such as load, store, and test) are executed
atomically.''  Another way of thinking about this is that the memory
hardware enforces mutually exclusive access to a word of memory.  Thus,
if two processes or processors try to write different values (say 16 and
29) to word OD45E, one or the other of these values will be written first
(say 29) and the other will be written second (say 16), but the bits of the
two values 16 and 29 will not be scrambled together.
  Low-Level Techniques for Mutual Exclusion
-   Turn Off Interrupts
	 -   in UNIX, if the operating system is about to make changes to its kernel data 
	       structures (e.g., create a new process by changing the process table)
	
-   turn off interrupts; therefore, a process may get more time on the 
	       processor
		 -   process cannot lose the processor because the short 
		       term scheduler is run in response to a timer interrrupt
		
 
	 
-   change data structure
		 -   keep the code very short without bugs
		
-   usually only one or two changes are needed here
		
 
	 
-   allow interrupts again
	
-   used on hercules 
	
-   great for single-processor machines
	
 
	  Two Problems:
	 -   if you need to do a lot of operations in the mutually exclusive segment
	
-   multiple processor machine (multiprocessor)
		 -   Zeus has 12 processors that share the same memory (shared 
		       memory architecture)
		
-   turning off interrupts gives one process exclusive access to its  
		       processor but other processes on other processors can still make
		       changes to memory 
		
 
 
 
-     Busy Wait (SpinLock)
-   one process ``busy waits'' for another
-   used for multiple processor machines
 
 
 
 
 
 
 
 
 Return to Contents
 
Return to Contents