A semaphore s is an integer variable which can take only non-negative values. Once it has been given its initial value, the only permissible operations on s are the atomic actions:
(a) Using the skeleton below, give a definition of a Java class
GeneralSemaphore
that implements a general semaphore. The
class should have two methods P()
and V()
that implement the corresponding semaphore operations.
class GeneralSemaphore { private long resource; public GeneralSemaphore (long r) { resource = r; } // method to implement the P operation // method to implement the V operation }
This file is maintained by Brian Logan Last modified: 12-Mar-2014, 13:54