Workqueues – The concept

So before we get started.. Let’s introduce ourselves to some workqueue jargon.

    • Work item a simple struct that holds a pointer to the function
      that is to be executed asynchronously.
    • Work queue  a queue of work items
    • Worker threads Special purpose threads that execute the functions
      off the queue, one after the other.
    • Workerpools A thread pool that is used to manage the worker threads

An illustration…Screenshot from 2016-08-28 01:46:12

 

 

We have a work item that is a simple struct that holds a pointer to the function that needs to be asynchronously executed.

A work queue is the queue to which these work items are queued.

Now, worker threads are these special purpose threads that execute the work items on the queue, one after the other.

And for managing these worker threads we have the workerpools.

This is the typical life cycle of a workqueue:

Screenshot from 2016-08-28 01:46:40.png

While there are work items on the workqueue the worker executes the
functions associated with the work items one after the other.  When
there is no work item left on the workqueue the worker becomes idle.
When a new work item gets queued, the worker begins executing again.

And that’s all about the concept of workqueues… 😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s