Re: Bizarre multithread open/close problem

Ignacio Vazquez-Abrams (ignacio@openservices.net)
Mon, 30 Jul 2001 18:46:11 -0400 (EDT)


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>

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/