Re: waitpid advice ? (killing off a kernel thread)

B. James Phillippe (bryan@terran.org)
Tue, 22 Jun 1999 20:55:30 -0700 (PDT)


On Sat, 19 Jun 1999, David Waite wrote:

> On Sat, 19 Jun 1999, B. James Phillippe wrote:
> > On Sat, 19 Jun 1999, David Waite wrote:
> >
> > > The problem is that the drivers have threads running that are not
> > > dying before I start deallocating resources.
> > ...
> > > Anyways, my question is.. obviously my method of killing and then
> > > waiting for the process to die is not working right. What can I do
> > > instead?

Hi David,

I've been looking at this closer and so far I haven't found a safe way of
doing it. The problem with waitpid/friends is that they are expected to be
called only for child processes. In our case, rmmod is not the parent of
the thread we want to kill.

I'm experimenting with a modification to add a new wait queue pointer in
task_struct, and then have sys_wait4 save the pointer and do a wake_up on
it after freeing the exiting thread. From cleanup_module (or wherever), we
can simply send a signal and then sleep on the thread's wait queue. This
way, it is the wait()'ing process that wakes the sleepers instead of the
exiting process itself. This should allow for waking only after the thread
is truly gone.

Does anyone know if a mechanism for doing this already exists?

cheers,
-bp

--
# bryan at terran dot org
# http://www.terran.org/~bryan

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