linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bizarre multithread open/close problem
@ 2001-07-30 21:09 isnkrnl
  2001-07-30 22:46 ` Ignacio Vazquez-Abrams
  0 siblings, 1 reply; 2+ messages in thread
From: isnkrnl @ 2001-07-30 21:09 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: Text/plain, Size: 1211 bytes --]

I'm not sure if this is a bug or not but my
coworker has a wierd one.

He has 2 threads, main and helper.

main:
f=open(/dev/brcmrec) does some work and then 

spawns helper:

helper spins forever doing various ioctls, read
and writes on f which was opened in main. Every
time through it looks at a "amIDone" flag which is
set by main.  pthreads are the threads.

Then at some point main wants to end helper and
close f.  Main sets "amIDone" which tells helper
to terminate and then successfully closes f.  

Now here is the problem, our brcmrec driver has a
close() function which isn't getting called when
main does the close, at least not all of the
time.  	  
We're beginning to think that if the helper thread
is in the middle of an ioctl or something then the
close works but it doesn't call the close on the
driver.  


I don't even know what kind of help to ask for
here, so feel free to poke at this any ways you
like.  I guess the bothersome part is that we have
a thread that doesn an open (did I mention it was
an exclusive open?) and then spawns a thread and
then does a close and we can't reopen the device
and the close part of our driver is never called.

Any ideas or hints?

thanks,
Ian Nelson

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bizarre multithread open/close problem
  2001-07-30 21:09 Bizarre multithread open/close problem isnkrnl
@ 2001-07-30 22:46 ` Ignacio Vazquez-Abrams
  0 siblings, 0 replies; 2+ messages in thread
From: Ignacio Vazquez-Abrams @ 2001-07-30 22:46 UTC (permalink / raw)
  To: linux-kernel

On Mon, 30 Jul 2001 isnkrnl@attglobal.net wrote:

> I'm not sure if this is a bug or not but my
> coworker has a wierd one.
>
> He has 2 threads, main and helper.
>
> main:
> f=open(/dev/brcmrec) does some work and then
>
> spawns helper:
>
> helper spins forever doing various ioctls, read
> and writes on f which was opened in main. Every
> time through it looks at a "amIDone" flag which is
> set by main.  pthreads are the threads.
>
> Then at some point main wants to end helper and
> close f.  Main sets "amIDone" which tells helper
> to terminate and then successfully closes f.
>
> Now here is the problem, our brcmrec driver has a
> close() function which isn't getting called when
> main does the close, at least not all of the
> time.
> We're beginning to think that if the helper thread
> is in the middle of an ioctl or something then the
> close works but it doesn't call the close on the
> driver.
>
>
> I don't even know what kind of help to ask for
> here, so feel free to poke at this any ways you
> like.  I guess the bothersome part is that we have
> a thread that doesn an open (did I mention it was
> an exclusive open?) and then spawns a thread and
> then does a close and we can't reopen the device
> and the close part of our driver is never called.
>
> Any ideas or hints?
>
> thanks,
> Ian Nelson

What if you use a semaphore to prevent the parent from close()ing it until the
child is done?

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-30 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-30 21:09 Bizarre multithread open/close problem isnkrnl
2001-07-30 22:46 ` Ignacio Vazquez-Abrams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).