IOCommandGate commandSleep/commandWakeup
IOCommandGate commandSleep/commandWakeup
- Subject: IOCommandGate commandSleep/commandWakeup
- From: Eric Long <email@hidden>
- Date: Thu, 13 Dec 2007 11:23:19 -0800
- Thread-topic: IOCommandGate commandSleep/commandWakeup
Hi,
I'm encountering a problem where calling commandWakeup() on an IOCommandGate
is failing to wake up the sleeping thread.
This describes how I though things were supposed to work:
Some code calls: myCommandGate->runCommand(NULL, NULL, NULL, NULL);
The command gate runs its action:
IOReturn com_myCompany_driver::waitForMonkey( OSObject *owner, void*,
void*, void*, void* )
{
com_myCompany_driver *driver;
IOReturn kr = kIOReturnSuccess;
driver = OSDynamicCast( com_myCompany_driver, owner);
// Make sure that this driver type is the sender of the command.
SIGNAL_IF(driver == NULL);
if (driver)
{
driver->tellMonkeyToFling(); // calls messageClients
driver->isSleeping = true;
kr = driver->myCommandGate->commandSleep(&(driver->isSleeping),
THREAD_ABORTSAFE);
driver->isSleeping = false;
if (kr != THREAD_AWAKENED) {
DEBUG_LOG("commandSleep() returned error x!", kr);
}
else {
DEBUG_LOG("Driver %p resuming thread after sleep", driver);
}
}
}
Then when the monkey responds, wake the thread up:
void com_myCompany_driver::handleMonkeyResponse( bool inResponse )
{
monkeyResponse = inResponse;
myCommandGate->commandWakeup(&isSleeping, false);
DEBUG_LOG("Called commandWakeup for driver %p", this);
}
In the system log, I see the log messages I expect. It looks like
everything happened that should happen, except in some instances, the
sleeping thread never wakes up (and thus I never see the "Driver x resuming
thread after sleep" message, but I do see the "Called commandWakeup for
driver x" message. It's like commandWakeup did nothing.
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden