.
/* remainder section */
. . .
This code says:
While the variable key is true, swap the values of key and lock.
(When key becomes false, it will mean that lock was false,
and because key was true before, lock will now be true.)
When key becomes false, execute the critical section.
When the critical section is complete, release the lock by setting it back to false.
The swap instruction has the same applications and limitations as the test-and-set.
SEMAPHORES
In 1965 one of the most prolific contributors to computer science proposed the construct of a ???semaphore???
which could be used to provide mutual exclusion and to avoid the requirement for busy waiting. Edgar Dijkstra
proposed that the operating system execute a short series of instructions atomically to provide such a service.
The operating system can execute several instructions atomically, because the operating system can turn the
interrupt system off while the code for a semaphore is being executed.
Basically, the semaphore is a short section of code that operates on an integer variable. A semaphore offers
two operations. Dijkstra (from the Netherlands) called these operations ???proberen??? (P, or test) and ???verhogen???
(V, or increment).
Pages:
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290