Re: Should getWorkLoop be thread-safe?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Godfrey On 04/08/2006, at 12:10 AM, Howard Gayle wrote: return arSetWorkLoop; } Is there a race condition where two different threads could call getWorkLoop(), resulting in the unwanted creation of two different IOWorkLoop objects? _______________________________________________ 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/gvdl%40mac.com _______________________________________________ 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 function tends to get called at driver start time. start() is guaranteed to be single threaded so there isn't really a threading issue. Apple's "I/O Kit Fundamentals" guide http://developer.apple.com/documentation/DeviceDrivers/Conceptual/ IOKitFundamentals/index.html has an example under Handling Events > Work Loops > Listing 7-1 of overriding getWorkLoop(). The example tries to make getWorkLoop() thread-safe. I have some concerns about the example code, but does getWorkLoop() really need to be thread-safe? I couldn't find any real code that worries about this. The code in AppleRAIDSet.cpp in AppleRAID is pretty typical: IOWorkLoop * AppleRAIDSet::getWorkLoop(void) { // Create a WorkLoop if it has not already been done. if (arSetWorkLoop == 0) { arSetWorkLoop = IOWorkLoop::workLoop(); } This email sent to gvdl@mac.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Godfrey van der Linden