Hi, Is it necessary for me to make the kernel thread sleep in TASK_INTERRUPTIBLE state? If I don't do it, doesn't the task gets scheduled (I know kernel threads are not preemptive). My sample code is as mentioned below 1. kernel thread is created by calling kernel_thread(launch thread function, it's arguments, 0) 2. launch_thread_func() will actually call the function which executes as a thread like launch_thread_func() { kernel thread initiailization things... .... call thread_func() here... } void thread_func(void *) { .... } Now my question is, if I have to check for the signal asynchronously it would be difficult as thread_func() could be a infinite loop. If I have to check for the signals in current->signal or current->blocked then it wouldn't give a totally asynchronous way of checking the signals. This method is sort of polling, if i'm not wrong. Doesn't the kernel provide any routine which lies in kernel and which works like sigaction() - without the need to change from user context to kernel context and vice versa. thanks, venu ----- Original Message ----- From: "Jan Hudec" <bulb@ucw.cz> To: <kernelnewbies@nl.linux.org> Sent: Thursday, May 30, 2002 10:59 AM Subject: Re: how to add signal handler to kernel thread? > On Thu, May 30, 2002 at 11:55:52AM +0100, venugopal panchamukhi wrote: > > Hi, > > Could anyone let me know the procedure to add a signal handler for a kernel thread which is created using kernel_thread(). > > AFAIK signals are delivered only on exit from kernel mode (which happens > either at the end of a syscall or after interrupt (which may have caused > the signal), scheduling being a special case of this. Since kernel > thread never leaves a kernel mode, the code to run signal handlers is > never executed. You have to check for current->signals every time you > wake up and if there is a signal, handle it. You will find all relevant > data about the signal somewhere in current. Of course you want to make > sure you sleep in TASK_INTPERRUPTIBLE state so you get scheduled when > signal arrives. > > -------------------------------------------------------------------------- ------ > - Jan Hudec `Bulb' <bulb@ucw.cz> > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/