site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com User-agent: Thunderbird 1.5.0.8 (Macintosh/20061025) class foo : public IOService { ... public: IOReturn clientCommand(..); private: IOCommandGate *_commandGate; IOCommandGate::Action _commandAction; IOReturn _clientCommand(...); bool _busyFlag; ... }; foo::_clientCommand(...) { while (_busyFlag) _commandGate->commandSleep(&busyFlag, THREAD_UNINT); ... _busyFlag = false; _commandGate->commandWakeup(&busyFlag, true /* wakeup one only */); } = Mike _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... devmaillists wrote: we are to implement waiting queues for scheduling threads generated from a UserClient interface in our kext. As I learned from the documentation I should use wait_queue_alloc , wait_queue_free, wait_queue_member and so on to implement wait queues. Unfortunately I do not find the symbols in the 10.4 SDK only in 10.39 SDK but I think this is not an option for Intel based developments. What is the preferred way to do wait queues with 10.4 SDK. If by "wait queues" you mean that you want to queue incoming threads, then you should use a CommandGate with your workloop. Something like this: foo::start() { ... _commandGate = IOCommandGate::(this); getWorkLoop()->addEventSource(_commandGate); _commandAction = OSMemberFunctionCast(IOCommandGate::Action, this, &foo::_clientCommand); _busyFlag = false; ... } foo::clientCommand(...) { _commandGate->runAction(_commandAction, ...) } The busy flag acts as the semaphore indicating that there's a thread in the critical region. The workloop lock is used to provide concurrency protection against your interrupt thread, and making it possible to sleep waiting for that thread without having to deal with other threads coming into the critical region. Caching the result of OSMemberFunctionCast is advisable, as it is somewhat expensive. This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Smith