public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] About Flags
@ 2000-09-29 16:50 Fabrice Gautier
  2000-10-06  5:45 ` Hugo Tyson
  0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Gautier @ 2000-09-29 16:50 UTC (permalink / raw)
  To: Ecos-List (E-mail)

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 ?

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.

Thanks
-- 
Fabrice Gautier
fabrice_gautier@sdesigns.com 









^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] About Flags
  2000-09-29 16:50 [ECOS] About Flags Fabrice Gautier
@ 2000-10-06  5:45 ` Hugo Tyson
  0 siblings, 0 replies; 2+ messages in thread
From: Hugo Tyson @ 2000-10-06  5:45 UTC (permalink / raw)
  To: ecos-discuss


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-10-06  5:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-29 16:50 [ECOS] About Flags Fabrice Gautier
2000-10-06  5:45 ` Hugo Tyson

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).