The critical section problem - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

The critical section problem

Description:

Individual jobs are entered and then linked into the queue ... Message queues. mailboxes. Pipes, named and unnamed. Bidirectional network connections ... – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 8
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
6
Critical section mechanisms
  • General classes in common use
  • Libraries for use in standard languages
  • Libc process-handling system calls
  • Pthread libraries
  • System V IPC
  • Semaphores
  • Message queues
  • Shared memory
  • Language-based
  • Monitors
  • Momitor is a class with mutual exclusion handling
  • Java threads
  • Extends thread, synchronized methods
  • Ada tasks

7
The basic mechanisms
  • Semaphores and related ideas
  • Conventional binary semaphore
  • Integer-valued semaphore
  • Reader/writer-oriented semaphores
  • Message-based
  • Message queues
  • mailboxes
  • Pipes, named and unnamed
  • Bidirectional network connections
Write a Comment
User Comments (0)
About PowerShow.com