The critical section problem - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

The critical section problem

Description:

Definition of the critical section problem. A theoretical description, but fits the real world ... No process has to wait if the critical section is free ... – PowerPoint PPT presentation

Number of Views:122
Avg rating:3.0/5.0
Slides: 6
Provided by: tomn8
Category:

less

Transcript and Presenter's Notes

Title: The critical section problem


1
The critical section problem
  • Reason why
  • Mechanisms
  • Typical problems

2
Why are critical sections used
  • Protecting temporary use of shared resources
  • Data structures
  • Typically the master data structure (print queue
    index) is the one shared
  • Individual jobs are entered and then linked into
    the queue
  • Entering job needs no protection linking does
  • Devices
  • Example scanner needs protection because entry
    operation is human and slow
  • Printer is held by system anyway
  • File system
  • Files and the file system structure are global
  • These global structures are cached for speed
  • Only the data blocks themselves actually move
    with every operation

3
Definition of the critical section problem
  • A theoretical description, but fits the real
    world
  • Any correct solution must satisfy
  • Mutual exclusion is enforced
  • Only processes wanting access participate in the
    decision
  • No process has to wait if the critical section is
    free
  • No process has to wait more than a finite number
    of steps
  • Assumption processes stay in the critical
    section only a finite time
  • Approaches
  • Software only
  • Special instructions
  • Interprocess communication mechanisms central
    controlling process for any given resource

4
Various software methods
  • Two-process purely programmed algorithms
  • Dijkstras algorithm
  • First valid solution (1965)
  • Petersons algorithm
  • Distinctly simpler (1968) but no real advantage
  • Problems with both
  • Two-process, not n-process
  • Busy-waiting
  • Global variables
  • Special instructions
  • Exchange requires static variable inside the
    function
  • TestAndSet requires static variable inside the
    function

5
General code for a critical section
Global variable definitions
While (1) wait to enter C. S. critical
section notify leaving C. S. remainder
section
Process I Local Variables Process I Code
Process II Local Variables Process II Code
Write a Comment
User Comments (0)
About PowerShow.com