I have a process P and a kernel thread KT. I want to synchronize execution of P with KT. KT is basically an event handler. But my requirement is that KT should not go ahead processing events if P is running. So I need to pause P and then go ahead with event processing in KT and resume P. So my question is, from KT, how do I force preempt P ? For resuming later, I can just use wake_up_process().
For scheduling out a process, commonly used trick is to set the state as TASK_INTERRUPTIBLE and call schedule(). Would it work if I have task_struct pointer of P saved, then from KT, to schedule out P, I set state of P(instead of current) as TASK_INTERRUPTIBLE and call schedule ? It is a hack, would it work ? Do you see any clean way that I am missing ?
Is there some signal I can send P to ask it to preempt ?