home tutorials faq contact
CS tutorials Share you information

Next: Special Notes Up: Nachos Threads Previous: Threads & Scheduling

Synchronization and Mutual Exclusion

Low-level Nachos routines (including the ones discussed above) frequently disable and re-enable interrupts to achieve mutual exclusion (e.g., by calling Interrupt::SetLevel()).

Synchronization facilities are provided through semaphores. The Semaphore object provides the following operations:

Semaphore(char* debugName, int initialValue)
The constructor creates a new counting semaphore having an initial value of initialValue. The string debugName is also associated with the semaphore to simplify debugging.
void P()
Decrement the semaphore's count, blocking the caller if the count is zero.
void V()
Increment the semaphore's count, releasing one thread if any are blocked waiting on the count.


 

Nachos
Tutorials
Roadmap
Source Code

Introduction
Threads
Interrupts
Synchronization
System Calls
Exception Handling
Multiprogramming
File System
Networking

Tutorials
Lab 1 Tutorial
Lab 2 Tutorial
Lab 3 Tutorial
Lab 4 Tutorial
Lab 5 Tutorial


© 1999-2008 - All rights reserved. CS tutorials™ and the logo are registered trademarks of CS tutorials.