This facility implements a semaphore with character string names.
SEMACC(0;PSB,M,SB==>c;SEMAC) - "Semaphore creator creator". This factory program creates a semaphore creator. Each semaphore creator will have a logically disjoint locking space.
SEMACC(kt==>24).
SEMAC(0==>c;SEMAPHORE) - "Semaphore creator". All semaphores created by the semaphore creator will share a single locking space.
SEMAC(kt+4==>0) - "Destroy" - Destroys all the semaphores and supporting domains created under this instance of SEMAC. N.B. Domains waiting on semaphores created by this domain will not be restarted by this call.
SEMAC(kt==>124).
SEMAPHORE(0,name==>0) - "lock". Returns when the resource represented by "name" can be accessed {corresponding to Dijkstra's "P" operation on binary semaphores}
SEMAPHORE(1,name==>0) - "unlock". Releases control of the resource represented by "name" {corresponding to Dijkstra's "V" operation}.
SEMAPHORE(3==>0) - "unlock all". Releases the locks on all names locked with this SEMAPHORE key.
SEMAPHORE(kt+4==>0) - "Destroy" - Destroys this instance of SEMAPHORE, releasing any resources locked under it.
SEMAPHORE(kt==>224).
If JOIN is a start key to a join object, any invocation of JOIN first waits until the join object is available, then:
JOIN(1;=>c,string;K,K,K,K) returns the message held by the object.
JOIN(kt;=>x'31')
JOIN(kt+4;=>0) deletes the object.
The first application is calling the compiler and becoming its co-routine mate to supply the compiler with input. A join object is made busy and the compiler is forked sending the join object's return key as the last key parameter. The caller is now running along with the compiler. When the compiler finishes it will return to the join object which will hold the return message until the caller picks the message up with the start key to the join object which it has kept.