Re: adding semaphores to my device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 14, 2010 at 10:43 PM, Bond <jamesbond.2k.g@xxxxxxxxx> wrote:
>
>
> On Tue, Sep 14, 2010 at 10:31 PM, Greg Freemyer <greg.freemyer@xxxxxxxxx>
> 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 ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux