1

queue_delayed_work(struct workqueue_struct *wq,struct delayed_work *dwork,unsigned long delay)

In the above function, is it possible to give delay that is less than one jiffy?

SD.
  • 1,432
  • 22
  • 38
yash
  • 47
  • 5

3 Answers3

1

You can give a delay of zero or more jiffies. To get delay, kernel internally uses a timer. The earliest timer can expire is on the closest next tick. therefore the smallest delay possible is of 1 jiffies. In case of zero jiffies, the delayed work (dwork) will immediately start without any delay.

queue_delayed_work internally calls __queue_delayed_work where implementation for configuring timer is done. The minimum expire time is jiffies + delay. Refer links for more information.

To schedule your work less than jiffiy timer, You can make use of hrtimers(high resolution timer).

For more information related to implementing hrtimer read followinf links :

hrtimer repeating task in the Linux kernel

https://www.ibm.com/developerworks/library/l-timers-list/

Krupal Tharwala
  • 1,036
  • 9
  • 16
0

The only delay which would be less than one jiffy is 0 jiffies in case of queue_delayed_work.

delay has type unsigned long and it's specified as "number of jiffies to wait before queueing".

Nebril
  • 3,153
  • 1
  • 33
  • 50
  • currently my jiffiy timer is 10ms i want to schedule my work less than jiffiy timer, Is there any other way to do this(Don't want to change the jiffy timer) – yash Oct 25 '17 at 10:00
  • 1
    yes there is a way for scheduling your work for less than jiffy timer...It is by using the HRTimers ( High resolution timers). They give resolutions in terms of nanoseconds. – Krupal Tharwala Oct 26 '17 at 05:22
  • Go through links mentioned for implementing hrtimer. – Krupal Tharwala Oct 26 '17 at 05:30
0

when we call wait_event_interruptible ( wq, condition) is it mandatory to call wake_up function when we use wait_event_interruptible ?

yash
  • 47
  • 5