Operating System Notes PDF
Document Details
Uploaded by BlitheChrysoprase1270
Presidency College
Dr Vasantha
Tags
Summary
These notes cover operating system concepts, focusing on process synchronization and related topics. They explore process synchronization as a coordination mechanism for concurrent processes. The notes detail the concept of a race condition and possible solutions, as well as introduce the concept of semaphores.
Full Transcript
Presidency College OPERATING SYSTEM BCA 305T 3 SEM BCA Unit-2 Unit – II Process Synchronization and deadlocks: The Critical Section Problem, Synchronization hardware, Semaphores, Classical pro...
Presidency College OPERATING SYSTEM BCA 305T 3 SEM BCA Unit-2 Unit – II Process Synchronization and deadlocks: The Critical Section Problem, Synchronization hardware, Semaphores, Classical problems of synchronization, Critical regions Process Synchronization: Process Synchronization is the coordination of execution of multiple processes in a multi-process system to ensure that they access shared resources in a controlled and predictable manner There are two types of processes: 1. Independent Process:The execution of one process does not affect the execution of other processes. 2. Co-operating process:A process that can affect or be affected by other processes executing in the system. PROBLEM WITH CONCURRENT EXECUTION: Concurrent access to shared data may result in data inconsistency. Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes. Race condition: The situation where several processes access and manipulate shared data concurrently. The final value of the shared data depends upon which process finishes last. To prevent race conditions, concurrent processes must be synchronized(managed) ie need to ensure that only one process is executing at a time while accessing shared data and files. By Dr Vasantha,DCA-2024 Page 1 What is Race Condition Race condition: The situation where several processes access and manipulate shared data concurrently. The final value of the shared data depends upon which process finishes last. To prevent race conditions, concurrent processes must be synchronized(managed) ie need to ensure that only one process is executing at a time while accessing shared data and files. By Dr Vasantha,DCA-2024 Page 2 Critical –Section Problem ♥ Each process has a section of code, known as a critical section ♥ It is very important that when one process executing in its critical section no other process is allowed to execute in its critical section ♥ Only one process is allowed to execute in its critical section (even with multiple processors). ♥ So each process must first request permission to enter its critical section. ♥ Each process has the following sections of code. Entry Section: The code that requests permission to enter its critical section Exit Section: The critical section may be followed by it Remainder Section: The rest of the program Requirements of Critical-Section Problem Mutual Exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections. Progress. If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely. By Dr Vasantha,DCA-2024 Page 3 Bounded Waiting. A bound or limit must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted. By Dr Vasantha,DCA-2024 Page 4 2. Explain SEMAPHORE and its types A semaphore is a process synchronization tool A semaphore is an integer variable with non-negative values, which can be accessed only through two standard operations wait() and signal(). A semaphore can only be accessed using the following operations: wait() and signal(). o wait() operation is called when a process wants access to a resource. o signal() operation is called when a process is done using a resource, or when the patron is finished Wait() Signal () wait(Semaphore s) signal(Semaphore s) { { while s