Professional Documents
Culture Documents
Ch. 4 ... Part - 3
Ch. 4 ... Part - 3
System
CH. 4 Services
BY DR. VEEJYA KUMBHAR
Ch. 4 Operating System Services
Syllabus
• Processes ✓
• Process Structure ✓
• Process Scheduling ✓
• Scheduling Algorithms ✓
• Process Synchronization &
Deadlocks
• Thread Management
• Memory Management
• System Calls
• File System
Process Synchronization and Deadlocks
•Independent Process: The execution of one process does not affect the
execution of other processes.
When more than one process is executing the same code or accessing the same memory or any
shared variable in that condition there is a possibility that the output or the value of the shared
variable is wrong so for that all the processes doing the race to say that my output is correct this
condition known as a race condition.
Several processes access and process the manipulations over the same data concurrently, then
the outcome depends on the particular order in which the access takes place.
A race condition is a situation that may occur inside a critical section.
This happens when the result of multiple thread execution in the critical section differs according
to the order in which the threads execute.
Race conditions in critical sections can be avoided if the critical section is treated as an atomic
instruction.
Also, proper thread synchronization using locks or atomic variables can prevent race conditions.
Atomic Instruction
A critical section is a code segment that can be accessed by only one process
at a time.
So, the critical section problem means designing a way for cooperative
processes to access shared resources without creating data inconsistencies.
Critical Section
•If a process enters the critical section, then no other process should be allowed to enter the critical section.
This is called mutual exclusion.
•If a process is in the critical section and another process arrives, then the new process must wait until the
first process exits the critical section. In such cases, the process that is waiting to enter the critical section
should not wait for an unlimited period. This is called progress.
•If a process wants to enter into the critical section, then there should be a specified time that the process can
be made to wait. This property is called bounded waiting.
•The solution should be independent of the system's architecture. This is called neutrality.
•Some of the software-based solutions for critical section problems are Peterson's
solution, semaphores, monitors.
•Some of the hardware-based solutions for the critical section problem involve atomic instructions such
as TestAndSet,compare and swap, Unlock and Lock.
Thank
You