CSC/ECE 506 Spring 2011/ch7 jp: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
Line 1: Line 1:
=Peterson's Algorithm=
=Peterson's Algorithm=
Peterson’s algorithm, also known as Peterson’s solution, is an algorithm that addresses the critical section problem by meeting the 3 criteria of the problem: mutual exclusion, progress, and bounded waiting.
int turn;  // turn for execution
int interested[2];  // the processors interested
void enter_region(int process)
{
  int otherProcess;
  otherProcess = 1 - process;   
  interested[process]=1; 
  turn = process;       
  while(turn == process && interested[otherProcess] == 1)
      {
  // busy wait
      }
}
void leave_region(int process)
{
  interested[process] = 0;
}


=Page tables=
=Page tables=

Revision as of 22:03, 20 March 2011

Peterson's Algorithm

Peterson’s algorithm, also known as Peterson’s solution, is an algorithm that addresses the critical section problem by meeting the 3 criteria of the problem: mutual exclusion, progress, and bounded waiting.

int turn;  // turn for execution
int interested[2];   // the processors interested
void enter_region(int process) 
{ 
  int otherProcess; 
  otherProcess = 1 - process;    
  interested[process]=1;  
  turn = process;         
  while(turn == process && interested[otherProcess] == 1)
     {
 	// busy wait
     }
} 
void leave_region(int process) 
{ 
  interested[process] = 0; 
}

Page tables