DELAY(9)DELAY(9)

NAME

delay, microdelay, addclock0link – small delays, clock interrupts

SYNOPSIS

void delay(int ms)

void microdelay(int µs)

Timer* addclock0link(void(*clockf)(void), int ms)

DESCRIPTION

Delay busy waits for ms milliseconds. The minimum value of ms is one on most architectures.

Microdelay works exactly the same as delay but using microseconds instead.

These routines are intended for use in interrupt contexts, device reset and shutdown functions, and other places where the scheduler is unavailable. When you have a process context, and can sleep, consider tsleep(9). Tsleep does not busy wait.

Addclock0link adds a new periodic timer to the current processor’s timer list, with clockf executing every ms milliseconds. If ms is zero a default clock is used, it will panic otherwise (i.e. ms < 0).

SOURCE

/sys/src/9/port/portclock.c
/sys/src/9/*/clock.c

SEE

sleep(9)