![]() |
![]() |
|
02158 Concurrent Programming Fall 2024 |
Mini Lab 3: Critical Region with Semaphores |
Home | Plan | Material |
To use semaphores to protect shared variables.
Read about semaphores in [Andrews], chapter 4.
The synchronization problem from Mini Lab 2 is now to be solved using semaphores.
Semaphore(int s0) // Constructor (sets the initial value, s0>=0)
void P()
void V()
[The Semaphore class should be use as is. The operation P() may throw an InterruptedException. This should just be caught and ignored. ]
Run the program again and find:
Enjoy!
Hans Henrik Løvengreen, Oct 2, 2024 |