Concurrency: ISBN 0-321-49362-1
Concurrency: ISBN 0-321-49362-1
Concurrency: ISBN 0-321-49362-1
Concurrency
ISBN 0-321-49362-1
Chapter 13 Topics
• Introduction
• Introduction to Subprogram-Level Concurrency
• Semaphores
• Monitors
• Message Passing
• Ada support for Concurrency
• Java Threads
• C# Threads
• Concurrency in Functional Languages
• Statement-Level Concurrency
• Semaphores
• Monitors
• Message Passing
• Dijkstra - 1965
• A semaphore is a data structure consisting of a
counter and a queue for storing task descriptors
– A task descriptor is a data structure that stores all of the
relevant information about the execution state of the task
• Semaphores can be used to implement guards on
the code that accesses shared data structures
• Semaphores have only two operations, wait and
release (originally called P and V by Dijkstra)
• Semaphores can be used to provide both
competition and cooperation synchronization
wait(aSemaphore)
if aSemaphore’s counter > 0 then
decrement aSemaphore’s counter
else
put the caller in aSemaphore’s queue
attempt to transfer control to a ready task
-- if the task ready queue is empty,
-- deadlock occurs
end
release(aSemaphore)
if aSemaphore’s queue is empty then
increment aSemaphore’s counter
else
put the calling task in the task ready queue
transfer control to a task from aSemaphore’s queue
end
• Ada, Java, C#
• The idea: encapsulate the shared data and
its operations to restrict access
• A monitor is an abstract data type for
shared data