On Sun, 6 May 2012 15:26:33 -0700, Charles Mills wrote: > >I have z/OS tasks of all stripes driving a z/OS system exit. I have a finite >supply of a resource that each task needs in the exit. Sometimes the >resources are exhausted and will not be replenished for a while. What if we >come through the exit and are out of the resources? It would be nice if all >of the tasks in such a situation could wait until the resource was >replenished, without each task having to do a GETMAIN or CPOOL GET, chaining >it to the previous (not a trivial thing in a totally asynchronous multi-CPU >situation), WAITing, and then unchaining the block and freeing it. It might >be nice if there were a single control block on which all of the tasks could >(effectively) "wait." > The conventional solution to this problem is the semaphore:
http://en.wikipedia.org/wiki/Semaphore_%28programming%29 I don't know that classic z/OS provides semaphores; others will surely know better than I. In a z/OS UNIX (USS) shell script I've done something using a POSIX FIFO. Initially, an executive writes one token to the FIFO for each unit resource to be used. Then it enters a loop reading tokens from the FIFO. If no token is available, it blocks. When it successfully reads a token, it forks a child to perform a chore. When a child completes a chore, it returns a token to the FIFO. I suspect my situation differs from yours in that the executive manages the queue of chores; the forked children are not autonomous as you describe your tasks. -- gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN