Dormancy
The so-called sleep is to let the CPU then does not return
wait_event_interruptible(wq, condition)
Sleep condition = 0 ///
condition = 1 /// wake
wait_event_interruptible()和wait_up_interruptible()
wait_event_interruptible (wq, condition)
with wake_up_interruptible () after the wake, wait_event_interruptible (wq, condition) macro itself and then check the "condition" the conditions to decide whether to return or continue to sleep, it returns true, false continued to sleep, but this program if the interrupt routine, then interrupt, and will continue to execute the interrupt function. Only when the execution wake_up_interruptible () condition and the condition is satisfied when the program will wake up from the queue.
Driving Example binding analysis
static int touch_event_handler(void *unused)
{
do
{
mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM);
set_current_state(TASK_INTERRUPTIBLE);
wait_event_interruptible(waiter, zintix_tpd_flag!=0);
zintix_tpd_flag = 0;
set_current_state (TASK_RUNNING);
mt65xx_eint_mask(CUST_EINT_TOUCH_PANEL_NUM);
if (tpd_touchinfo()) {
TPD_DEBUG_SET_TIME;
}
}while(!kthread_should_stop());
return 0;
}
static void tpd_eint_interrupt_handler(void)
{
printk("TPD interrup has been triggered\n");
// TPD_DEBUG_PRINT_INT;
zintix_tpd_flag = 1;
wake_up_interruptible(&waiter);
}
When interrupted, wake waiter, execution do () while
In add that knowledge:
wait_event_interruptible is an important function of linux-driven design interrupted him what use is it?
1 What is the use?
Is the process of sleep, waiting for interrupt:
Which will be used in the drive current of the sleep process.
2 two parameters how to use?
wait_event_interruptible(queue, condition)
1 queue interrupt queue inside a corresponding interrupt
Inside the linux kernel, wait.h inside a macro definition: DECLARE_WAIT_QUEUE_HEAD is waiting for a wait queue structure
DECLARE_WAIT_QUEUE_HEAD queue is the definition of a waiting queue
2 condition set conditions are met
Then how to restart the dormant process it?
3 How to Wake Up
In the interrupt process have added, or other processes which joined
wake_up_interruptible(&queue)