The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: jnc@mercury.lcs.mit.edu (Noel Chiappa)
To: tuhs@minnie.tuhs.org
Cc: jnc@mercury.lcs.mit.edu
Subject: Re: [TUHS] V6 networking & alarm syscall
Date: Fri, 11 Jan 2019 20:24:39 -0500 (EST)	[thread overview]
Message-ID: <20190112012439.7D56A18C073@mercury.lcs.mit.edu> (raw)

    > From: Paul Ruizendaal

    > It would not seem terribly complex to add non-blocking i/o capability to
    > V6. ...  Adding a 'capacity' field to the sgtty interface would not
    > have been a big leap either. ...
    > Maybe in the 1975-1980 time frame this was not felt to be 'how Unix does
    > it'?

This point interested me, so I went and had a look at how the MIT V6+/PWB
TCP/IP did it. I looked at user TELNET, which should be pretty simple (server
would probably be more complicated, due to PTY stuff).

It's totally different - although that's in part because in the MIT system,
TCP is in the user process, along with the application. In the user process,
there's a common non-premptive 'tasking' package which both the TCP and TELNET
code use. When there are no tasks ready to run, the process uses the sleep()
system call to wait for a fixed, limited quantum (interrupts, i.e. signals,
will usually wake it before the quantum runs out); note this comment:

 / uses the system sleep call rather than the standard C library
 / sleep (sleep (III)) because there is a critical race in the
 / C library implementation which could result in the process
 / pausing forever. This is a horrible bug in the UNIX process
 / control mechanism.

Quoted without comment from me!

There are 3 TCP tasks - send, receive and timer. The process receives an
'asynchronous I/O complete' signal when a packet arrives, and that wakes up
the process, and then one of the tasks therein, to do packet processing
(incoming data, acks, etc).

There appears to be a single TELNET task, which reads from the user's
keyboard, and sends data to the network. (It looks like processing of incoming
data is handled in the context of one of the TCP tasks.) Its main loop starts
with this:

         ioctl (0, FIONREAD, &nch);
                        if (nch == 0) {
                                tk_yield ();
                                continue;
                        }
                }
                if ((c = getchar()) == EOF) {

so that ioctl() must look to see if there is any data waiting in the terminal
input buffer (I'm too lazy to go see what FIONREAD does, right at the moment).

      Noel

             reply	other threads:[~2019-01-12  1:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-12  1:24 Noel Chiappa [this message]
2019-01-12  1:58 ` Dave Horsfall
2019-01-12  2:33   ` Warner Losh
  -- strict thread matches above, loose matches on Subject: below --
2019-01-13 10:52 Paul Ruizendaal
2019-01-13 15:39 ` Warner Losh
     [not found] <mailman.1.1547258402.6716.tuhs@minnie.tuhs.org>
2019-01-12 11:13 ` Paul Ruizendaal
2019-01-12  4:14 Noel Chiappa
2019-01-11 23:27 Paul Ruizendaal
2019-01-10 23:12 Paul Ruizendaal
2019-01-11  0:17 ` Clem cole
2019-01-11 15:33 ` ron
2019-01-11 18:45   ` Clem Cole
2019-01-11 19:06     ` David
2019-01-11 22:08     ` reed
2019-01-11 22:18       ` Larry McVoy
2019-01-12 12:04         ` reed
2019-01-12 17:20           ` Clem Cole
2019-01-12 18:16             ` Eric Allman
2019-01-13  1:16               ` Madeline Autumn-Rose
2019-01-11 22:47       ` Clem Cole
2019-01-11 22:55         ` Eric Allman
2019-01-11 23:32         ` Warner Losh

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=20190112012439.7D56A18C073@mercury.lcs.mit.edu \
    --to=jnc@mercury.lcs.mit.edu \
    --cc=tuhs@minnie.tuhs.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 NNTP newsgroup(s).