Timer usage notes

INIT_DELAYED_WORK timer interrupt function call

Define global variables:

 #ifdef TPD_ESD_PROTECT
#define TPD_ESD_CHECK_CIRCLE       2000
static struct delayed_work gsl_esd_check_work;
static struct workqueue_struct *gsl_esd_check_workqueue = NULL;
 #endif

initialization:

#ifdef TPD_ESD_PROTECT
INIT_DELAYED_WORK(&gsl_esd_check_work, gsl_esd_check_func);
    gsl_esd_check_workqueue = create_workqueue("gsl_esd_check");
#endif

Turn on timing:

 queue_delayed_work(gsl_esd_check_workqueue, &gsl_esd_check_work, TPD_ESD_CHECK_CIRCLE);

Close timing:

 cancel_delayed_work_sync(&gsl_esd_check_work);

Interrupt function:

static void gsl_esd_check_func(struct work *work)
{
*************************************************
}

Summary and examples of Linux kernel timers and work queues

https://www.jianshu.com/p/a3ad64ddbd89
is very detailed and complete

66 original articles published · Like 112 · Visits 470,000+

Guess you like

Origin blog.csdn.net/qq_44710568/article/details/105572948