site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 I'm trying to understand IOCommandGate, if that is the function that I want to use for my task. I need to serialize various requests to prevent them from interleaving. Some of the requests may take a long time to complete. In the example at <http://developer.apple.com/documentation/ DeviceDrivers/Conceptual/IOKitFundamentals/HandlingEvents/ chapter_8_section_3.html>, I see how enqueuing the requests might work, but what I am not sure of is how dequeuing would work. Clearly IOCommandGate works as a semaphore for multiple producers to a target. However, how does one also have protected access to dequeue the request? It seems that CheckRequestQueue() still has to process the queue item in another thread otherwise the gate thread would be blocked, or is that the point? I'm also wondering how the queue is emptied when there are no more requests coming in to keep it going? I think I'm missing something fundamental. Thanks for your insight, ...Duane ps For those wishing to play at home, this is the code I am referring to. void ApplePMU::enqueueCommand ( PMUrequest * request ) { commandGate->runCommand(request); } void receiveMsg ( OSObject * theDriver, void * newRequest, void *, void *, void * ) { ApplePMU * PMUdriver = (ApplePMU *) theDriver; PMUrequest * theRequest = (PMUrequest*)newRequest; // Inserts the request in the queue: theRequest->prev = PMUdriver->queueTail; theRequest->next = NULL; if ( PMUdriver->queueTail != NULL ) { PMUdriver->queueTail->next = theRequest; } else { PMUdriver->queueHead = theRequest; } PMUdriver->queueTail = theRequest; // If we can, we process the next request in the queue: if ( (PMUdriver->PGE_ISR_state == kPMUidle) && !PMUdriver->adb_reading) { PMUdriver->CheckRequestQueue(); } } -----BEGIN PGP SIGNATURE----- Version: PGP Desktop 9.6.3 (Build 3017) Charset: US-ASCII wsBVAwUBR0JRLErg9acQ4r2CAQhzJggAuOLBksvmaEsmgIsxlL9PUbGkRepQpTvY Uxy7PevOwH91/rid1PaK22ktEZ38vNMnm/B3b/7GOBAW/oH1/en+VnpzaL5uz+ga fh+BwqW4vzJdGEVtiUjCMpKjA8wleYiPCpemeuPG8tYfai/jQQrUhueSMUAmfEIc cWF/hm82B5kM2/QB4lZg7Q+g+7xftL6yBKLPfEGX7cq1Zmc4Cpv5wn2hrSrY5CwA n9WM17cmVNtoPVLDuRUI35aRGJnKf5P2DNOv+aWWf5iV/Gn/+iZdfyMJlrZN3mPn aUREfUaKSbG0FzQl8DIAAna6NUhbzivL1JKh3FRH0aa46JeLrAvxvA== =erje -----END PGP SIGNATURE----- _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com