RTEMS Logo

RTEMS 4.7.99.2 On-Line Library


Barrier Manager BARRIER_OBTAIN - Acquire a barrier

PREV UP NEXT Bookshelf RTEMS C User's Guide

20.4.4: BARRIER_OBTAIN - Acquire a barrier

CALLING SEQUENCE:

rtems_status_code rtems_barrier_obtain(
  rtems_id         id,
  rtems_unsigned32 option_set,
  rtems_interval   timeout
);

DIRECTIVE STATUS CODES:

RTEMS_SUCCESSFUL - barrier obtained successfully
RTEMS_UNSATISFIED - barrier not available
RTEMS_TIMEOUT - timed out waiting for barrier
RTEMS_OBJECT_WAS_DELETED - barrier deleted while waiting
RTEMS_INVALID_ID - invalid barrier id

DESCRIPTION:

This directive acquires the barrier specified by id. The RTEMS_WAIT and RTEMS_NO_WAIT components of the options parameter indicate whether the calling task wants to wait for the barrier to become available or return immediately if the barrier is not currently available. With either RTEMS_WAIT or RTEMS_NO_WAIT, if the current barrier count is positive, then it is decremented by one and the barrier is successfully acquired by returning immediately with a successful return code.

Conceptually, the calling task should always be thought of as blocking when it makes this call and being unblocked when the barrier is released. If the barrier is configured for manual release, this rule of thumb will always be valid. If the barrier is configured for automatic release, all callers will block except for the one which is the Nth task which trips the automatic release condition.

The timeout parameter specifies the maximum interval the calling task is willing to be blocked waiting for the barrier. If it is set to RTEMS_NO_TIMEOUT, then the calling task will wait forever. If the barrier is available or the RTEMS_NO_WAIT option component is set, then timeout is ignored.

NOTES:

The following barrier acquisition option constants are defined by RTEMS:

A clock tick is required to support the timeout functionality of this directive.


PREV UP NEXT Bookshelf RTEMS C User's Guide

Copyright © 1988-2004 OAR Corporation