9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] thread confusion
Date: Wed, 21 Sep 2005 16:37:21 -0400	[thread overview]
Message-ID: <ee9e417a050921133714f0e59a@mail.gmail.com> (raw)
In-Reply-To: <200509212025.j8LKPdr29497@demeter.cs.utwente.nl>

> if I first close one randomly chosen end of the pipe,
> and then do a zero-length write at the other end and
> then close that end, it works.

By it works I assume you mean you get a zero-length
read out the other end.  But that's because you did a
zero-length write, not because the pipe is signaling EOF.

> It also works if I first close one end of the pipe,
> and then do the zero-length write and close at the
> other end.

Pipes are symmetric so this is good.

> is this a correct procedure, or would another be preferred?

What doesn't work?  Can you post a small test program
that doesn't make a blocked read fail when the other
end of the pipe is closed?  Again, it sounds like you're
not closing all the references to one end of the pipe.
If multiple programs have references to a pipe end,
they *all* need to close them.  Make sure that the
proc running tlsClient doesn't have a reference too.

> the question is how to start and reset the timer.

It depends how granular this timer is.  If we're talking
about something large like seconds, then it is reasonable
to have the timer proc just poll the channel with nbrecvp
for new work or cancellations after it ticks off each second.

Your alternate approach, with a tick stream, is also reasonable.

No matter which you use, the return channels that the timer
proc writes to should be buffered so that the timer proc never
blocks writing to them.

Russ


  parent reply	other threads:[~2005-09-21 20:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-21 14:44 Fco. J. Ballesteros
2005-09-21 15:05 ` Axel Belinfante
2005-09-21 15:42   ` Russ Cox
2005-09-21 20:25     ` Axel Belinfante
2005-09-21 20:32       ` Axel Belinfante
2005-09-21 20:37       ` Russ Cox [this message]
2005-09-21 22:34         ` Axel Belinfante
2005-09-21 22:44           ` Russ Cox
2005-09-26 18:40       ` rog
2005-09-26 18:52         ` Russ Cox
2005-09-26 19:20           ` rog
2005-09-27 10:12         ` Axel Belinfante
  -- strict thread matches above, loose matches on Subject: below --
2005-09-21 15:48 Fco. J. Ballesteros
2005-09-21 13:53 Fco. J. Ballesteros
2005-09-21 14:32 ` Axel Belinfante
2005-09-21 13:25 Axel Belinfante

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=ee9e417a050921133714f0e59a@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /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).