issues in concurrent systems
DESCRIPTION
Lecture 27. Issues in Concurrent Systems. LB. Online Survey. The Spring term course/instructor opinion survey will be available during the period Monday, April 17th through Friday, April 28th from 6am to 11:59pm each day: http://www.coursesurvey.gatech.edu. Fabulous Prizes!. LB. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/1.jpg)
Issues in Concurrent Systems
![Page 2: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/2.jpg)
Online Survey
The Spring term course/instructor opinion survey will be available during the period Monday, April 17th through Friday, April 28th from 6am to 11:59pm each day:
http://www.coursesurvey.gatech.edu
LB
![Page 3: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/3.jpg)
Final Exam Schedule
• CS1311 Sections L/M/N Tuesday/Thursday 10:00 A.M.
• Exam Scheduled for 8:00 Friday May 5, 2000• Physics L1
LB
![Page 4: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/4.jpg)
Final Exam Schedule
• CS1311 Sections E/F Tuesday/Thursday 2:00 P.M.
• Exam Scheduled for 2:50 Wednesday May 3, 2000• Physics L1
LB
![Page 5: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/5.jpg)
Issues in Concurrent Systems
• Concurrency is great, but there are some problems to be addressed:– Mutual exclusion (protection)– Starvation (fairness)– Deadlock– Time– Synchronization– Increased Cost of Overhead
![Page 6: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/6.jpg)
Mutual Exclusion
By providing mutual exclusion, we can protect a resource from being “corrupted.”
Last Seaton flight 121
Operator 1 Operator 2
![Page 7: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/7.jpg)
Banking Example
• Gertrude makes $100 deposit
• Get current balance of $500
• balance = 500 + 100 = 600• Write new balance back to
disk thus on disk = $600
• Heathcliffe requests $100 withdrawl
• Get current balance of $500• balance = 500 - 100 = 400
• Write new balance back to disk thus on disk = $400
TimeSlice
LB
![Page 8: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/8.jpg)
Banking Example• Gertrude makes $100
deposit• Request and get AcctLock• Get current balance of $500
from disk
• balance = 500 + 100 = 600• Write back balance = $600• Release AcctLock
• Heathcliffe requests $100 withdrawl
• Request AcctLock• Wait(AcctLock)
• Get AcctLock• Read balance = 600• balance = 600 - 100 = 500• Write back $500
LB
![Page 9: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/9.jpg)
Fairness
• Multiple processors (users) competing for a resource.
• Make sure that all jobs get serviced (have access to the resource) fairly.
• Policies include:– Shortest job first– First come, first served– More sophisticated schemes
![Page 10: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/10.jpg)
First Come, First Served
Fred - 10 hours
Wilma - 5 minutes
Dino - 2 seconds
Fred’s long job blocks others
![Page 11: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/11.jpg)
Shortest Job First
Dino - 2 secondsPriority Queue
priority: 1
Wilma - 5 minutespriority: 2
Fred - 10 hourspriority: 10
Fast jobs first, but what if new fast jobs keep arriving? Will Fred’s job ever get served?
![Page 12: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/12.jpg)
Multiple Queues
1 minute jobs
2 minute jobs
4 minute jobs
8 minute jobs
Job 123 Job 86
Job 5
Job 123
Job 13
Job 23
Job 12
LB
![Page 13: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/13.jpg)
Typical Multiple Queue Rules
• Jobs that take longer than expected get moved
down.
• Jobs that less time than expected get moved up.
• Jobs that have been waiting a long time get
moved up.
LB
![Page 14: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/14.jpg)
Deadlock
When sharing resources, jobs can get into never-ending waits:
Job A Job B
resource C resource D
A has resource C, needs DB has resource D, needs C
![Page 15: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/15.jpg)
Preventing Deadlock
• There are several algorithms to prevent deadlock:– Require resources to always be
acquired in a particular order.– If the job can’t acquire all the resources
it needs for a particular task, it frees all the resources it has reserved.
– Establish priorities for resource queues.
![Page 16: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/16.jpg)
Dining Philosophers
Chopsticks
LB
![Page 17: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/17.jpg)
Algorithm DiningPhilosophersLoopexitif(no more food)
Engage in philosophical discussion
Get left chopstick
Get right chopstick
Eat some food with chopsticks
Put chopsicks downEndloop
LB
![Page 18: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/18.jpg)
Dining Philosophers
LB
![Page 19: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/19.jpg)
Dining PhilosophersYak
LB
![Page 20: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/20.jpg)
Dining Philosophers
Yak
LB
![Page 21: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/21.jpg)
Dining Philosophers
Yak
LB
![Page 22: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/22.jpg)
Dining Philosophers
Yak
LB
![Page 23: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/23.jpg)
Dining Philosophers
Yak
LB
![Page 24: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/24.jpg)
Dining Philosophers
Yak
LB
![Page 25: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/25.jpg)
Dining PhilosophersYak
LB
![Page 26: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/26.jpg)
Dining Philosophers
Yak
LB
![Page 27: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/27.jpg)
Dining PhilosophersYak
Delicious!
LB
![Page 28: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/28.jpg)
Dining Philosophers
LB
![Page 29: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/29.jpg)
Dining Philosophers
Deadlock!
LB
![Page 30: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/30.jpg)
Algorithm DiningPhilosophersLoopexitif(no more food)
Engage in philosophical discussion
Get left chopstick
Get right chopstick
Eat some food with chopsticks
Put chopsicks downEndloop
Stuck here!
LB
![Page 31: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/31.jpg)
Preventing Philosopher Deadlock
• Add a resource– Add a chopstick in the middle.
• Alter the order of acquisition– Number the chopsticks in sequence– Change algorithm to take odd numbered
chopstick first.
![Page 32: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/32.jpg)
Dining Philosophers
4
3
2
1
LB
![Page 33: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/33.jpg)
Dining Philosophers
4
3
2
1
LB
![Page 34: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/34.jpg)
Dining Philosophers
4
3
2
1
LB
![Page 35: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/35.jpg)
Dining Philosophers
4
3
2
1
Yummy!
LB
![Page 36: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/36.jpg)
Preventing Philosopher Deadlock• Add a resource
– Add a chopstick in the middle.• Alter the order of acquisition
– Number the chopsticks in sequence– Change algorithm to take odd numbered
chopstick first.• Have a “back-off and try again” policy
– If a philosopher waits for a chopstick for more than a few minutes, release held chopstick.
LB
![Page 37: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/37.jpg)
Time
Computer 1Computer 2
Computer 3
• Whose system clock is correct in a distributed system?
![Page 38: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/38.jpg)
Time
• Hardware Approach: Develop highly sophisticated atomic clocks and synchronize off of US standard time clock.
• Software Approach: Use algorithms that don’t rely on real time at all!
• Mix of the two.
LB
![Page 39: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/39.jpg)
Synchronization
Process1
Process2
• What if one process wants to exchange data with another process?
• How do the processes “get together” to coordinate their communication?
• Asynchronous vs Synchronous Operations
![Page 40: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/40.jpg)
Impact of Processing Overhead
2 4 8 16 32 64 1281
248
163264
128
1
R = 0
R = 0.001
R = 0.02
R = 0.1
Actual Number of Processors
Effe
ctiv
e nu
mbe
r of
Proc
esso
rs
R = Context switch TimeTask Time
![Page 41: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/41.jpg)
CS Specialties• Operating Systems people worry about the
effective allocation and coordination of resources within a single computer system.
• Networking people worry about effective communication between multiple computer systems over networks.
• Database people worry about providing fast access to specific data (located within large amounts of data) while protecting the integrity of data from corruption by multiple concurrent users.
• Hardware Architecture people worry about how processors are designed so that they can work effectively with algorithms, compilers and data structures.
![Page 42: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/42.jpg)
CS Core Specialty Areas• Systems• Theory• Languages/Compilers• Architecture• Database• Networking/Telecom• HCI• Security• Biocomputing• ...
LB
![Page 43: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/43.jpg)
Questions?
![Page 44: Issues in Concurrent Systems](https://reader035.vdocuments.net/reader035/viewer/2022062502/5681675b550346895ddc21d0/html5/thumbnails/44.jpg)