cyg_flag_init
Name: cyg_flag_init ( ) - initialize a flag for use
Synopsis:
void cyg_flag_init
(
  cyg_flag_t *flag /* flag to initialize */
)
Description: This initializes a flag for use. Flags are synchronization mechanism that allows threads to wait on a condition or a set of conditions. Each condition is represented as a bit. Bits are user defined.
Include: #include <cyg/kernel/kapi.h>
Returns: nothing
See Also: cyg_flag_destroy

cyg_flag_destroy
Name: cyg_flag_destroy ( ) - destroy (invalidate) a flag
Synopsis:
void cyg_flag_destroy
(
  cyg_flag_t *flag /* flag to destroy (invalidate) */
)
Description: This destroys or invalidates a flag. Be certain that no threads are waiting on or otherwise using a flag when you call this function or you may deadlock the system.
Include: #include <cyg/kernel/kapi.h>
Returns: nothing
See Also: cyg_flag_init

cyg_flag_setbits
Name: cyg_flag_setbits ( ) - set bits (conditions) in a flag
Synopsis:
void cyg_flag_setbits
(
  cyg_flag_t       *flag, /* flag to modify */
  cyg_flag_value_t value  /* bits to set    */
)
Description: This sets bits (conditions) to true in a flag. Any bit in "value" that is set to true (1) will set the equivalent bit in the flag. This may wake threads waiting on this flag as a result.
Include: #include <cyg/kernel/kapi.h>
Returns: nothing
See Also: cyg_flag_maskbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_peek, cyg_flag_waiting

cyg_flag_maskbits
Name: cyg_flag_maskbits ( ) - clear conditions (bits) in a flag
Synopsis:
void cyg_flag_maskbits
(
  cyg_flag_t       *flag, /* flag to modify */
  cyg_flag_value_t value  /* bits to clear  */
)
Description: This clears bits (conditions) in a flag. Any bit that is set to false (0) in "value" will be subsequently cleared in the flag. If "value" is set to 0, all conditions will be cleared, if "value" is set to all ones, no conditions will be cleared. Since this just clears conditions, no thread will run as a result of a call to this function.
Include: #include <cyg/kernel/kapi.h>
Returns: nothing
See Also: cyg_flag_setbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_peek, cyg_flag_waiting

cyg_flag_wait
Name: cyg_flag_wait ( ) - wait forever on a flag
Synopsis:
cyg_flag_value_t cyg_flag_wait
(
  cyg_flag_t       *flag,   /* flag to wait on     */
  cyg_flag_value_t pattern, /* pattern to wait for */
  cyg_flag_mode_t  mode     /* mode of waiting     */
)
Description: This causes the calling thread to wait on a set of bits (conditions) to be set in a given flag. The "mode" indicates how the pattern will be interpreted:

CYG_FLAG_WAITMODE_AND - return match if all conditions in the pattern are set in the flag

CYG_FLAG_WAITMODE_OR - return match if any of the conditions in the pattern are set in the flag.

CYG_FLAG_WAITMODE_CLR - automatically clear the conditions that caused the calling thread to return a match, IF there was a match.

CYG_FLAG_WAITMODE_CLR can be combined with CYG_FLAG_WAITMODE_AND or CYG_FLAG_WAITMODE_OR to clear the bits that caused the condition to be met by oring the bitfields together.

If the conditions are met, the pattern that caused the pattern match is returned. A value of 0 will be returned if the thread was awakened for another reason other than a pattern match or a bad value was specified as the mode.

Include: #include <cyg/kernel/kapi.h>
Returns: the pattern that caused a match or 0 if an error.
See Also: cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_peek, cyg_flag_waiting

cyg_flag_timed_wait
Name: cyg_flag_timed_wait ( ) - wait on a flag until timeout
Synopsis:
cyg_flag_value_t cyg_flag_timed_wait
(
  cyg_flag_t       *flag,   /* flag to wait on        */
  cyg_flag_value_t pattern, /* pattern to wait for    */
  cyg_flag_mode_t  mode     /* mode of waiting        */
  cyg_tick_count_t abstime  /* absolute timeout value */
)
Description: This causes the calling thread to wait on a set of bits (conditions) to be set in a given flag. If the system clock goes beyond "abstime" the wait will timeout and an error will be returned. The "mode" indicates how the pattern will be interpreted:

CYG_FLAG_WAITMODE_AND - return match if all conditions in the pattern are set in the flag

CYG_FLAG_WAITMODE_OR - return match if any of the conditions in the pattern are set in the flag.

CYG_FLAG_WAITMODE_CLR - automatically clear the conditions that caused the calling thread to return a match, IF there was a match.

CYG_FLAG_WAITMODE_CLR can be combined with CYG_FLAG_WAITMODE_AND or CYG_FLAG_WAITMODE_OR to clear the bits that caused the condition to be met by oring the bitfields together.

If the conditions are met, the pattern that caused the pattern match is returned. A value of 0 will be returned if the thread timed out, was awakened for another reason other than a pattern match or a bad value was specified as the mode.

Include: #include <cyg/kernel/kapi.h>
Returns: the pattern that caused a match or 0 if an error or timeout.
See Also: cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_wait, cyg_flag_poll, cyg_flag_peek, cyg_flag_waiting

cyg_flag_poll
Name: cyg_flag_poll ( ) - test for pattern match but do not block
Synopsis:
cyg_flag_value_t cyg_flag_poll
(
  cyg_flag_t       *flag,   /* flag to wait on     */
  cyg_flag_value_t pattern, /* pattern to wait for */
  cyg_flag_mode_t  mode     /* mode of waiting     */
)
Description: This causes the calling thread to check if a set of bits (conditions) have been set in a given flag. The "mode" indicates how the pattern will be interpreted:

CYG_FLAG_WAITMODE_AND - return match if all conditions in the pattern are set in the flag

CYG_FLAG_WAITMODE_OR - return match if any of the conditions in the pattern are set in the flag.

CYG_FLAG_WAITMODE_CLR - automatically clear the conditions that caused the calling thread to return a match, IF there was a match.

CYG_FLAG_WAITMODE_CLR can be combined with CYG_FLAG_WAITMODE_AND or CYG_FLAG_WAITMODE_OR to clear the bits that caused the condition to be met by oring the bitfields together.

If the conditions are met, the pattern that caused the pattern match is returned. A value of 0 will be returned if the thread timed out, was awakened for another reason other than a pattern match or a bad value was specified as the mode.

Include: #include <cyg/kernel/kapi.h>
Returns: the pattern that caused a match or 0 if there was no match.
See Also: cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_peek, cyg_flag_waiting

cyg_flag_peek
Name: cyg_flag_peek ( ) - returns bits (conditions) currently set in a flag
Synopsis:
cyg_flag_value_t cyg_flag_peek
(
  cyg_flag_t *flag /* flag to peek at */
)
Description: This returns the current bits (conditions) that are set in a given flag.
Include: #include <cyg/kernel/kapi.h>
Returns: the bits (conditions) as a bitmask that have been set in the flag.
See Also: cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_waiting

cyg_flag_waiting
Name: cyg_flag_waiting ( ) - check to see if threads wait on a given flag
Synopsis:
cyg_bool_t cyg_flag_waiting
(
  cyg_flag_t *flag /* flag to check */
)
Description: This reports whether any threads are currently being blocked waiting for bits (conditions) to be set in the given flag.
Include: #include <cyg/kernel/kapi.h>
Returns: "true" if threads are being blocked, "false" otherwise.
See Also: cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_peek