From: Hugo Tyson <hmt@redhat.com>
To: ecos-discuss@sourceware.cygnus.com
Subject: Re: [ECOS] About Flags
Date: Fri, 06 Oct 2000 05:45:00 -0000 [thread overview]
Message-ID: <wwtsnqaduc5.fsf@masala.cygnus> (raw)
In-Reply-To: <8AE4B526B977D411841F00A0CC334020052C7A@cuz-exchange.sdesigns.net>
Fabrice Gautier <Fabrice_Gautier@sdesigns.com> writes:
> Hi,
>
> I would like to know if it is safe to destroy a flag structure after it has
> been signaled.
>
> I mean:
>
> I have several thread waiting for the flag - and they know that after wait
> return the flag pointer they have will be invalid.
> And one thread signaling the flag and then deleting it.
>
> So is it possible that between the moment the corresponding cyg_flag_setbits
> returns and the moment cyg_flag_wait returns the cyg_flag_wait function try
> to access the flag structure ?
You can just call the destructor. Cyg_Flag::~Cyg_Flag() awakens all waiting
threads with wake reason Cyg_Thread::DESTRUCT, so they know the flag is
gone, and return false. If you signalled some threads before that, they
will no longer be waiting, all will be well: they will not try to touch the
flag structure.
> Additionnaly, I would like to wait for an exact value of the flag, is this
> possible? It seems only supported operations are AND and OR.
No; flags aren't like that. If you're placing arbitrary values in there
(such as an address or a count) you're using them inappropriately.
You can choose just to put in a limited range of values of course. If you
use only 1,2,4,8,16.... then either wait opt picks up a unique value.
- Huge
prev parent reply other threads:[~2000-10-06 5:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-29 16:50 Fabrice Gautier
2000-10-06 5:45 ` Hugo Tyson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wwtsnqaduc5.fsf@masala.cygnus \
--to=hmt@redhat.com \
--cc=ecos-discuss@sourceware.cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).