Re: Help with char device

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

 



On Sat, 27 Jul 2002 16:52:00 -0300 (BRT)
Rik van Riel <riel@conectiva.com.br> wrote:

RVR> On Sat, 27 Jul 2002, Tom Bradley wrote:
RVR> 
RVR> > ssize_t my_read(struct file * filp, char * buf, size_t count,
RVR> > loff_t * fpos){
RVR> >
RVR> > 	ssize_t ret;
RVR> > 	struct semaphore sem;
RVR> 
RVR> Note that I'm not familiar with the semaphore code, so I could be
RVR> wrong ... but won't this effectively give each thread going into
RVR> this code its OWN semaphore on its own stack ?

	Indeed.

	Tom: As Rik said, in your code each thread has it's own semaphore....so
you'll never have mutual exclusion (with this code). Your threads should
_share_ a "struct semaphore" (correctly initialized [e.g. init_MUTEX],
BTW) so access serialization can be done.

Felipe
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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