Re: IOMalloc / IOFree while holding a mutex
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=a+gPu/fttUButxJAxRhKmvo3INVLZgNRioJKHTF6JI4=; b=BrD1qyNIwyAE0fbDJoCZAhry/Ws1H3sok/PrOy3eNk4D0R2tvizqSq5dDu9nVa6E6m JVfURvetLXfO1ZaMmlOHlIlmkJzcQJ2JDT5cbC0Skaow8HmWUrsMc+Cyvz8LGHQFj+6j 7k4Oe1ykwkWee4ExczBEz3If5FEpG+yqZhFAQ=
On Wed, 16 Nov 2011 11:09:07 +0530 (IST) sheetal phirke <sheetal_phirke06@yahoo.co.in> wrote:
Can I call IOMalloc / IOFree while holding mutex lock?
yes.
I expect that the reason you can do that is that attempting to acquire a mutex lock can block. Spinlocks are much faster than mutexes because they never block. You never have to worry about context switch time. But if you are blocked when some other thread tries to acquire the same spinlock that you are holding, it might hold that spinlock for a very long time, until your call to IOMalloc or IOFree returns. Because spinlocks just waste CPU cycles until the spinlock object is acquired, doing this will waste CPU resources in a dramatic way. It will also slow everything else down in the system, even if not CPU-bound, because all the tasks that depend on spinlock acquisition are designed with the assumption that it never takes very long to acquire one. -- Michael David Crawford mdcrawford at gmail dot com Custom Software Development for the iPhone and Mac OS X http://www.dulcineatech.com/custom-software-development/ _______________________________________________ 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... This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Crawford