Login Required

This note requires login to view the full content (464 lines total). Showing first 20 lines as preview. Please login to view the full content.

Login to unlock

Chapter 6: Process Synchronization

Created: 2025-12-16
Updated: 2025-12-16
  • background: concurrent access to shared data may result in data inconsistency
  • consumer-producer problem: counter itself will have synchronization issues
  • Race Condition: the outcome depends on which process finished first, which is uncontrollable
  • Solution: 1) non-preemptive scheduling: can be used in kernel mode only. 2) critical section
  • Critical Section
    • N processes are competing to use shared data
    • each process has a code segment, called critical section (CS), in which the shared data is accessed
    • ensure mutual exclusion: only one process can be in its CS at a time
  • Critical Section Requirements
    • Mutual Exclusion: only one process in CS at a time
    • Progress: No deadlock --- It ensures the system doesn't freeze. If the CS is empty, someone must be allowed to enter.
    • Bounded Waiting: No starvation --- It ensures fairness. An individual process cannot be forced to wait forever while others cut in line.
  • Entry Section: code to request permission to enter CS
  • Exit Section: code to release CS

Software Solutions

Peterson's Solution (2 processes only)

Login to unlock full content

Login Now