Re: kernel_thread() & thread starting

Russell King (rmk@arm.linux.org.uk)
Sun, 18 Feb 2001 22:53:16 +0000 (GMT)


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.

--- 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/