i use below code for waiting interrupt and read data, this code work fine but it use 100% of cpu.
How use semaphore to avoid cpu 100% usage?
static irqreturn_t tsc_irq_handler(int irq,void *dev_id)
{
write_pointer= *TSF_CBWPR;
read_pointer = *TSF_CBRPR;
flag = 1;
return IRQ_HANDLED;
}
int thread_fn(void *unused)
{
while (!kthread_should_stop())
{
while(!flag){};
flag=0;
//do some code, like write to file.
}
return 0;
}