Deadline support for the net package

105 views
Skip to first unread message

Aram Hăvărneanu

unread,
Jan 5, 2014, 4:01:18 PM1/5/14
to go-p...@googlegroups.com
I will be working on adding deadline support to the net package.
Network I/O interested in timeouts will register itself with a
deadline goroutine implemented in the runtime, similar to how the Unix
code now registers with the runtime-integrated network poller.  I/O
will then proceed synchronously, as usual on Plan 9, but the deadline
goroutine (which is just a fancy timer goroutine) will post notes to
procs that exceed the timeout value.  This goroutine has to be in the
runtime because it needs access to the "m" that is blocked in the
system call.  Notice that we can't get the "m" right away, since we
are not yet scheduled on the "m" that will do the system call.  We can
get the "m" only when we try to do the I/O; until then we only save
the file descriptor.  The final registration with the deadline
goroutine is done either in entersyscall or in the syscall i/o
wrapper.

Apart from posting notes, the deadline goroutine will inform the
interrupted proc that it interrupted it, by setting some per-m flag or
something.  This has to be done to distinguish a note posted by the
deadline goroutine from a note posted by some unrelated process.

The interrupted code, having seen this flag will return whatever net
currently returns on deadlines.  If it doesn't see this flag it will
return the usual error, as normal.

This mechanism is made harder by the fact that the Go runtime expects
to own the note handlers, and we are using them in a novel way that
will break some assumptions.  In particular, because we reuse procs
instead of creating them for new I/O, we can't set up a new note
handler, so the Go-installed handler must do.  This means changing the
default handler.

-- 
Aram Hăvărneanu

Jeff Sickel

unread,
Jan 6, 2014, 2:33:39 PM1/6/14
to go-p...@googlegroups.com
Send references to the CL when you have something working.

Jeff Sickel

unread,
Jan 20, 2014, 12:06:17 PM1/20/14
to go-p...@googlegroups.com
See CL https://codereview.appspot.com/49920048 before proceeding. 

I've started flushing out the Dealine issues in association with that CL as it touches on the fd_plan9.go and other net and runtime source.
Reply all
Reply to author
Forward
0 new messages