public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Michael W. Ellis" <mellis@pesa.com>
To: <ecos-discuss@ecos.sourceware.org>
Subject: RE: [ECOS] cyg_flag_timed_wait doesn't seem to work as expected
Date: Fri, 27 May 2016 20:46:00 -0000	[thread overview]
Message-ID: <07FFDDED6CBCCE4E9FBD46AEC3EBFD4F02C5069B@exchange> (raw)
In-Reply-To: <57487536.4090201@calivar.com>

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

  reply	other threads:[~2016-05-27 20:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 13:29 Michael W. Ellis
2016-05-27 15:53 ` AW: " Richard Rauch
2016-05-27 16:31 ` Nick Garnett
2016-05-27 20:46   ` Michael W. Ellis [this message]
2016-06-16 13:26 ` [ECOS] eCos Configuration Tool clewan and rebuild Michael W. Ellis
2016-06-16 17:09   ` [ECOS] " Grant Edwards
2016-06-16 21:18     ` Michael W. Ellis
2016-06-16 21:41       ` Grant Edwards
2016-06-16 23:05         ` Alex Schuilenburg
2016-06-17  4:05           ` AW: " Richard Rauch
2016-06-17 10:10             ` Alex Schuilenburg
2016-06-18 12:01               ` AW: " Richard Rauch
2016-06-18 13:20                 ` Alex Schuilenburg
2016-06-30 14:53         ` [ECOS] Input from debug console Michael W. Ellis
2016-06-30 16:01           ` Michael W. Ellis
2016-06-30 16:09             ` Evgeniy Dushistov
2016-06-30 17:52             ` [ECOS] " Grant Edwards

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=07FFDDED6CBCCE4E9FBD46AEC3EBFD4F02C5069B@exchange \
    --to=mellis@pesa.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    /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).