SlidePub
Home
Categories
Login
Register
Home
General
14thjune youtube.ppt on operating systems Interupts
14thjune youtube.ppt on operating systems Interupts
anilvarsha1
7 views
11 slides
Feb 27, 2025
Slide
1
of 11
Previous
Next
1
2
3
4
5
6
7
8
9
10
11
About This Presentation
This a ppt for Operating system concepts
Size:
171.32 KB
Language:
en
Added:
Feb 27, 2025
Slides:
11 pages
Slide Content
Slide 1
Silberschatz, Galvin and Gagne ©2013Operating System Concepts – 9
th
Edition
Chapter 5: Process
Synchronization
Slide 2
5.2 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Critical-Section Handling in OS
Two approaches depending on if kernel is preemptive or non-
preemptive
Preemptive – allows preemption of process when running
in kernel mode
Non-preemptive – runs until exits kernel mode, blocks, or
voluntarily yields CPU
Essentially free of race conditions in kernel mode
Slide 3
5.3 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Synchronization Hardware
Many systems provide hardware support for implementing the
critical section code.
All solutions below based on idea of locking
Protecting critical regions via locks
Uniprocessors – could disable interrupts
Currently running code would execute without preemption
Generally too inefficient on multiprocessor systems
Operating systems using this not broadly scalable
Modern machines provide special atomic hardware instructions
Atomic = non-interruptible
Either test memory word and set value
Or swap contents of two memory words
Slide 4
5.4 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Solution to Critical-section Problem Using Locks
do {
acquire lock
critical section
release lock
remainder section
} while (TRUE);
Slide 5
5.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
test_and_set Instruction
Definition:
boolean test_and_set (boolean *target)
{
boolean rv = *target;
*target = TRUE;
return rv:
}
1.Executed atomically
2.Returns the original value of passed parameter
3.Set the new value of passed parameter to “TRUE”.
Slide 6
5.6 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Solution using test_and_set()
Shared Boolean variable lock, initialized to FALSE
Solution:
do {
while (test_and_set(&lock))
; /* do nothing */
/* critical section */
lock = false;
/* remainder section */
} while (true);
Slide 7
5.7 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
compare_and_swap Instruction
Definition:
int compare _and_swap(int *value, int expected, int new_value) {
int temp = *value;
if (*value == expected)
*value = new_value;
return temp;
}
1.Executed atomically
2.Returns the original value of passed parameter “value”
3.Set the variable “value” the value of the passed parameter “new_value”
but only if “value” ==“expected”. That is, the swap takes place only under
this condition.
Slide 8
5.8 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Solution using compare_and_swap
Shared integer “lock” initialized to 0;
Solution:
do {
while (compare_and_swap(&lock, 0, 1) != 0)
; /* do nothing */
/* critical section */
lock = 0;
/* remainder section */
} while (true);
Slide 9
5.9 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
Mutex Locks
TSL is complicated and generally inaccessible to application
programmers
OS designers build software tools to solve critical section
problem
Simplest is mutex lock
Protect a critical section by first acquire() a lock then
release() the lock
Boolean variable indicating if lock is available or not
Calls to acquire() and release() must be atomic
Usually implemented via hardware atomic instructions
But this solution requires busy waiting
This lock therefore called a spinlock
Slide 10
5.10 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9
th
Edition
acquire() and release()
acquire() {
while (available== false);
/* busy wait */
available = false;
}
release() {
available = true;
}
do {
acquire lock
critical section
release lock
remainder section
} while (true);
Slide 11
Silberschatz, Galvin and Gagne ©2013Operating System Concepts – 9
th
Edition
End of Chapter 5
Tags
Categories
General
Download
Download Slideshow
Get the original presentation file
Quick Actions
Embed
Share
Save
Print
Full
Report
Statistics
Views
7
Slides
11
Age
278 days
Related Slideshows
22
Pray For The Peace Of Jerusalem and You Will Prosper
RodolfoMoralesMarcuc
30 views
26
Don_t_Waste_Your_Life_God.....powerpoint
chalobrido8
32 views
31
VILLASUR_FACTORS_TO_CONSIDER_IN_PLATING_SALAD_10-13.pdf
JaiJai148317
30 views
14
Fertility awareness methods for women in the society
Isaiah47
29 views
35
Chapter 5 Arithmetic Functions Computer Organisation and Architecture
RitikSharma297999
26 views
5
syakira bhasa inggris (1) (1).pptx.......
ourcommunity56
28 views
View More in This Category
Embed Slideshow
Dimensions
Width (px)
Height (px)
Start Page
Which slide to start from (1-11)
Options
Auto-play slides
Show controls
Embed Code
Copy Code
Share Slideshow
Share on Social Media
Share on Facebook
Share on Twitter
Share on LinkedIn
Share via Email
Or copy link
Copy
Report Content
Reason for reporting
*
Select a reason...
Inappropriate content
Copyright violation
Spam or misleading
Offensive or hateful
Privacy violation
Other
Slide number
Leave blank if it applies to the entire slideshow
Additional details
*
Help us understand the problem better