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=domainkey-signature:received:received:from:to:cc:references:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:thread-index:x-mimeole; bh=MetaqInJoQ51s9N2CXBhkAR6LHR6j7i+FOJHN4f9u3c=; b=oH8F3r05rXXnsofz9pHyIhU7dF8ooadxgLNhWPVRBltKf9cYJedSycbEHVrcCMWf93NSfEQz9FCzwRXSYXAPElW58mfAUmmbvffM+uK7v//Wc7jn3u+IlZ3ecL9/kGdHAajCg8mr33FzA1M+yK3sjWjA7q76oUh/tNsVc4I5VsM= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:references:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:thread-index:x-mimeole; b=l2lM+/Z6Y7Z2dYH2irQVMCpHC2zj+fuIKAyLCLzVD27Fp4StQ+E2XbLIy3Ykr0AjPu2EvUj0c3B7gfbQIznp6g51A0uOBbFLSRu16rAY5vifdv0lv8b86rK6ugFMEEhaxp74kk69kZkwcI1Sw2VUjlJp08HsJV9KgC/9xLcideE= Thread-index: AchUchEa4kw+5ok2SxSUkO4R10r0pwAACPkg Hi Mike, Thanks for your comments. Actually, I'm in bug-fixing phase and changes in the code would require thorough testing. I would be doing some changes as per suggestions in this thread. But still if you could clarify a few things - - Is there any specific reason that I see panic only on iMac(10.4.8) and not on MacPro(10.4.9) or MacMini(10.4.7)? - what are the consequences of sleeping while holding a lock? ________________________________ Thanks - vishal shetye -----Original Message----- From: Michael Smith [mailto:drivers@mu.org] Sent: Friday, January 11, 2008 10:20 PM To: Vishal Shetye Cc: darwin-kernel@lists.apple.com Subject: Re: Panic in OSMalloc?? On Jan 10, 2008, at 11:15 PM, Vishal Shetye wrote:
Could you please explain what are the consequences of calling OSMalloc with some spin lock held. I'm using lck_spin_lock() to lock a global variable before OSMalloc and release it once the item allocated has been added to a queue.
Why would you do this? Firstly - spinlocks are a low-level primitive; they are not generally suitable for use in high-level code. At the level you are working, you should almost never need a spinlock - use a proper mutex if you must, but strive whenever possible to design your code so that you don't need locking in the first place. Secondly; why are you locking the global and then blocking? You should be using a try/backout scheme to avoid holding the lock while you sleep: LOCK flag = condition UNLOCK if (flag) thing = allocate() LOCK if (!condition) do_free = true else do_free = false queue_enter(thing) endif UNLOCK if (do_free) free(thing) endif endif = 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... This email sent to site_archiver@lists.apple.com