I want to implement a IPC in linux kernel. The idea is that:
a producer process can write to a physical page
a consumer process only can read this page
a consumer process can't read this page until producer process fix this page (e.g. set the page to
FIXSTATE)
My implementation is: when consumer process read this page, it will invoke a pagefualt.
The page fault handler will let the consumer pte (page table entry) point to the physical page, then suspend the consumer process. When producer process sets this page to FIXSTATE, producer will
find the wait queue and wake up consumer process.
My question is:
According to my research, I can't call schedule() in page fault handler to suspend consumer process because it's in interrupt context. So I set the consumer process state to TASK_UNINTERRUPTIBLE, then call resched_task(current) to indicate current (consumer) process needs reschedule when return from pagefault handler. But resched_task is a static function in kernel/sched.c, it can't be called outside this file.
Is there some method to suspend/sleep the current process (the process invoke pagefault) in page fault handler?
thanks in advance for any answers!