我已经创建了一个处理中断的内核模块。此外,还有一个 C 程序。
该程序在执行期间会引起中断。当中断到来时,程序应该挂起,并保持挂起状态——直到内核模块中的中断处理程序完成对这个中断的处理。
请告诉我,如何实现?
最佳答案
您可以在内核模块执行此操作时等待具有属性 PTHREAD_PROCESS_SHARED
设置的互斥锁,当内核模块完成时,您可以向互斥锁发出信号,以便您的进程可以继续。
要设置它,您可以使用 pthread_mutexattr_setpshared
还有这个:
For inter-process synchronization, a mutex needs to be allo- cated
in memory shared between these processes. Since the memory for such a mutex must be allocated dynamically, the mutex needs to be explicitly initialized using mutex_init().
关于c - 暂停程序执行直到处理中断 - 如何实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15246670/