This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: cyg_flag_timed_wait doesn't seem to work as expected


> -----Original Message-----
> From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-
> owner@ecos.sourceware.org] On Behalf Of Nick Garnett
> Sent: Friday, May 27, 2016 11:27 AM
> To: ecos-discuss@ecos.sourceware.org
> Subject: Re: [ECOS] cyg_flag_timed_wait doesn't seem to work as
> expected
> 
> 
> 
> On 27/05/16 14:30, Michael W. Ellis wrote:
> > I'm running an old version of eCos (2.0.98) from eCosCentric and I'm
> > attempting to use cyg_flag_timed_wait to periodically update a
> display
> > (see code, below).  My event flag variable g_flags is initialized
> > elsewhere before this thread is created.  Other threads access the
> > same event flag but use their own bits within the flag.
> >
> > My problem is with the timed wait behavior of the event flag.  At
> > startup I see an initial wait of 30 seconds before the first display
> > update occurs, but the update occurs continually after the initial
> > timeout.  The local variable flags always reads 0, indicating
timeout
> > has occurred.  My understanding is that calling cyg_flag_timed_wait
> at
> > the top of the loop restarts the timer, but this does not seem to be
> > the case.  What am I missing here?  Is there something I must do to
> > clear the timeout event?
> >
> 
> The problem is your use of 3000 for the timeout. In eCos, timeouts
give
> the wakeup time, not the duration. So, the first call waits until tick
> 3000, but the rest return immediately since it is now past 3000.
> 
> The solution is to use cyg_current_time()+3000 in the timeout
argument.
> 
> --
> Nick Garnett                                         Kernel Architect
> eCosCentric Limited    http://www.eCosCentric.com    The eCos experts
> Barnwell House, Barnwell Drive, Cambridge, UK.        +44 1223 245571
> Registered in England and Wales:                      Reg No: 4422071
> 

This makes perfect sense now.  I made this change and everything is
working as I expect.

Thanks,

Michael

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]