Metered concurrency: Difference between revisions
Content deleted Content added
m →[[Java]]: Use Java header instead |
m Switch to header template |
||
Line 3:
The goal of this task is to create a [http://en.wikipedia.org/wiki/Counting_semaphore counting semaphore] used to control the execution of a set of concurrent units. This task intends to demonstrate coordination of active concurrent units through the use of a passive concurrent unit. The operations for a counting semaphore are ''acquire'', ''release'', and ''count''. Each active concurrent unit should attempt to acquire the counting semaphore before executing its assigned duties. In this case the active concurrent unit should report that it has acquired the semaphore. It should sleep for 2 seconds and then release the semaphore.
==
'''Compiler: GNAT''' GPL 2006
Line 97 ⟶ 96:
end Semaphores_Main;
==
This semaphore slightly differs from the task description; the release operation is not on the semaphore itself but given out with each acquisition, and cannot be invoked too many times.
Line 218 ⟶ 215:
}
==
See [http://search.cpan.org/dist/Coro/Coro/Semaphore.pm Coro::Semaphore].
==
Python threading module includes a semaphore implementation. This code show how to use it.
Line 267 ⟶ 261:
</pre>
==
Counting semaphores are built in:
|