<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Event Flags</TITLE
|
>Event Flags</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="The eCos Kernel"
|
TITLE="The eCos Kernel"
|
HREF="kernel.html"><LINK
|
HREF="kernel.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="Mail boxes"
|
TITLE="Mail boxes"
|
HREF="kernel-mail-boxes.html"><LINK
|
HREF="kernel-mail-boxes.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Spinlocks"
|
TITLE="Spinlocks"
|
HREF="kernel-spinlocks.html"></HEAD
|
HREF="kernel-spinlocks.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="REFENTRY"
|
CLASS="REFENTRY"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="kernel-mail-boxes.html"
|
HREF="kernel-mail-boxes.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="kernel-spinlocks.html"
|
HREF="kernel-spinlocks.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><H1
|
><H1
|
><A
|
><A
|
NAME="KERNEL-FLAGS">Event Flags</H1
|
NAME="KERNEL-FLAGS">Event Flags</H1
|
><DIV
|
><DIV
|
CLASS="REFNAMEDIV"
|
CLASS="REFNAMEDIV"
|
><A
|
><A
|
NAME="AEN1555"
|
NAME="AEN1555"
|
></A
|
></A
|
><H2
|
><H2
|
>Name</H2
|
>Name</H2
|
>cyg_flag_init, cyg_flag_destroy, cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_peek, cyg_flag_waiting -- Synchronization primitive</DIV
|
>cyg_flag_init, cyg_flag_destroy, cyg_flag_setbits, cyg_flag_maskbits, cyg_flag_wait, cyg_flag_timed_wait, cyg_flag_poll, cyg_flag_peek, cyg_flag_waiting -- Synchronization primitive</DIV
|
><DIV
|
><DIV
|
CLASS="REFSYNOPSISDIV"
|
CLASS="REFSYNOPSISDIV"
|
><A
|
><A
|
NAME="AEN1566"><H2
|
NAME="AEN1566"><H2
|
>Synopsis</H2
|
>Synopsis</H2
|
><DIV
|
><DIV
|
CLASS="FUNCSYNOPSIS"
|
CLASS="FUNCSYNOPSIS"
|
><A
|
><A
|
NAME="AEN1567"><P
|
NAME="AEN1567"><P
|
></P
|
></P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="FUNCSYNOPSISINFO"
|
CLASS="FUNCSYNOPSISINFO"
|
>#include <cyg/kernel/kapi.h>
|
>#include <cyg/kernel/kapi.h>
|
</PRE
|
</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>void cyg_flag_init</CODE
|
>void cyg_flag_init</CODE
|
>(cyg_flag_t* flag);</CODE
|
>(cyg_flag_t* flag);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>void cyg_flag_destroy</CODE
|
>void cyg_flag_destroy</CODE
|
>(cyg_flag_t* flag);</CODE
|
>(cyg_flag_t* flag);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>void cyg_flag_setbits</CODE
|
>void cyg_flag_setbits</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t value);</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t value);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>void cyg_flag_maskbits</CODE
|
>void cyg_flag_maskbits</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t value);</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t value);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>cyg_flag_value_t cyg_flag_wait</CODE
|
>cyg_flag_value_t cyg_flag_wait</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t pattern, cyg_flag_mode_t mode);</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t pattern, cyg_flag_mode_t mode);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>cyg_flag_value_t cyg_flag_timed_wait</CODE
|
>cyg_flag_value_t cyg_flag_timed_wait</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t pattern, cyg_flag_mode_t mode, cyg_tick_count_t abstime);</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t pattern, cyg_flag_mode_t mode, cyg_tick_count_t abstime);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>cyg_flag_value_t cyg_flag_poll</CODE
|
>cyg_flag_value_t cyg_flag_poll</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t pattern, cyg_flag_mode_t mode);</CODE
|
>(cyg_flag_t* flag, cyg_flag_value_t pattern, cyg_flag_mode_t mode);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>cyg_flag_value_t cyg_flag_peek</CODE
|
>cyg_flag_value_t cyg_flag_peek</CODE
|
>(cyg_flag_t* flag);</CODE
|
>(cyg_flag_t* flag);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>cyg_bool_t cyg_flag_waiting</CODE
|
>cyg_bool_t cyg_flag_waiting</CODE
|
>(cyg_flag_t* flag);</CODE
|
>(cyg_flag_t* flag);</CODE
|
></P
|
></P
|
><P
|
><P
|
></P
|
></P
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="KERNEL-FLAGS-DESCRIPTION"
|
NAME="KERNEL-FLAGS-DESCRIPTION"
|
></A
|
></A
|
><H2
|
><H2
|
>Description</H2
|
>Description</H2
|
><P
|
><P
|
>Event flags allow a consumer thread to wait for one of several
|
>Event flags allow a consumer thread to wait for one of several
|
different types of event to occur. Alternatively it is possible to
|
different types of event to occur. Alternatively it is possible to
|
wait for some combination of events. The implementation is relatively
|
wait for some combination of events. The implementation is relatively
|
straightforward. Each event flag contains a 32-bit integer.
|
straightforward. Each event flag contains a 32-bit integer.
|
Application code associates these bits with specific events, so for
|
Application code associates these bits with specific events, so for
|
example bit 0 could indicate that an I/O operation has completed and
|
example bit 0 could indicate that an I/O operation has completed and
|
data is available, while bit 1 could indicate that the user has
|
data is available, while bit 1 could indicate that the user has
|
pressed a start button. A producer thread or a DSR can cause one or
|
pressed a start button. A producer thread or a DSR can cause one or
|
more of the bits to be set, and a consumer thread currently waiting
|
more of the bits to be set, and a consumer thread currently waiting
|
for these bits will be woken up.
|
for these bits will be woken up.
|
</P
|
</P
|
><P
|
><P
|
>Unlike semaphores no attempt is made to keep track of event counts. It
|
>Unlike semaphores no attempt is made to keep track of event counts. It
|
does not matter whether a given event occurs once or multiple times
|
does not matter whether a given event occurs once or multiple times
|
before being consumed, the corresponding bit in the event flag will
|
before being consumed, the corresponding bit in the event flag will
|
change only once. However semaphores cannot easily be used to handle
|
change only once. However semaphores cannot easily be used to handle
|
multiple event sources. Event flags can often be used as an
|
multiple event sources. Event flags can often be used as an
|
alternative to condition variables, although they cannot be used for
|
alternative to condition variables, although they cannot be used for
|
completely arbitrary conditions and they only support the equivalent
|
completely arbitrary conditions and they only support the equivalent
|
of condition variable broadcasts, not signals.
|
of condition variable broadcasts, not signals.
|
</P
|
</P
|
><P
|
><P
|
>Before an event flag can be used it must be initialized by a call to
|
>Before an event flag can be used it must be initialized by a call to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_init</TT
|
>cyg_flag_init</TT
|
>. This takes a pointer to a
|
>. This takes a pointer to a
|
<SPAN
|
<SPAN
|
CLASS="STRUCTNAME"
|
CLASS="STRUCTNAME"
|
>cyg_flag_t</SPAN
|
>cyg_flag_t</SPAN
|
> data structure, which can be part of a
|
> data structure, which can be part of a
|
larger structure. All 32 bits in the event flag will be set to 0,
|
larger structure. All 32 bits in the event flag will be set to 0,
|
indicating that no events have yet occurred. If an event flag is no
|
indicating that no events have yet occurred. If an event flag is no
|
longer required it can be cleaned up with a call to
|
longer required it can be cleaned up with a call to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_destroy</TT
|
>cyg_flag_destroy</TT
|
>, allowing the memory for the
|
>, allowing the memory for the
|
<TT
|
<TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>cyg_flag_t</I
|
>cyg_flag_t</I
|
></TT
|
></TT
|
> structure to be re-used.
|
> structure to be re-used.
|
</P
|
</P
|
><P
|
><P
|
>A consumer thread can wait for one or more events by calling
|
>A consumer thread can wait for one or more events by calling
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
>. This takes three arguments. The
|
>. This takes three arguments. The
|
first identifies a particular event flag. The second is some
|
first identifies a particular event flag. The second is some
|
combination of bits, indicating which events are of interest. The
|
combination of bits, indicating which events are of interest. The
|
final argument should be one of the following:
|
final argument should be one of the following:
|
</P
|
</P
|
><P
|
><P
|
></P
|
></P
|
><DIV
|
><DIV
|
CLASS="VARIABLELIST"
|
CLASS="VARIABLELIST"
|
><DL
|
><DL
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_FLAG_WAITMODE_AND</TT
|
>CYG_FLAG_WAITMODE_AND</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>The call to <TT
|
>The call to <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
> will block until all
|
> will block until all
|
the specified event bits are set. The event flag is not cleared when
|
the specified event bits are set. The event flag is not cleared when
|
the wait succeeds, in other words all the bits remain set.
|
the wait succeeds, in other words all the bits remain set.
|
</P
|
</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_FLAG_WAITMODE_OR</TT
|
>CYG_FLAG_WAITMODE_OR</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>The call will block until at least one of the specified event bits is
|
>The call will block until at least one of the specified event bits is
|
set. The event flag is not cleared on return.
|
set. The event flag is not cleared on return.
|
</P
|
</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_FLAG_WAITMODE_AND | CYG_FLAG_WAITMODE_CLR</TT
|
>CYG_FLAG_WAITMODE_AND | CYG_FLAG_WAITMODE_CLR</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>The call will block until all the specified event bits are set, and
|
>The call will block until all the specified event bits are set, and
|
the entire event flag is cleared when the call succeeds. Note that
|
the entire event flag is cleared when the call succeeds. Note that
|
if this mode of operation is used then a single event flag cannot be
|
if this mode of operation is used then a single event flag cannot be
|
used to store disjoint sets of events, even though enough bits might
|
used to store disjoint sets of events, even though enough bits might
|
be available. Instead each disjoint set of events requires its own
|
be available. Instead each disjoint set of events requires its own
|
event flag.
|
event flag.
|
</P
|
</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_FLAG_WAITMODE_OR | CYG_FLAG_WAITMODE_CLR</TT
|
>CYG_FLAG_WAITMODE_OR | CYG_FLAG_WAITMODE_CLR</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>The call will block until at least one of the specified event bits is
|
>The call will block until at least one of the specified event bits is
|
set, and the entire flag is cleared when the call succeeds.
|
set, and the entire flag is cleared when the call succeeds.
|
</P
|
</P
|
></DD
|
></DD
|
></DL
|
></DL
|
></DIV
|
></DIV
|
><P
|
><P
|
>A call to <TT
|
>A call to <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
> normally blocks until the
|
> normally blocks until the
|
required condition is satisfied. It will return the value of the event
|
required condition is satisfied. It will return the value of the event
|
flag at the point that the operation succeeded, which may be a
|
flag at the point that the operation succeeded, which may be a
|
superset of the requested events. If
|
superset of the requested events. If
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_thread_release</TT
|
>cyg_thread_release</TT
|
> is used to unblock a thread
|
> is used to unblock a thread
|
that is currently in a wait operation, the
|
that is currently in a wait operation, the
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
> call will instead return 0.
|
> call will instead return 0.
|
</P
|
</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_timed_wait</TT
|
>cyg_flag_timed_wait</TT
|
> is a variant of
|
> is a variant of
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
> which adds a timeout: the wait
|
> which adds a timeout: the wait
|
operation must succeed within the specified number of ticks, or it
|
operation must succeed within the specified number of ticks, or it
|
will fail with a return value of 0. <TT
|
will fail with a return value of 0. <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_poll</TT
|
>cyg_flag_poll</TT
|
>
|
>
|
is a non-blocking variant: if the wait operation can succeed
|
is a non-blocking variant: if the wait operation can succeed
|
immediately it acts like <TT
|
immediately it acts like <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
>, otherwise
|
>, otherwise
|
it returns immediately with a value of 0.
|
it returns immediately with a value of 0.
|
</P
|
</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_setbits</TT
|
>cyg_flag_setbits</TT
|
> is called by a producer thread
|
> is called by a producer thread
|
or from inside a DSR when an event occurs. The specified bits are or'd
|
or from inside a DSR when an event occurs. The specified bits are or'd
|
into the current event flag value. This may cause a waiting thread to
|
into the current event flag value. This may cause a waiting thread to
|
be woken up, if its condition is now satisfied.
|
be woken up, if its condition is now satisfied.
|
</P
|
</P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_maskbits</TT
|
>cyg_flag_maskbits</TT
|
> can be used to clear one or
|
> can be used to clear one or
|
more bits in the event flag. This can be called from a producer when a
|
more bits in the event flag. This can be called from a producer when a
|
particular condition is no longer satisfied, for example when the user
|
particular condition is no longer satisfied, for example when the user
|
is no longer pressing a particular button. It can also be used by a
|
is no longer pressing a particular button. It can also be used by a
|
consumer thread if <TT
|
consumer thread if <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_FLAG_WAITMODE_CLR</TT
|
>CYG_FLAG_WAITMODE_CLR</TT
|
> was not
|
> was not
|
used as part of the wait operation, to indicate that some but not all
|
used as part of the wait operation, to indicate that some but not all
|
of the active events have been consumed. If there are multiple
|
of the active events have been consumed. If there are multiple
|
consumer threads performing wait operations without using
|
consumer threads performing wait operations without using
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>CYG_FLAG_WAITMODE_CLR</TT
|
>CYG_FLAG_WAITMODE_CLR</TT
|
> then typically some
|
> then typically some
|
additional synchronization such as a mutex is needed to prevent
|
additional synchronization such as a mutex is needed to prevent
|
multiple threads consuming the same event.
|
multiple threads consuming the same event.
|
</P
|
</P
|
><P
|
><P
|
>Two additional functions are provided to query the current state of an
|
>Two additional functions are provided to query the current state of an
|
event flag. <TT
|
event flag. <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_peek</TT
|
>cyg_flag_peek</TT
|
> returns the current
|
> returns the current
|
value of the event flag, and <TT
|
value of the event flag, and <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_waiting</TT
|
>cyg_flag_waiting</TT
|
> can
|
> can
|
be used to find out whether or not there are any threads currently
|
be used to find out whether or not there are any threads currently
|
blocked on the event flag. Both of these functions must be used with
|
blocked on the event flag. Both of these functions must be used with
|
care because other threads may be operating on the event flag.
|
care because other threads may be operating on the event flag.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="KERNEL-FLAGS-CONTEXT"
|
NAME="KERNEL-FLAGS-CONTEXT"
|
></A
|
></A
|
><H2
|
><H2
|
>Valid contexts</H2
|
>Valid contexts</H2
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_init</TT
|
>cyg_flag_init</TT
|
> is typically called during system
|
> is typically called during system
|
initialization but may also be called in thread context. The same
|
initialization but may also be called in thread context. The same
|
applies to <TT
|
applies to <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_destroy</TT
|
>cyg_flag_destroy</TT
|
>.
|
>.
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_wait</TT
|
>cyg_flag_wait</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_flag_timed_wait</TT
|
>cyg_flag_timed_wait</TT
|
> may only be called from
|
> may only be called from
|
thread context. The remaining functions may be called from thread or
|
thread context. The remaining functions may be called from thread or
|
DSR context.
|
DSR context.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="kernel-mail-boxes.html"
|
HREF="kernel-mail-boxes.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="kernel-spinlocks.html"
|
HREF="kernel-spinlocks.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>Mail boxes</TD
|
>Mail boxes</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="kernel.html"
|
HREF="kernel.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>Spinlocks</TD
|
>Spinlocks</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|