PDA

View Full Version : waking kernel threads



akshata
September 28th, 2008, 03:42 PM
Hi,
Im a novice to kernel programming and needed some help

I have wriiten a simple program to create kernel threads.

init_module()
{
struct task_struct *k;
k=kthread_create(mythread,data,"thread 1");
}

static int mythread(void * data)
{
..................
}

When i do insmod the thread iss created by mythread is not called. Should i wake up the thread? how do i do it?
How do i put it to sleep again? Do i ahev to use some semaphores for this?

Thanks

the_unforgiven
September 28th, 2008, 05:20 PM
Hi,
Im a novice to kernel programming and needed some help

I have wriiten a simple program to create kernel threads.

init_module()
{
struct task_struct *k;
k=kthread_create(mythread,data,"thread 1");
}

static int mythread(void * data)
{
..................
}

When i do insmod the thread iss created by mythread is not called. Should i wake up the thread? how do i do it?
How do i put it to sleep again? Do i ahev to use some semaphores for this?

Thanks
Check this:
http://lwn.net/Articles/65178/

Essentially, you need to do wake_up_process() on the return value of kthread_create().

In normal cases, this will be done asynchronously by the kernel when the event on which the thread is waiting is triggered (say, via interrupt service routine, workqueue or tasklet).