[cs33211] CS33211 How to ensure threads won't starve?

Mikhail Nesterenko mikhail at cs.kent.edu
Wed Oct 10 23:14:50 EDT 2012


> Hello Dr. Nesterenko,
> 
> Consider the following scenario.
> 
> 1) 1st pedestrian acquires the zone lock to cross street so that other cars
> cannot enter. (More pedestrians may enter while lock is acquired).
> 2) Car requests the zone lock.
> 3) Final pedestrian leaves the zone and unlocks zone lock
> 4) Pedestrian requests the zone lock.
> 
> Now, what is preventing a pedestrian from acquiring the zone lock again?
> (The car threads would starve).
>
> 
> One more Question...
> 
> The project guideline does not specify how long cars should wait for the
> pedestrians. For example, suppose a pedestrian acquires the zone lock and
> begins walking. Then more pedestrians enter the zone. As long as
> pedestrians keep entering the zone while there are pedestrians currently in
> it, the zone will never be available to cars. This is exactly like the
> readers-writers problem on the slides where the writers are favored. How
> should we handle this? Thank you.

A pedestrian has to yield to cars. So, if there is a car and a pedestrian
waiting, even if there is another pedestrian crossing, the car goes first.

Note that a pedestrian should not wait for more than two cars.

Thanks,
-- 
Mikhail


More information about the cs33211 mailing list