Hardware Reference
In-Depth Information
7
RESOURCE ACCESS PROTOCOLS
7.1 INTRODUCTION
A
resource
is any software structure that can be used by a process to advance its
execution. Typically, a resource can be a data structure, a set of variables, a main
memory area, a file, or a set of registers of a peripheral device. A resource dedicated
to a particular process is said to be
private
, whereas a resource that can be used by
more tasks is called a
shared resource
. A shared resource protected against concurrent
accesses is called an
exclusive resource
.
To ensure consistency of the data structures in exclusive resources, any concurrent op-
erating system should use appropriate resource access protocols to guarantee a mutual
exclusion among competing tasks. A piece of code executed under mutual exclusion
constraints is called a
critical section
.
Any task that needs to enter a critical section must wait until no other task is holding
the resource. A task waiting for an exclusive resource is said to be
blocked
on that
resource, otherwise it proceeds by entering the critical section and holds the resource.
When a task leaves a critical section, the resource associated with the critical section
becomes
free
, and it can be allocated to another waiting task, if any.
Operating systems typically provide a general synchronization tool, called a
semaphore
[Dij68, BH73, PS85], that can be used by tasks to build critical sections. A semaphore
is a kernel data structure that, apart from initialization, can be accessed only through
two kernel primitives, usually called
wait
and
signal
. When using this tool, each ex-
clusive resource
R
k
must be protected by a different semaphore
S
k
and each critical
section operating on a resource
R
k
must begin with a
wait
(
S
k
) primitive and end with
a
signal
(
S
k
) primitive.
Search WWH ::
Custom Search