0% found this document useful (0 votes)
7 views22 pages

8.process Synchronization

Uploaded by

Ghaffar Buzdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views22 pages

8.process Synchronization

Uploaded by

Ghaffar Buzdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Process Synchronization

Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.2 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.3 Silberschatz, Galvin and Gagne ©2018
Process Synchronization
 Process Synchronization Mode

 (i) Serial Mode : only one process executed at a time. E.g ATM

 (ii) Parallel Mode : More than one processes executed Simaltanously.


E.g Multiprogramming. It have two types.

 (a) Independent Process : Execution of one process do not effect to


an other process. (No common to each other)

 (b) Co-Operative Process : The processes effect to each other due to


some share variable, memory, code or resources(printer, cpu, H/w)

Operating System Concepts – 10th Edition 6.4 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.5 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.6 Silberschatz, Galvin and Gagne ©2018
Critical Section Problem
 Consider system of n processes {p0, p1, … pn-1}
 Each process has critical section segment of code
• Process may be changing common variables, updating table,
writing file, etc.
• When one process in critical section, no other may be in its
critical section
 Critical section problem is to design protocol to solve this
 Each process must ask permission to enter critical section in entry
section, may follow critical section with exit section, then
remainder section

Operating System Concepts – 10th Edition 6.7 Silberschatz, Galvin and Gagne ©2018
Critical Section

 General structure of process Pi

Operating System Concepts – 10th Edition 6.8 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.9 Silberschatz, Galvin and Gagne ©2018
Critical-Section Problem (Cont.)
Requirements for solution to critical-section problem

1. Mutual Exclusion - If process Pi is executing in its critical section,


then no other processes can be executing in their critical sections
2. 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 process that will enter the critical section next cannot
be postponed indefinitely
3. Bounded Waiting - A bound 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.

Operating System Concepts – 10th Edition 6.10 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.11 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.12 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.13 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.14 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.15 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.16 Silberschatz, Galvin and Gagne ©2018
Synchronization Hardware
 Many systems provide hardware support for implementing the
critical section code.
 Uniprocessors – could disable interrupts
• Currently running code would execute without preemption
• Generally too inefficient on multiprocessor systems

Operating System Concepts – 10th Edition 6.17 Silberschatz, Galvin and Gagne ©2018
Hardware Instructions
 Special hardware instructions that allow us to either
test-and-modify the content of a word, or to swap the
contents of two words atomically (uninterruptedly.)
• Test-and-Set instruction
• Swap instruction

Operating System Concepts – 10th Edition 6.18 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.19 Silberschatz, Galvin and Gagne ©2018
The TestAndSet Instruction

 Definition

 Properties
• Executed atomically
• Returns the original value of passed parameter
• Set the new value of passed parameter to true

Operating System Concepts – 10th Edition 6.20 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.21 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 6.22 Silberschatz, Galvin and Gagne ©2018

You might also like