Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Locking in kernel across user space calls



At 1:46 PM -0400 5/15/07, Andrew Gallatin wrote:
Jim Wintermyre writes:
 > At 10:36 PM +0930 5/15/07, Michael Smith wrote:
 > >On May 15, 2007, at 5:48 PM, Jim Wintermyre wrote:
 > >
 > >>So my question is, is this safe?  Is there a better way to do this?
 > >>I have control over all the clients that will ever call this
 > >>function, so I can guarantee that any necessary cleanup will happen
 > >>(i.e. if the process crashes in Init while holding the lock that it
 > >>will release it etc.).
 > >
 > >It's really bogus.  Better to keep a state variable in the
 > >userclient instance and enforce per-client serialisation that way.
 >
 > OK, so suppose I keep a static in the userclient that the user
 > process can set when it needs to trigger serialization across
 > processes and multiple driver calls.  What do I call from the
 > userclient to block the user process thread until the flag is clear?

It is gross, but if you stick with your current model, the only other
alternative is building your own mutex/condvar, which seems "grosser
than gross" to take a term from my elementary school days :)

Can you re-design the protocol with your userclient, such that there
is a single call up front which allocates per-client state and further
calls simply setup that per-client state, so there is no need for
serialization across multiple calls?

Yes, probably, but that code is currently pretty "gross" too, so not easily at the moment. I was sure there was some obvious way to synchronize among multiple user processes across mulitple driver calls, that I didn't know about. Maybe not. Is there not some straightforward API to tell the user process (from the userclient) to just block/sleep until a flag is cleared, or an event is triggered, or something? I am guaranteed that this Init function in the user framework (the thing that needs the synchronization) will never be called from more than one thread in a given user process, if that helps. I assume that each call from different processes must by definition be on different threads.


Thanks,
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-drivers mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-drivers/email@hidden

This email sent to email@hidden
References: 
 >Locking in kernel across user space calls (From: Jim Wintermyre <email@hidden>)
 >Re: Locking in kernel across user space calls (From: Jim Wintermyre <email@hidden>)
 >Re: Locking in kernel across user space calls (From: Andrew Gallatin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.