Job Jar. An important use of an unordered queue is as a job jar. The memos in the job jar indicate tasks to perform. Whenever a process requires more work to do, it pulls a memo out of the job jar. Whenever a process creates more work to do, it drops memos in the job jar. It is often convenient to have one job jar for each process and one common jar for all. The individual job jars are used for operations that must be performed by a particular process, e.g. file I/O - a file is typically open in only one particular process. Memo_alt can be used to get a memo from either the local job jar or the common one.
Job jar with termination detection. A danger with a job jar is that all processes may try to fetch another job out of an empty jar and deadlock. Therefor it is desirable that this condition be detected before the last process waits. Here we give an algorithm to detect termination of a job jar algorithm.
As with multiple readers and writers, we use an extra folder with a status memo in it. The status memo has two fields, (np, ng), which record the number of jobs put into the job jar and the number of attempts to get a job from the job jar, respectively. If nprocs is the number of processes, then the algorithm has terminated when ng=np+nprocs. Here are the algorithms for depositing a job into the job jar and removing a job. When the job jar algorithm has terminated, all processes will remove a terminate memo from the jar.
Deposit job |
Fetch job |
| get status memo from job
jar status folder add one to np replace it put job memo in job jar |
get status memo from job
jar status folder add one to ng if ng=np+nprocs
replace the status memo get a job memo from the job jar |
This page last updated 09/30/97