world leader in high performance signal processing
Trace: » work_queues

Work Queues

A Work Queue is a method used to allow a non blockable process like an interrupt service routine to trigger a deferred process that may include blocking functions.

There is a default work queue monitored by the kernel event deamon keventd. It is possible to create your own work queues

The following example shows how to use a (possibly) blocking call like vfree to delete a structure.

An example of using a work queue

  #include   <linux/workqueue.h>                           
       struct work_struct work;                                
       INIT_WORK(&work, delete_my_item, (void *)item )
  void delete_my_item( void * item)               

This is an example of creating a work queue

struct workqueue_struct * keventd_wq;
void init_workqueues(void)
        keventd_wq = create_workqueue("events");

The Kernel Functions for the Work Queue system are as follows

schedule_work queue the work on the keventd work queue
schedule_delayed_work queue the work on the keventd after a delay in jiffies
schedule_delayed_work_on queue the work on a selected cpu
flush_scheduled_work wait until all schedule jobs are completed
queue_work queue the task on a work queue
queue_delayed_work queue the work after a delay in jiffies
flush_workqueue wait until all the queued tasks have completed
__create_workqueue create a new workqueue
destroy_workqueue delete a workqueue