Last active
February 1, 2025 23:30
-
-
Save aerodame/9a8f79ca18609d9790099e3dfecab34e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "SimpleSemaphore.h" | |
| Semaphore::Semaphore(int initialValue) : S(initialValue) {} | |
| void Semaphore::P() { | |
| while (S <= 0) { | |
| // Busy wait (not ideal for real-world scenarios) | |
| } | |
| S--; | |
| } | |
| void Semaphore::V() { | |
| S++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment