2009-12-08 07:11:25     short delay (0.9ms) with nanosleep

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2009-12-08 07:11:25     short delay (0.9ms) with nanosleep

Stefan Pledl (GERMANY)

Message: 83241   

 

Is it possible to delay a user space program shorter than 1 ms.

 

I have done some tests with nanosleep  (0.9 ms) and found out that the real delay varies between 0.2 and 1.1 ms.

 

I use a customized BF537 board and high resolution timers are enabled.

 

#

# Kernel Timer/Scheduler

#

# CONFIG_HZ_100 is not set

# CONFIG_HZ_250 is not set

# CONFIG_HZ_300 is not set

CONFIG_HZ_1000=y

CONFIG_HZ=1000

CONFIG_SCHED_HRTICK=y

CONFIG_GENERIC_TIME=y

CONFIG_GENERIC_CLOCKEVENTS=y

# CONFIG_TICKSOURCE_GPTMR0 is not set

CONFIG_TICKSOURCE_CORETMR=y

# CONFIG_CYCLES_CLOCKSOURCE is not set

# CONFIG_GPTMR0_CLOCKSOURCE is not set

CONFIG_TICK_ONESHOT=y

# CONFIG_NO_HZ is not set

CONFIG_HIGH_RES_TIMERS=y

CONFIG_GENERIC_CLOCKEVENTS_BUILD=y

 

 

Stefan

QuoteReplyEditDelete

 

 

2009-12-09 02:33:28     Re: short delay (0.9ms) with nanosleep

Yi Li (CHINA)

Message: 83265   

 

Stefan,

 

Please also enable "CONFIG_CYCLES_CLOCKSOURCE". Otherwise the HRT is not really enabled. I think we need to select this option by default.

 

You can check whether HRT is enabled or not by looking at /proc/timer_list, here is mine (on BF537-STAMP):

 

root:/> cat /proc/timer_list

Timer List Version: v0.4

HRTIMER_MAX_CLOCK_BASES: 2

now at 7340499546 nsecs

 

cpu: 0

clock 0:

  .base:       00174cf4

  .index:      0

  .resolution: 1 nsecs

  .get_time:   _ktime_get_real

  .offset:     21532631707209 nsecs

active timers:

clock 1:

  .base:       00174d20

  .index:      1

  .resolution: 1 nsecs

  .get_time:   _ktime_get

  .offset:     0 nsecs

active timers:

#0: <00175224>, _tick_sched_timer, S:01

# expires at 7344000000-7344000000 nsecs [in 3500454 to 3500454 nsecs]

#1: <0295b9f4>, _hrtimer_wakeup, S:01

# expires at 8202222051-8203222044 nsecs [in 861722505 to 862722498 nsecs]

#2: <0201de80>, _it_real_fn, S:01

# expires at 8241537871-8241537871 nsecs [in 901038325 to 901038325 nsecs]

#3: <02cefe90>, _hrtimer_wakeup, S:01

# expires at 13241495915-13241495915 nsecs [in 5900996369 to 5900996369 nsecs]

  .expires_next   : 7344000000 nsecs

  .hres_active    : 1

  .nr_events      : 1765

  .nohz_mode      : 0

  .idle_tick      : 0 nsecs

  .tick_stopped   : 0

  .idle_jiffies   : 0

  .idle_calls     : 0

  .idle_sleeps    : 0

  .idle_entrytime : 0 nsecs

  .idle_waketime  : 0 nsecs

  .idle_exittime  : 0 nsecs

  .idle_sleeptime : 0 nsecs

  .last_jiffies   : 0

  .next_jiffies   : 0

  .idle_expires   : 0 nsecs

jiffies: 4294894131

 

 

Tick Device: mode:     1

Per CPU device: 0

Clock Event Device: bfin_core_timer

max_delta_ns:   2147483647

min_delta_ns:   1000

mult:           2147483648

shift:          32

mode:           3

next_event:     7344000000 nsecs

set_next_event: _bfin_timer_set_next_event

set_mode:       _bfin_timer_set_mode

event_handler:  _hrtimer_interrupt

 

 

You can see the clock0 and clock1 has resolution of 1 nsecs.

 

-Yi

QuoteReplyEditDelete

 

 

2009-12-13 04:26:25     Re: short delay (0.9ms) with nanosleep

Stefan Pledl (GERMANY)

Message: 83460   

 

Hi Yi,

 

now with "CONFIG_CYCLES_CLOCKSOURCE" enabed the delay varies between 0.85 and about  1ms.

 

In the future, if the PREEMT_RT patches are integrated into the blackfin kernel, i think we can make this time

more precise.

 

I agree with you that we should enable this option by default .

 

tanks al lot

Attachments

    Outcomes