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

From Expertiza_Wiki
Jump to navigation Jump to search
Line 24: Line 24:


=Page tables=
=Page tables=
An issue with multiprocessor systems is how to enter the critical section.  One software solution is to use Page tables to ensure mutual exclusion, progress, and bounded waiting which are the 3 criteria needed to be met.
==Memory Coherence==
As with other forms of synchronization, page tables for multiprocessor systems must have strategies for handling data.  As discussed in Li and Hudaks article, there are two basic approaches for page synchronization, invalidation and write-broadcast.  In an invalidation approach, there is only 1 owner for each page, having either read or write access to the page.  In a write-broadcast, as the name implies, it broadcasts or writes all copies for the page data and returns the faulty instruction.
As mentioned in the invalidation approach, there must be an owner for the page.  There are two basic ownership approaches for page tables, fixed or dynamic.  In a fixed ownership approach, 1 processor always owns the same page.  Other processors who want read or write access to the page location must negotiate for the access.  For dynamic ownership, there are two subcategories, centralized or distributed management.
==Centralized Management==
In centralized management for dynamic pages, there is a single, central processor that maintains a page table which has a table for each page and each page has 3 fields: owner, copy set, and lock.  The owner field consists of the single processor which owns the page, which could also be thought as the most recent processor to have write access.  The copy set field has a list of all processors that have a copy of the page.  This field helps to avoid a broadcast.  The lock field is used for synchronizing requests.
==Distributed Management==
There are 2 schemes for Distributed Management: fixed and dynamic.  For a fixed distributed management, each processor in the system is given a predetermined subset of pages to manage.  A simple, straightforward distribution of responsibility is the divide pages evenly among the system, although there are other solutions which could be tailored to the applications needs.
In a dynamic distributed management system, each processor keeps track of ownership of all pages within their local table.  Instead of the owner field in the Centralized Management scheme, instead there is a probOwner field which has the probable owner of the page for a page fault.

Revision as of 22:04, 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; 
}

The algorithm uses two variables as seen above, interested and turn. If a flag value for interested is set to 1, it indicates the process wants to enter the critical section. The variable turn is a placeholder for the process whose turn will be next allowed to enter the critical section. As seen above, Process1 has been given priority over P0.

To ensure mutual exclusion, the variable interested and turn are set to ensure only 1 can enter the critical section at a time. To ensure Progress, once a processor has left the critical section the other processors can determine which processor is allowed into the critical section next. To ensure bounded waiting, as seen with the above code, a process will wait no longer than 1 turn to enter the critical section as the variable turn=1 will be enabled.

Page tables

An issue with multiprocessor systems is how to enter the critical section. One software solution is to use Page tables to ensure mutual exclusion, progress, and bounded waiting which are the 3 criteria needed to be met.

Memory Coherence

As with other forms of synchronization, page tables for multiprocessor systems must have strategies for handling data. As discussed in Li and Hudaks article, there are two basic approaches for page synchronization, invalidation and write-broadcast. In an invalidation approach, there is only 1 owner for each page, having either read or write access to the page. In a write-broadcast, as the name implies, it broadcasts or writes all copies for the page data and returns the faulty instruction.

As mentioned in the invalidation approach, there must be an owner for the page. There are two basic ownership approaches for page tables, fixed or dynamic. In a fixed ownership approach, 1 processor always owns the same page. Other processors who want read or write access to the page location must negotiate for the access. For dynamic ownership, there are two subcategories, centralized or distributed management.

Centralized Management

In centralized management for dynamic pages, there is a single, central processor that maintains a page table which has a table for each page and each page has 3 fields: owner, copy set, and lock. The owner field consists of the single processor which owns the page, which could also be thought as the most recent processor to have write access. The copy set field has a list of all processors that have a copy of the page. This field helps to avoid a broadcast. The lock field is used for synchronizing requests.

Distributed Management

There are 2 schemes for Distributed Management: fixed and dynamic. For a fixed distributed management, each processor in the system is given a predetermined subset of pages to manage. A simple, straightforward distribution of responsibility is the divide pages evenly among the system, although there are other solutions which could be tailored to the applications needs.

In a dynamic distributed management system, each processor keeps track of ownership of all pages within their local table. Instead of the owner field in the Centralized Management scheme, instead there is a probOwner field which has the probable owner of the page for a page fault.