Operating System of engineering technology.ppt

anikr12121 6 views 11 slides Aug 15, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

Operating system


Slide Content

NAME : Akash Khanra ROLL : 12500122104 SEMESTER : SECTION : B SUBJECT : Operating System   1

Process Synchronization

3 Process Synchronization in Operating Systems Process synchronization is a fundamental concept in operating systems. It ensures that multiple processes running concurrently can access shared resources without causing data corruption or unexpected behavior.

4 The Need for Process Synchronization In modern operating systems, processes often need to share resources such as files, databases, and peripherals. Without proper synchronization, concurrent access to shared resources can lead to race conditions, where the outcome of operations depends on the unpredictable order in which processes execute. Data Consistency Shared data must be consistent, even when multiple processes are accessing it simultaneously. Resource Management Ensuring fair and efficient allocation of shared resources, like printers or network connections. System Stability Preventing deadlocks, where processes become blocked indefinitely, waiting for each other. Process Cooperation Allowing processes to collaborate effectively, sharing information and completing tasks together.

5 Critical Sections and Race Conditions A critical section is a code segment where shared resources are accessed. A race condition occurs when multiple processes access and modify shared resources concurrently, leading to unpredictable results . Critical Section A code segment where shared resources are accessed exclusively. Race Condition Unpredictable outcome due to interleaving of instructions from multiple processes. Example Two processes incrementing a shared counter. The final value depends on the order of execution.

6 Mutual Exclusion Mechanisms Mutual exclusion ensures that only one process can access a critical section at a time. This prevents race conditions and ensures data integrity. Disabling Interrupts Disabling interrupts prevents context switching, ensuring a process can execute without interruption. Lock Variables A shared variable that indicates whether a critical section is in use, using a test-and-set operation. Semaphores A synchronization primitive that provides a more flexible and robust mechanism for controlling access to shared resources.

7 Semaphores and Their Operations Semaphores are integer variables that act as signaling mechanisms between processes. They are used to control access to shared resources and coordinate the execution of processes. Operation Description Wait (S) Decrements the semaphore S. If S is negative, the process is blocked until S becomes non-negative. Signal (S) Increments the semaphore S. If S is negative, a blocked process is unblocked and allowed to proceed.

Deadlocks and Starvation 8 Deadlock occurs when two or more processes are blocked indefinitely, each waiting for a resource held by another process. Starvation occurs when a process is repeatedly denied access to a shared resource, even though the resource is available. Deadlock A situation where two or more processes are blocked indefinitely. Starvation A process is repeatedly denied access to a shared resource. Resource Contention Both deadlocks and starvation arise due to competition for shared resources.

9 Synchronization Problems and Solutions Various synchronization problems arise in real-world applications, each requiring specific solutions. These solutions often involve careful design of critical sections, synchronization primitives, and error handling. Producer-Consumer Problem Two processes share a buffer: one produces data, the other consumes it. Readers-Writers Problem Multiple readers can access shared data concurrently, but only one writer at a time. Dining Philosophers Problem Five philosophers share five forks, and each needs two forks to eat, leading to potential deadlock.

Conclusion and Key Takeaways Process synchronization is a critical aspect of operating systems, ensuring efficient and reliable resource sharing. Understanding the concepts of critical sections, mutual exclusion, semaphores, and common synchronization problems is essential for building robust and scalable applications . Data Integrity Protecting shared resources from corruption due to concurrent access. Process Coordination Enabling processes to collaborate and communicate effectively. System Performance Optimizing resource utilization and preventing performance bottlenecks.

Thank You
Tags