• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: waiting queue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: waiting queue


  • Subject: Re: waiting queue
  • From: Michael Smith <email@hidden>
  • Date: Thu, 16 Nov 2006 10:12:07 -0800

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:



class foo : public IOService { ... public: IOReturn clientCommand(..);

private:
   IOCommandGate           *_commandGate;
   IOCommandGate::Action   _commandAction;
   IOReturn                _clientCommand(...);
   bool                    _busyFlag;
...
};


foo::start()
{
...
_commandGate = IOCommandGate::(this);
getWorkLoop()->addEventSource(_commandGate);
_commandAction = OSMemberFunctionCast(IOCommandGate::Action, this, &foo::_clientCommand);
_busyFlag = false;
...
}


foo::clientCommand(...)
{
_commandGate->runAction(_commandAction, ...) }


foo::_clientCommand(...)
{
   while (_busyFlag)
      _commandGate->commandSleep(&busyFlag, THREAD_UNINT);

   ...

   _busyFlag = false;
   _commandGate->commandWakeup(&busyFlag, true /* wakeup one only */);
}

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.

= Mike



_______________________________________________
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


  • Follow-Ups:
    • Re: waiting queue
      • From: devmaillists <email@hidden>
References: 
 >waiting queue (From: devmaillists <email@hidden>)

  • Prev by Date: waiting queue
  • Next by Date: Call function on all processors
  • Previous by thread: waiting queue
  • Next by thread: Re: waiting queue
  • Index(es):
    • Date
    • Thread