rt-kernel: User & Reference Manual  424
Functions
Flags

Functions

void flags_init (flags_t *flags, flags_value_t value)
void flags_clr (flags_t *flags, flags_mask_t mask)
flags_t * flags_create (flags_value_t value)
void flags_destroy (flags_t *flags)
flags_value_t flags_get (flags_t *flags)
void flags_set (flags_t *flags, flags_mask_t mask)
void flags_wait_all (flags_t *flags, flags_mask_t mask, flags_value_t *value)
int flags_wait_all_tmo (flags_t *flags, flags_mask_t mask, tick_t time, flags_mask_t *value)
void flags_wait_any (flags_t *flags, flags_mask_t mask, flags_value_t *value)
int flags_wait_any_tmo (flags_t *flags, flags_mask_t mask, tick_t time, flags_value_t *value)

Function Documentation

void flags_clr ( flags_t *  flags,
flags_mask_t  mask 
)

Clears the flag. Bits that are set to one in the mask are cleared in the flag register. Bits that are set to zero in the mask are left unmodified.

Parameters:
flagsFlags handle
maskMask value
flags_t* flags_create ( flags_value_t  value)

Allocates and initialises a flags handle. See flags_init() for further details.

Parameters:
valueInitial value of flags
Returns:
The flags handle to be used in all subsequent operations on the flag.
void flags_destroy ( flags_t *  flags)

Frees the resources allocated by the flags. The flags must not be in use when this function is called (no task can be waiting on the flag, nor can they do so at any time after calling this function).

This function must only be called with a handle that was returned by flags_create().

Parameters:
flagsFlags handle
flags_value_t flags_get ( flags_t *  flags)

Gets the value in the flag register.

Parameters:
flagsFlags handle
Returns:
The value in the flag register.
void flags_init ( flags_t *  flags,
flags_value_t  value 
)

Initialises a flags handle. The flag register is initialised to value.

Parameters:
flagsFlags handle
valueInitial value of flags
void flags_set ( flags_t *  flags,
flags_mask_t  mask 
)

Sets the flag. Bits that are set to one in the mask are set in the flag register. Bits that are set to zero in the mask are left unmodified.

If any tasks were waiting on any of the bits that were modified, they will be put in the READY state.

Parameters:
flagsFlags handle
maskMask value
void flags_wait_all ( flags_t *  flags,
flags_mask_t  mask,
flags_value_t *  value 
)

Waits for all of the requested bits in the flag register to be set.

If all of the bits that are set to one in the mask are also set to one in the flag, then the function will return immediately. If any of the bits that are set to one in the mask are not set in the flag, then the calling task is put in the WAITING state.

Parameters:
flagsFlags handle
maskMask value
valueUpdated with value of flags after waiting
int flags_wait_all_tmo ( flags_t *  flags,
flags_mask_t  mask,
tick_t  time,
flags_mask_t *  value 
)

Analogous to flags_wait_all(), but a maximum time to wait can be specified. If any of the requested bits are not set, the calling task will wait until all of the requested bits become set, or the number of ticks given by time expires.

Parameters:
flagsFlags handle
maskMask value
timeNumber of ticks to wait
valueUpdated with value of flags after waiting
Returns:
0 if all of the requested bits are set, 1 if the service timed out.
void flags_wait_any ( flags_t *  flags,
flags_mask_t  mask,
flags_value_t *  value 
)

Waits for any of the requested bits in the flag register to be set.

If any of the bits that are set to one in the mask are also set to one in the flag, then the function will return immediately. If none of the bits that are set to one in the mask are set in the flag, then the calling task is put in the WAITING state.

Parameters:
flagsFlags handle
maskMask value
valueUpdated with value of flag register after waiting
int flags_wait_any_tmo ( flags_t *  flags,
flags_mask_t  mask,
tick_t  time,
flags_value_t *  value 
)

Analogous to flags_wait_any(), but a maximum time to wait can be specified. If none of the requested bits are set, the calling task will wait until any of the requested bits become set, or the number of ticks given by time expires.

Parameters:
flagsFlags handle
maskMask value
timeNumber of ticks to wait
valueUpdated with value of flag register after waiting
Returns:
0 if any of the requested bits are set, 1 if the service timed out.

rt-kernel