At 17:29 +1000 12/5/03, Wally Crooze wrote: Note. I am writing a filesystem... so I can't avoid using BSD headers. If you're working within the BSD portions of the kernel, your code should rely on the kernel funnels as its primary synchronisation mechanism. Kernel funnels are described in DTS Technote 2028 "Threading Architectures". <http://developer.apple.com/technotes/tn/tn2028.html#MacOSXKernelThreading> Any code running under a funnel is automatically single threaded. Thus, there's no need for locking for simple operations, like global += 1. However, locking does come into play if your code blocks. When you block you automatically release the funnel you're holding, and other code might run and modify state that you care about. You have to make sure that any state you depend on is preserved across blocking. Given that you're working on a file system, the primary locking mechanism you should use is the vnode locking mechanism (vn_lock--which calls VOP_LOCK--and VOP_UNLOCK). If you need to lock something other than vnodes, you would typically use the BSD locks provided by <sys/lock.h>. Remember that vnode locks must be taken in the correct order (from root to leaf) in order to avoid deadlocks. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Technical Support * Networking, Communications, Hardware _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.