IBM Mainframe Assembler List <[email protected]> wrote on 04/15/2011 03:45:16 PM:
> From: Andy Coburn <[email protected]> . . . > I believe you said that you did have multiple tasks adding to the queue and > one task removing them. This is how the problem can occur. . . . I don't know where I got the technique, but the best code for multiple requesters and single server that is bullet proof and very efficient is: There are three queues - a requestor que, a process que and a reuseable element que. assuming que elements have the first word of which is the ptr to the next que element, the requestors push elements to the top of the requestor que with a single CS. The elements are therefore in reverse order of processing. when the server wants to process elements and has no work on its que, it removes all elements from the requestor que and reorders them by reversing the pointers, so that the last element on the requestor que becomes the top element of the server que. the reordered que becomes its que. the server then processes the elements on its que from top down using a single CS to get each element. as elements are processed they are returned to the reuseable element que. this can be made to work for multiple servers but is messy as it requires locking. but the concept is the same. I would put sample code but am late for dinner date. as was said in graduate school, the proof is left to the student. this is I think easier than vector calculus or partial dif eq. ----------------------------------------- The information contained in this communication (including any attachments hereto) is confidential and is intended solely for the personal and confidential use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this communication in error and that any review, dissemination, copying, or unauthorized use of this information, or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. Thank you
