Concurrency Mechanism
Concurrency Mechanism
MECHANISM
Presented by,
LINA KASIM
S5 BCA
Definition
Two or more segments of a program can be
executing concurrently if the effect of executing the
segments is independent of the order in which they
are executed. We refer to these program segments as
tasks or processes. On multiple-processor machines,
independent code segments can be executed
simultaneously to achieve increased processing
efficiency. On a single-processor machine, the
execution of independent code segments can be
interleaved to achieve processing efficiency: One
task may be able to execute while another is waiting
for an external event to occur or waiting for
completion of an I/O operation.
2
FUNDAMENTAL PROBLEMS
Asynchronous
FUNDAMENT message
AL passing
APPROACHES
Synchronous
message
passing
SHARED
VARIABLE
APPROCH
In the shared variable approach to concurrency, multiple
processes have access to a common region of memory. The
simplest form of shared variable communication is the
"test and set" approach. When two tasks are to
synchronize, the first task to reach its synchronization
point will test and then set a shared memory cell to indicate
that it is waiting for the second task. When the second task
reaches its synchronization point, it tests the shared cell
and determines that the first task is waiting. Having
synchronized, the two tasks can exchange information,
reset the shared memory cell, and proceed concurrently
until the next synchronization point is reached. Test and set
also can be used to prevent one task from accessing shared
data while another task is updating that data.
ASYNCHRONOUS MESSAGE-
PASSING APPROACH