1 Part (a)
Resources
Resources.java
Thread Synchronisation/Semaphores
Operating Systems
Lab Class 6 – Model Solutions
1
GetTask.java
ReleaseTask.java
ResourceManager.java
7.
Extra question: The code that decrements available resources and the code that incre- ments available resources are the statements that could be involved in race condition. In part (a), we use Java monitors synchronized, wait and notify(All), while in part (b), we use Java Semaphore’s acquire and release.
In part (b), use a semaphore to represent the available resources variable and replace increment and decrement operations by semaphore increment (release) and semaphore decre- ment (acquire) operations.
Part (b)
2
ResourcesSemaphore
ResourcesSemaphore.java
GetTask.java
ReleaseTask.java
ResourceManager.java