Re: IOMalloc / IOFree while holding a mutex
Re: IOMalloc / IOFree while holding a mutex
- Subject: Re: IOMalloc / IOFree while holding a mutex
- From: Michael Smith <email@hidden>
- Date: Mon, 21 Nov 2011 12:17:25 -0800
Sheetal,
If you have to ask, the answer is almost certainly "no".
= Mike
On Nov 20, 2011, at 10:03 PM, sheetal phirke wrote:
Hi,
First of all I would like to thank everyone to share valuable information.
I am writing IOKit driver with Vnode & File listener.
Is it safe for me to take mutex lock while IOMalloc / IOFree?
Thanks & Regards,
Sheetal.
From: Shantonu Sen <email@hidden> To: sheetal phirke <email@hidden> Cc: email@hidden Sent: Wednesday, 16 November 2011 11:05 PM Subject: Re: IOMalloc / IOFree while holding a mutex There's some layers of sublety here. You can do a lot of things at a technical level. Certainly there are no assertions or consistency checks that prevent you from holding an IOLock/lck_mtx_t. However if
you are writing a storage driver that is on the paging path, consider what happens if you take the lock (or run under a command gate), attempt the IOMalloc, which in turn needs to free up pages by paging out user data, which issues an I/O, which tries to acquire the mutex previously acquired? You can try to massage the code to accept an asyncReadWrite() without taking any locks, so you don't end up deadlocking, but it requires some thought. This is one of the reasons why memory allocations on the I/O path is frowned upon. Shantonu Sen email@hiddenOn Nov 16, 2011, at 6:17 AM, chas williams - CONTRACTOR wrote: > On Wed, 16 Nov 2011 11:09:07 +0530 (IST) > sheetal phirke < email@hidden> wrote: > >> Can I call
-- The lyf so short, the craft so long to lerne -- Chaucer
|
_______________________________________________
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