On Tue, Sep 14, 2010 at 10:43 PM, Bond <[email protected]> wrote:
>
>
> On Tue, Sep 14, 2010 at 10:31 PM, Greg Freemyer <[email protected]>
> wrote:
>>
>> I think a mutex will do what you need.
>> Have you looked at:   Documentation/mutex-design.txt
>>
>> You should find the Documentation folder at the top level of your
>> kernel source tree.
>>
>> The mutex calls are at the bottom of the file.
>>
> Ok.
>>
>> Look around at the kernel source for some example uses.  Especially
>> where to call mutex_init().  You obviously don't want to call that in
>> your write() routine.
>>
> Why not in write routine?
> I discussed this thing with a friend he suggested to implement this in write
> routine() .

mutex_init() is a way to dynamically _create_ a mutex.

I'm sure you can do that in the write routine, but it seems much more
natural to create your control mutex in the open routine since it is
effectively a one time action.

fyi:  your driver may be so simple you don't need to create the mutex
dynamically.

See LLD3 chapter 5 for more:
http://lwn.net/images/pdf/LDD3/ch05.pdf

Greg

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to