0% found this document useful (0 votes)
8 views

process synchronization_notes

gy

Uploaded by

hosmatasamudras
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

process synchronization_notes

gy

Uploaded by

hosmatasamudras
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Process Synchronization - Chapter 5 Summary

Objectives
• Introduce the concept of process synchronization.

• Discuss the critical-section problem and solutions to ensure shared data consistency.

• Review software and hardware solutions for the critical-section problem.

• Examine classical synchronization problems.

• Explore tools for solving synchronization challenges.

Background
• Concurrent Execution: Processes can execute simultaneously and may be interrupted,
risking incomplete execution.

• Shared Data Access: Concurrent access leads to potential data inconsistency.

• Mechanisms for Consistency: Necessary for orderly execution of cooperating processes.

• Example: Consumer-producer problem — uses an integer counter to track buffer states.

The Critical-Section Problem


• Definition: Task of designing protocols allowing a system of processes to share resources
without interference.

• Structure:

• Critical Section: A section of code where shared resources are accessed.

• Entry Section: Code per process to request entry into the critical section.

• Exit Section: Follow-up section to release the critical section.

Requirements for Solutions

1. Mutual Exclusion: Only one process in the critical section at a time.

2. Progress: If no process in the critical section, selection of the next process must not be
postponed indefinitely.

3. Bounded Waiting: Limit on entry attempts after a process requests access.

Critical-Section Handling in Operating Systems


• Preemptive vs. Non-preemptive Kernels:

• Preemptive: Process preemption possible in kernel mode.


• Non-preemptive: Processes run until they exit kernel mode or yield the CPU.

Peterson’s Solution
• A two-process solution using atomic load and store instructions to ensure mutual
exclusion, progress, and bounded waiting are met:

• Variables: turn (indicates turn) and flag[] (indicates readiness).

Synchronization Hardware
• Locking Mechanisms:

• Uniprocessors: Disabling interrupts.

• Modern Multiprocessors: Using atomic hardware instructions like test-and-set or


compare-and-swap.

Lock-based Solutions:

• Mutex Locks: Simplified tool for protecting critical sections.

• Semaphore: Provides more sophisticated synchronization:

• Types include binary semaphores (similar to mutex) and counting semaphores (range
of values).

Classical Problems of Synchronization


1. Bounded-Buffer Problem: Coordination to fill and empty buffers correctly.

2. Readers-Writers Problem: Managing read/write access, prioritizing tasks.

3. Dining-Philosophers Problem: Abstract example of resource allocation among competing


processes.

Problem Handling Techniques

• Semaphore use, including considerations of deadlock and priority inversion, which may
arise with improper semaphore operations.

Monitors
• High-level abstraction for synchronization, allowing only one process at a time within the
monitor.

• Uses condition variables with operations like wait() and signal() to manage process state
transitions.

Monitor-driven Solutions:
• Dining Philosophers example solution using monitor-based methods to prevent deadlock
and manage concurrent activities.

Synchronization in Operating Systems


• Solaris: Uses adaptive mutexes and reader-writer locks.

• Windows: Utilizes dispatcher objects, spinlocks, and events.

• Linux: Offers semaphores, spinlocks, and reader-writer variants with options influenced by
kernel version.

• Pthreads: Provides API with mutex locks and condition variables, supporting
synchronization across different OS.

Alternative Approaches
• Transactional Memory: Uses atomic sequences of read-write operations to memory.

• OpenMP: Compiler directives and APIs for parallel programming.

• Functional Programming: Uses immutable variables, decreasing race conditions risks.

These notes encapsulate crucial concepts and solutions concerning process synchronization,
providing foundational insights suitable for further study in operating systems.

You might also like