Try https://www.geeksforgeeks.org/semaphores-in-process-synchronization/
This may help
https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/5_Synchronization.html