9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] A question about timeout
@ 2009-07-14 14:21 Adriano Verardo
  2009-07-14 14:47 ` cinap_lenrek
  0 siblings, 1 reply; 4+ messages in thread
From: Adriano Verardo @ 2009-07-14 14:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I'm porting some Unix applications which implement a timeout on
read/write/accept/... calls using select().

In previous versions I did the same by signals but with problems
due to the behaviour  of the interrupted system call.

Select() is also used to choose among channels waiting for I/O.

How can I implement channel selection and secure timeouts
without using APE ?

Re-write some pieces is not a problem, I prefer a "pure" 8c implementation.


adriano



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] A question about timeout
  2009-07-14 14:21 [9fans] A question about timeout Adriano Verardo
@ 2009-07-14 14:47 ` cinap_lenrek
  2009-07-14 17:41   ` Adriano Verardo
  0 siblings, 1 reply; 4+ messages in thread
From: cinap_lenrek @ 2009-07-14 14:47 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

to interrupt on i/o operations you send a note to the process.
for ioproc(2), here is iointerrupt() that does that. for timeouts here is
a alarm() function (see sleep(2)) that will fire a note on you when the alarm expires.
notes should also work for rendezvous()/alt(), but a better way is to include
a timeout/cancel channel in your alt() operation. as a example see
/sys/src/cmd/rio/time.c. here we have a central timer process
that does a sleep and sends a message to channels associated
with timers when they expire.

--
cinap

[-- Attachment #2: Type: message/rfc822, Size: 2747 bytes --]

From: Adriano Verardo <a.verardo@tecmav.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] A question about timeout
Date: Tue, 14 Jul 2009 16:21:08 +0200
Message-ID: <4A5C9454.9080801@tecmav.com>

I'm porting some Unix applications which implement a timeout on
read/write/accept/... calls using select().

In previous versions I did the same by signals but with problems
due to the behaviour  of the interrupted system call.

Select() is also used to choose among channels waiting for I/O.

How can I implement channel selection and secure timeouts
without using APE ?

Re-write some pieces is not a problem, I prefer a "pure" 8c implementation.


adriano

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] A question about timeout
  2009-07-14 14:47 ` cinap_lenrek
@ 2009-07-14 17:41   ` Adriano Verardo
  2009-07-14 19:01     ` cinap_lenrek
  0 siblings, 1 reply; 4+ messages in thread
From: Adriano Verardo @ 2009-07-14 17:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

cinap_lenrek@gmx.de wrote:
> to interrupt on i/o operations you send a note to the process.
> for ioproc(2), here is iointerrupt() that does that. for timeouts here is
> a alarm() function (see sleep(2)) that will fire a note on you when the alarm expires.
> notes should also work for rendezvous()/alt(), but a better way is to include
> a timeout/cancel channel in your alt() operation. as a example see
> /sys/src/cmd/rio/time.c. here we have a central timer process
> that does a sleep and sends a message to channels associated
> with timers when they expire.
>
> --
> cinap

Thank you very much.

Where can I find the explanation of the interrupted system calls behaviour ?
In Unix I sometimes found quite difficult to deal with them.
What about Plan9 ?

adriano




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] A question about timeout
  2009-07-14 17:41   ` Adriano Verardo
@ 2009-07-14 19:01     ` cinap_lenrek
  0 siblings, 0 replies; 4+ messages in thread
From: cinap_lenrek @ 2009-07-14 19:01 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 269 bytes --]

its best to look at the manpage for the function to check
what happens in the case of interruption. but they usualy
just return -1 and set errstr will contain the string
"interrupted". plan9 does no syscall restarting.

read notify(2) and thread(2).

--
cinap

[-- Attachment #2: Type: message/rfc822, Size: 3176 bytes --]

From: Adriano Verardo <a.verardo@tecmav.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] A question about timeout
Date: Tue, 14 Jul 2009 19:41:27 +0200
Message-ID: <4A5CC347.7080806@tecmav.com>

cinap_lenrek@gmx.de wrote:
> to interrupt on i/o operations you send a note to the process.
> for ioproc(2), here is iointerrupt() that does that. for timeouts here is
> a alarm() function (see sleep(2)) that will fire a note on you when the alarm expires.
> notes should also work for rendezvous()/alt(), but a better way is to include
> a timeout/cancel channel in your alt() operation. as a example see
> /sys/src/cmd/rio/time.c. here we have a central timer process
> that does a sleep and sends a message to channels associated
> with timers when they expire.
>
> --
> cinap

Thank you very much.

Where can I find the explanation of the interrupted system calls behaviour ?
In Unix I sometimes found quite difficult to deal with them.
What about Plan9 ?

adriano

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-14 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-14 14:21 [9fans] A question about timeout Adriano Verardo
2009-07-14 14:47 ` cinap_lenrek
2009-07-14 17:41   ` Adriano Verardo
2009-07-14 19:01     ` cinap_lenrek

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