lkml.org 
[lkml]   [2001]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kernel_thread() & thread starting
On Sun, Feb 18, 2001 at 10:53:16PM +0000, Russell King wrote:
> Kenn Humborg writes:
> > When starting bdflush and kupdated, bdflush_init() uses a semaphore to
> > make sure that the threads have run before continuing. Shouldn't
> > start_context_thread() do something similar?
> I think this would be a good idea. Here is a patch to try. Please report
> back if it works so that it can be forwarded to Linus. Thanks.

Works perfectly for me.

I'll leave it up to you guys to decide what's the right way to deal with
this and pass a patch to Linus/Alan. Meanwhile, I'll keep Russell's
patch below in our CVS tree.

Thanks,
Kenn

> --- orig/kernel/context.c Tue Jan 30 13:31:11 2001
> +++ linux/kernel/context.c Sun Feb 18 22:51:56 2001
> @@ -63,7 +63,7 @@
> return ret;
> }
>
> -static int context_thread(void *dummy)
> +static int context_thread(void *sem)
> {
> struct task_struct *curtask = current;
> DECLARE_WAITQUEUE(wait, curtask);
> @@ -79,6 +79,8 @@
> recalc_sigpending(curtask);
> spin_unlock_irq(&curtask->sigmask_lock);
>
> + up((struct semaphore *)sem);
> +
> /* Install a handler so SIGCLD is delivered */
> sa.sa.sa_handler = SIG_IGN;
> sa.sa.sa_flags = 0;
> @@ -148,7 +150,9 @@
>
> int start_context_thread(void)
> {
> - kernel_thread(context_thread, NULL, CLONE_FS | CLONE_FILES);
> + DECLARE_MUTEX_LOCKED(sem);
> + kernel_thread(context_thread, &sem, CLONE_FS | CLONE_FILES);
> + down(&sem);
> return 0;
> }
>
>
>
> --
> Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
> http://www.arm.linux.org.uk/personal/aboutme.html
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:17    [from the cache]
©2003-2011 Jasper Spaans