Lecture Notes for Operating Systems
Concurrency, 22 September 1999
These are provisional lecture notes, expect changes.
- concurrency - more than one processes executing at the same time
- three representative concurrency problems.
- the dining philosophers problem.
- example problem
- write a program that reads a tape drive, computes a while, and
writes another tape - the computation cannot start until the program has
both tape drives
- five identical copies of the program are to be run on a system
with five identical tape drives
- commands - get_tape(), compute(), release_tape()
- what does the program look like?
- model - due to dijkstra
- five philosophers, a table, plates of spaghetti, forks
- philosophers either think or eat, hungry; eating requires two
adjacent forks;
- some hungry philosopher eventually gets to eat
- every hungry philosopher eventually gets to eat
- a hungry philosopher that's eaten n meals has priority over a
hungry philosopher that's eaten m meals when n < m
- the readers-writers problem
- a never-ending stream of readers and writers access a database
- only one writer may change the database at a time, and only the
writer may access the database while its being changed
- any number of readers may access the database at the same time
- write an access program for readers and writers - safe and high
throughput, timely information
- the sleeping barber problem
- a barber shop with one barber chair and an n-customer bench.
- when the shop is empty the barber is sleeping in the barber chair
- a customer enters the store
- empty - wake up the barber
- bench not full - take a seat
- bench full - blow off the hair cut
- how many new customers in the shop at once
- ipc - inter-process communication or coordination
- competing access to shared resources
- coordinated execution behavior - synchronization
- race conditions - unmediated access to shared resources; two threads
updating a common counter, interrupts
- idea - make shared access non-interruptable or atomic or serial
- follow on problem - decreased performance
- two-part solution
- mutual exclusion to prohibit shared access
- critical regions or sections to delimit the scope of mutual
exclusion
- rules
- mutual exclusion only in critical regions
- cpu abstracted away - number and speed
- processes outside cr may not block entry into the cr
- processes attempting to enter the cr eventually will
This page last modified on 27 September 1999.