site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=zTmWymTJg9bQ5kmasEpH1l/Am8DzZtCQS+6vFKpqFTk=; b=N8WuStk/stP/CDaDRuXBHaeYJ8qpS5O7A1ZVHZSBE5UcREMzuyQ0CcR+C8H0vEKVO4 Kqxitg1HDQJbBhCxNRSwbxQPKYj+iWiapD7BywxCPyL3fXvVit09iSRYeWljOl6whYBl 5aqJRQpM3MBa1qL7NQkt0KE7rzKLxWG7zgfB4= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; b=D77jv3tOKGpxtBk9vwj6VR6zJH9eoFe0ULxyuTUhDODKp4dCXubFbpM1tOhKuEIrUi QgGP7SgoValXhVMbE4RQGeeCxfCYOpfp3GYm6Skw7LrgrOoCFc84voywoyQG4Xyy8hU9 HSw0g5a9HNOAh7IOEFrIEgGliI0muIISGXlL8= Hey, Today, for some reason or another, I've been pondering how locks work. After locating the pthread source (in libc, available at opensource.apple.com, for those curious) I've found the source for the pthread_mutex_lock, in pthread_mutex.c It seems the meat of this function are the macros 'LOCK' and 'PLOCKSTAT_MUTEX_ACQUIRE'. The 'LOCK' macro is defined (indirectly) as _spin_lock. _spin_lock is implemented in various places based on the architecture you're compiling for; in my case I'm interested in i386. For that, _spin_lock is defined as: _OSSpinLockLock: _spin_lock: __spin_lock: movl $(_COMM_PAGE_SPINLOCK_LOCK), %eax jmpl *%eax .align 2, 0x90 .globl _OSSpinLockUnlock .globl _spin_unlock .globl __spin_unlock But I can't seem to find what _COMM_PAGE_SPINLOCK_LOCK is. I'm taking a shot in the dark that it's a function address in the kernel's address space. Is this correct? (I'm no assembly expert! :)) If so, where is the value for _COMM_PAGE_SPINLOCK_LOCK set? Secondly we have PLOCKSTAT_MUTEX_ACQUIRE. I can't seem to find where it's defined either, and it seems to be the real heavy-lifter for pthread_mutex_lock. Any ideas? Lastly and perhaps most important, is there a good low-level OS book that might explain the nitty gritty when it comes to locks and everything else deep under-the-hood? Thanks a lot! David _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Dave Keck