linux - How to preempt one process from another process/kernel thread? -
i have process p , kernel thread kt. want synchronize execution of p kt. kt event handler. requirement kt should not go ahead processing events if p running. need pause p , go ahead event processing in kt , resume p. question is, kt, how force preempt p ? resuming later, can use wake_up_process().
for scheduling out process, commonly used trick set state task_interruptible , call schedule(). work if have task_struct pointer of p saved, kt, schedule out p, set state of p(instead of current) task_interruptible , call schedule ? hack, work ? see clean way missing ?
is there signal can send p ask preempt ?
you cannot asking. sure set state task_interruptible process/thread running on same or on different cpu/core. can't invoke schedule() on cpu/core (for same reason can't invoke other function on cpu/core). consider schedule() not take cpu/core id argument how tell core1 should reschedule?
another popular solution these types of synchronization requirements use real-time priorities. ugly proposed can work if have kernel supports real-time priorities. idea here simple, process p has higher priority kt , preempt kt when ready run. use cpu affinity force both processes onto same cpu/core (this important, won't work otherwise!). btw, there isn't real synchronization in approach -- strictly relying on rt priorities enforce when p , kt run respect 1 another.
i suggest take advice of damon , re-design since there no real clean way ask there many clean ways synchronize 2 processes.
Comments
Post a Comment