|
| |
![]() |
|
Lab 1: TutorialThis is ONLY a preview of the tutorial. If you would like to view the entire tutorial, you must purchase the tutorial.Implementing LocksProvided: the public interface to locks in synch.h You: define the private data and implement the interface only need to modify synch.h and synch.cc should not need to modify the public parts of synch.h. Note: that it should not take you very much code to implement locks. (Hint: You may find semaphores and primitive thread routines useful as building blocks). Why Do We Need Locks...? to avoid race conditions to make sure that two processes do not get into each other's way when accessing a common resource to sequence the processes when there are dependencies among them Solution...? mutual exclusion
...
//----------------------------------------------------------------------
// Lock::Acquire
// Atomically wait until the lock is free, then set it to busy.
// Equivalent to Semaphore::P(), with the semaphore value of 0
// equal to busy, and semaphore value of 1 equal to free.
//----------------------------------------------------------------------
void Lock::Acquire()
{
#ifdef CHANGED
// someone else is holding the lock and its priority is less than mine
if(debug->IsEnabled(dbgSynch)){
if (lockHolder!=NULL){
cout<<"The lock is owned by: "<
This is ONLY a preview of the tutorial. If you would like to view the entire tutorial, you must purchase the tutorial.Each tutorial comes with the following:
This includes both documentation on understanding the concepts for each assignment and how to get started. Topics are accompanied with animations.
|
Nachos Introduction Tutorials |
||||||||||||||||||
| © 1999-2008 - All rights reserved. CS tutorials™ and the logo are registered trademarks of CS tutorials. | |||||||||||||||||||