Title: Issues in Concurrent Systems
1Issues in Concurrent Systems
Lecture 27
2Online Survey
LB
- The Spring term course/instructor opinion survey
will be available during the period Monday, April
17th through Friday, April 28th from 6am to
1159pm each day - http//www.coursesurvey.gatech.edu
Fabulous Prizes!
3Final Exam Schedule
LB
- CS1311 Sections L/M/N Tuesday/Thursday 1000 A.M.
- Exam Scheduled for 800 Friday May 5, 2000
- Physics L1
4Final Exam Schedule
LB
- CS1311 Sections E/F Tuesday/Thursday 200 P.M.
- Exam Scheduled for 250 Wednesday May 3, 2000
- Physics L1
5Issues 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
6Mutual Exclusion
- By providing mutual exclusion, we can protect a
resource from being corrupted.
7Banking Example
LB
- 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
Time Slice
Final Answer?
8Banking Example
LB
- 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
9Fairness
- 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
10First Come, First Served
Fred - 10 hours
Wilma - 5 minutes
Dino - 2 seconds
Freds long job blocks others
11Shortest Job First
Priority Queue
Dino - 2 seconds
priority 1
Fast jobs first, but what if new fast jobs keep
arriving? Will Freds job ever get served?
12Multiple Queues
LB
Job 123
Job 86
Job 5
Job 13
Job 23
8 minute jobs
Job 123
Job 12
13Typical Multiple Queue Rules
LB
- 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.
14Deadlock
- When sharing resources, jobs can get into
never-ending waits
Job B
Job A
resource D
resource C
A has resource C, needs D B has resource D, needs
C
15Preventing Deadlock
- There are several algorithms to prevent deadlock
- Require resources to always be acquired in a
particular order. - If the job cant acquire all the resources it
needs for a particular task, it frees all the
resources it has reserved. - Establish priorities for resource queues.
16Dining Philosophers
LB
17LB
- Algorithm DiningPhilosophers
- Loop
- exitif(no more food)
- Engage in philosophical discussion
-
- Get left chopstick
- Get right chopstick
- Eat some food with chopsticks
- Put chopsicks down
- Endloop
18Dining Philosophers
LB
19Dining Philosophers
LB
Yak
20Dining Philosophers
LB
Yak
21Dining Philosophers
LB
Yak
22Dining Philosophers
LB
Yak
23Dining Philosophers
LB
Yak
24Dining Philosophers
LB
Yak
25Dining Philosophers
LB
Yak
26Dining Philosophers
LB
Yak
27Dining Philosophers
LB
Yak
Delicious!
28Dining Philosophers
LB
29Dining Philosophers
LB
Deadlock!
30LB
- Algorithm DiningPhilosophers
- Loop
- exitif(no more food)
- Engage in philosophical discussion
-
- Get left chopstick
- Get right chopstick
- Eat some food with chopsticks
- Put chopsicks down
- Endloop
Stuck here!
31Preventing 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.
32Dining Philosophers
LB
1
4
2
3
33Dining Philosophers
LB
1
4
2
3
34Dining Philosophers
LB
1
4
2
3
35Dining Philosophers
LB
1
Yummy!
4
2
3
36Preventing Philosopher Deadlock
LB
- 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.
37Time
- Whose system clock is correct in a distributed
system?
38Time
LB
- Hardware Approach Develop highly sophisticated
atomic clocks and synchronize off of US standard
time clock. - Software Approach Use algorithms that dont rely
on real time at all! - Mix of the two.
39Synchronization
- 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
Process 2
Process 1
40Impact of Processing Overhead
128
R 0
64
R 0.001
32
Effective number of Processors
16
R 0.02
8
R 0.1
4
2
1
2
4
8
16
32
64
128
1
Actual Number of Processors
41CS 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.
42CS Core Specialty Areas
LB
- Systems
- Theory
- Languages/Compilers
- Architecture
- Database
- Networking/Telecom
- HCI
- Security
- Biocomputing
- ...
43Questions?
44(No Transcript)