syl <[EMAIL PROTECTED]> writes:

> Hi everyone,
> 
> I'm not sure if I'm at the right place to ask this question, but I
> might aswell try; I'm writing you this mail because there is one thing
> I can't understand in the openbsd kthread.
> 
> Actually, it is those two functions from the kthread's man :
> kthread_create and kthread_create_deferred.. from man 9
> kthread_create creates a kernel thread and kthread_create_deferred
> adds a pointer to a function in a queue that will be then went through
> and each of it's elements will be launched in a seperate kthread.
> 
> I wrote a simple syscall using the lkm and kthread_create;
> Here is the syscall :
> 
> #include <sys/param.h>
> #include <sys/kthread.h>
> #include <sys/types.h>
> #include <sys/malloc.h>
> 
> #define NB_THREAD       1
> 
> void            theHook(void *data)
> {
>       uprintf("Goodbye threaded world\n");
>       kthread_exit(0);
> }
> 
> int             mycall(struct proc *p, void *uap, int retval[])
> {
>       int     error;
>       struct  proc *mypr;
> 
>       uprintf( "I create a new thread for fun :)\n" );
>       kthread_create(theHook, NULL, &mypr, "bite!");
>       return (0);
> }
> 
> But it would not work : The thread was not launched.

Erm. How do you know it didn't work?

You're definitely using uprintf incorrectly since the kthread will not
have any tty, therefore it won't know where to print stuff. So if you're
depending on uprintf to know what happened, it won't do what you think
it will.

uprintf should be used very carefully.

> I therefor replaced kthread_create by kthread_create_deferred and it
> looked like this :

kthread_create_deferred is not for you.

//art

Reply via email to