[okl4-developer] okl4 system call or API about "delay" and "interrupt"

Sergio Ruocco sergio.ruocco at gmail.com
Sun Dec 2 02:15:48 EST 2007


Jorge Torres wrote:
> Hi kashin,
> 
> Having a delay is very simple and clean, simpler than saying it,
> 
> #include <interfaces/timer_client.h>
> #include <timer/timer.h>
> 
> timer_t tim, tim_ret;
> int r;
> 
> timer_init();
> tim = timer_create();
> r = timer_request(tim, MICROSECS(10), TIMER_ONESHOT);
> do {
>       tim_ret = timer_wait();
> } while(tim_ret!=tim) ;

I am not familiar with Iguana timers, so I won't comment on this code.

However...


> And that's it, or you can always go dirty with for(i=0;i<N;i++);

Busy looping to get microsecond-level delays (or any delay) is DEAD
WRONG on multiple levels.

Level 0: the compiler optimises out your empty loop.
Level 1: you waste CPU and energy
....
Level oo: the delay is typically wrong


FYI, a couple of years ago now, to get lightweight, fine-grained
(us-level) delays on Iguana/L4 I programmed my own low-level timer
driver. Things are surely better now: ask OKL guys.



> Hope it helps,
> 
> Cheers,
> 
> Jorge

	Sergio



Sergio Ruocco, PhD
home page: http://www.disco.unimib.it/ruocco             Research Fellow
mail:ruocco at disco.unimib.it / sergio.ruocco at gmail.com        NOMADIS Lab
phone: +39-02-6448-7914               Mobile, embedded real-time systems
skype: 'sergioruocco'  Dip. di Informatica, Sistemistica e COmunicazione
Building U14, room 1003  Università degli Studi di Milano-Bicocca, Italy

Your manuscript is both good and original; but the part that is good is
not original, and the part that is original is not good.
Samuel Johnson




More information about the Developer mailing list