Concurrent Processes
Concurrent Processes
Concurrent Processes
Concurrent Processes
• Advantages:
– Simplicity
• Disadvantages:
– Reliability is no higher than for a single processor
system
– Can lead to poor use of resources
– Increases the number of interrupts
• Test-and-set:
– An indivisible machine instruction executed in a single
machine cycle to see if the key is available and, if it is,
sets it to unavailable
– The actual key is a single bit in a storage location that
can contain a 0 (free) or a 1 (busy)
– A process P1 tests the condition code using TS
instruction before entering a critical region
• If no other process in this region, then P1 is allowed to
proceed and condition code is changed from 0 to 1
• When P1 exits, code is reset to 0, allows other to enter
• Advantages:
– Simple procedure to implement
– Works well for a small number of processes
• Drawbacks:
– Starvation could occur when many processes are
waiting to enter a critical region
• Processes gain access in an arbitrary fashion
– Waiting processes remain in unproductive, resource-
consuming wait loops (busy waiting)
Algorithm
Producer Consumer
produce data P (full)
P (empty) P (mutex)
P (mutex) read data from buffer
write data into buffer V (mutex)
V (mutex) V (empty)
V (full) consume data
Understanding Operating Systems, Fourth Edition 30
Producers and Consumers (continued)
• (continued)
– Scheduling threads for execution
– Synchronizing thread execution using semaphores,
events, or conditional variables
– Terminating a thread and releasing its resources
• Ada:
– High-level concurrent programming language
developed by the U.S Department of Defense
– Initially intended for real-time and embedded
systems
– Made available to the public in 1980, named after
Augusta Ada Byron
– Standardized by ANSI in 1983 and nicknamed
Ada83
– Latest standard is ANSI/ISO/IEC-8652:1995 Ada 95