interrupt_queueCreate

Synopsis

#include <sys/interrupt.h>

int interrupt_queueCreate(handle_t *queue, int clock);

Status

Implemented

Conformance

Phoenix-RTOS specific

Description

The interrupt_queueCreate() function shall create an interrupt queue referenced by queue. An interrupt queue is a conditional variable created with the PH_COND_UNLOCKED attribute (see condCreateWithAttr()), i.e. it has no mutex associated with it.

The handle returned in queue is meant to be passed as the queue argument of the interrupt() syscall (see Handling interrupts). The kernel broadcasts on the queue when the registered interrupt handler returns a value greater than or equal to zero, which wakes up the thread blocked in interrupt_queueWait().

The clock argument selects the clock used to interpret the timeout argument of interrupt_queueWait(). The following values are supported:

  • PH_CLOCK_RELATIVE - timeout is relative to the current time,

  • PH_CLOCK_REALTIME - timeout is an absolute time based on the real-time clock,

  • PH_CLOCK_MONOTONIC - timeout is an absolute time based on the monotonic clock.

A queue created by this function may be waited on by only one thread at a time. If more than one thread has to be woken up by the same interrupt, or the interrupt state has to be inspected under a lock, use interrupt_queueCreateLocked() together with interrupt_queueWaitLocked() instead.

The queue shall be released with resourceDestroy().

Return value

Upon successful completion, a value of zero shall be returned; otherwise, an error number shall be returned to indicate the error.

Errors

The interrupt_queueCreate() function shall fail if:

  • -ENOMEM - Insufficient memory exists to initialize the queue,

  • -EINVAL - The value of clock is invalid,

  • -EFAULT - The address specified by queue is invalid.