Counting semaphore

Creator
Creator
Seonglae Cho
Created
Created
2023 Nov 13 7:15
Editor
Edited
Edited
2023 Dec 20 4:55
Refs
Refs

Usual semaphore reference

협의의 세파포어
  • S - Integer counter
  • P - decrement function - before critical section - wait(S)
  • V - increment function - after critical section -signal(S)
    • two function should satisfy atomicity - other process cannot change while this function
When shared resource is more than one for preventing
Race Condition
Mutex semaphore 인데 공유 자원이 여러개
Semaphore prevent multi-process access to data which are File type integer counter and unlocked by other. supervise many resources
notion image
P(S) { S--; if S < 0 // sleep this process } V(S) { S++; if S <= 0 // remove from sleep queue
 

S

  • default value is resources number
  • 0 : block
 
 
 
 
 

Recommendations