3 semacquire, semrelease \- user level semaphores
10 int semacquire(long *addr, int block);
13 long semrelease(long *addr, long count);
18 facilitate scheduling between processes sharing memory.
19 Processes arrange to share memory by using
30 The semaphore's value is the integer pointed at by
33 atomically waits until the semaphore has a positive value
34 and then decrements that value.
35 It returns 1 if the semaphore was acquired and \-1 on error
36 (e.g., if it was interrupted).
40 and the semaphore is not immediately available,
42 returns 0 instead of waiting.
46 to the semaphore's value
47 and returns the new value.
52 can be thought of as efficient, correct replacements for:
56 semacquire(long *addr, int block)
69 semrelease(long *addr, int count)
71 return *addr += count;
80 are not typically used directly.
81 Instead, they are intended to be used to coordinate
82 scheduling in higher-level abstractions such as
83 locks, rendezvous points, and channels
93 cannot be used to coordinate between threads
95 Use locks, rendezvous points, or channels instead.
97 .B /sys/src/9/port/sysproc.c