public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Gary Thomas <gthomas@cambridge.redhat.com>
To: Grant Edwards <grante@visi.com>
Cc: ecos-discuss@sources.redhat.com
Subject: RE: [ECOS] RedBoot gets() implimentation question
Date: Thu, 18 Jan 2001 15:08:00 -0000	[thread overview]
Message-ID: <XFMail.20010118160852.gthomas@cambridge.redhat.com> (raw)
In-Reply-To: <20010118161705.A10218@visi.com>

On 18-Jan-2001 Grant Edwards wrote:
> 
> If you don't mind, I've got a couple questions about the
> implimentation of gets() in RedBoot:
> 
> ========================================================================
> gets(char *buf, int buflen, int timeout)
> {
> [...]
> 
>     while (true) {
>#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
>         if (script && *script) {
>             c = *script++;
>         } else
>#endif
>         if ((timeout > 0) && (ptr == buf)) {
>             mon_set_read_char_timeout(50);
>             while (timeout > 0) {
>                 res = mon_read_char_with_timeout(&c);
>                 if (res) {
>                     // Got a character
>                     break;
>                 }
>                 timeout -= 50;
>             }
>             if (res == false) {
>                 return _GETS_TIMEOUT;  // Input timed out
>             }
>         } else {
>             mon_read_char(&c);
>         }
>         *ptr = '\0';
>         switch (c) {
> [...]        
> ========================================================================
> 
> The test ((timeout > 0) && (ptr == buf)) means that the timeout
> only applies for the first character, and once we've received
> that first character we use blocking reads until we see an
> end-of-line?
> 
> That means that network polling stops and TCP sockets (and
> associated timers) go dead between between the time the first
> character is received and the newline is received?  [I don't
> think that's a problem, but it's something to keep in mind.]
> 

Correct.  This was a design choice - avoid the overhead of polling
for potential new TCP connections (all that's really going on here)
once data starts coming in.

> 
> I'm also curious about the inner loop:
> 
>             mon_set_read_char_timeout(50);
>             while (timeout > 0) {
>                 res = mon_read_char_with_timeout(&c);
>                 if (res) {
>                     // Got a character
>                     break;
>                 }
>                 timeout -= 50;
>             }
> 
> Would the following be equivalent?
> 
>             mon_set_read_char_timeout(timeout);
>             res = mon_read_char_with_timeout(&c);
> 

Yes and no.  Yes - the overall timeout would be the same.  No since
we want to go back and check for new TCP connections as often as is
reasonable.

  reply	other threads:[~2001-01-18 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-18 14:12 Grant Edwards
2001-01-18 15:08 ` Gary Thomas [this message]
2001-01-19  7:31   ` Grant Edwards
2001-01-19  7:43     ` Gary Thomas

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=XFMail.20010118160852.gthomas@cambridge.redhat.com \
    --to=gthomas@cambridge.redhat.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=grante@visi.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).