9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Tread and alarm
@ 2010-10-27 21:09 Adriano Verardo
  2010-10-27 21:16 ` Adriano Verardo
  2010-10-27 21:40 ` cinap_lenrek
  0 siblings, 2 replies; 6+ messages in thread
From: Adriano Verardo @ 2010-10-27 21:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi, all

In a user space file server (9p(2)/9pfile(2)/...) I postpone the Rread
response if there are no available data,
in order to implement a suspensive read().

The client is (really?) suspended until Tread, but the read() sys call
cannot be interrupted by alarm().

It seems to me that the alarm note is received after Tread, as if the
process were totally freezed
waiting for the 9P transaction.

Could anyone kindly explain to me if this is correct and where is my
mistake ?

Thanks in advance

adriano




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

* Re: [9fans] Tread and alarm
  2010-10-27 21:09 [9fans] Tread and alarm Adriano Verardo
@ 2010-10-27 21:16 ` Adriano Verardo
  2010-10-27 21:26   ` erik quanstrom
  2010-10-27 21:40 ` cinap_lenrek
  1 sibling, 1 reply; 6+ messages in thread
From: Adriano Verardo @ 2010-10-27 21:16 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Errata: ... alarm note is received after Rread, as if the ...

sorry :-)

Adriano Verardo wrote:
> Hi, all
>
> In a user space file server (9p(2)/9pfile(2)/...) I postpone the Rread
> response if there are no available data,
> in order to implement a suspensive read().
>
> The client is (really?) suspended until Tread, but the read() sys call
> cannot be interrupted by alarm().
>
> It seems to me that the alarm note is received after Tread, as if the
> process were totally freezed
> waiting for the 9P transaction.
>
> Could anyone kindly explain to me if this is correct and where is my
> mistake ?
>
> Thanks in advance
>
> adriano
>
>
>
>




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

* Re: [9fans] Tread and alarm
  2010-10-27 21:16 ` Adriano Verardo
@ 2010-10-27 21:26   ` erik quanstrom
  2010-10-27 21:56     ` Adriano Verardo
  0 siblings, 1 reply; 6+ messages in thread
From: erik quanstrom @ 2010-10-27 21:26 UTC (permalink / raw)
  To: 9fans

> The client is (really?) suspended until Tread, but the read() sys call
> cannot be interrupted by alarm().

i didn't understand your errata, so to clarify,
read(2) is interruptable with a note (modulo the
file server, but that's a different story).  here's a
program that demonstrates:

; 8.readalarm
note: alarm
read -1
	interrupted

- erik

----

#include <u.h>
#include <libc.h>

void
nofun(void*, char *msg)
{
	print("note: %s\n", msg);
	if(strstr(msg, "alarm") != nil)
		noted(NCONT);
	else
		noted(NDFLT);
}

void
main(void)
{
	char buf[1024];
	int fd, n;

	fd = open("/net/log", OREAD);
	if(fd == -1)
		sysfatal("open: %r");
	notify(nofun);
	alarm(500);
	n = read(fd, buf, 1024);
	alarm(0);

	print("read %d\n", n);
	if(n < 0)
		print("	%r\n");
	exits("");
}



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

* Re: [9fans] Tread and alarm
  2010-10-27 21:09 [9fans] Tread and alarm Adriano Verardo
  2010-10-27 21:16 ` Adriano Verardo
@ 2010-10-27 21:40 ` cinap_lenrek
  2010-10-27 22:24   ` Adriano Verardo
  1 sibling, 1 reply; 6+ messages in thread
From: cinap_lenrek @ 2010-10-27 21:40 UTC (permalink / raw)
  To: 9fans

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

you have to implement flush in the 9p server.

--
cinap

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

From: Adriano Verardo <a.verardo@tecmav.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] Tread and alarm
Date: Wed, 27 Oct 2010 23:09:22 +0200
Message-ID: <4CC89502.8000304@tecmav.com>

Hi, all

In a user space file server (9p(2)/9pfile(2)/...) I postpone the Rread
response if there are no available data,
in order to implement a suspensive read().

The client is (really?) suspended until Tread, but the read() sys call
cannot be interrupted by alarm().

It seems to me that the alarm note is received after Tread, as if the
process were totally freezed
waiting for the 9P transaction.

Could anyone kindly explain to me if this is correct and where is my
mistake ?

Thanks in advance

adriano


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

* Re: [9fans] Tread and alarm
  2010-10-27 21:26   ` erik quanstrom
@ 2010-10-27 21:56     ` Adriano Verardo
  0 siblings, 0 replies; 6+ messages in thread
From: Adriano Verardo @ 2010-10-27 21:56 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

erik quanstrom wrote:
>> The client is (really?) suspended until Tread, but the read() sys call
>> cannot be interrupted by alarm().
>>
>
> i didn't understand your errata
If the are no available data, the file server doesn't do

r->ofcall.count = 0;
response(r, nil);

but just enqueue the Req and process it only when there are data to return.

The client exec alarm() and read(), exactly as in your example.
The alarm handler is the same too and I see the print only after the
server response:

r->ofcall.count = N (>0)
response(r, nil)

adriano
> , so to clarify,
> read(2) is interruptable with a note (modulo the
> file server, but that's a different story).  here's a
> program that demonstrates:
>
> ; 8.readalarm
> note: alarm
> read -1
> 	interrupted
>
> - erik
>
> ----
>
> #include <u.h>
> #include <libc.h>
>
> void
> nofun(void*, char *msg)
> {
> 	print("note: %s\n", msg);
> 	if(strstr(msg, "alarm") != nil)
> 		noted(NCONT);
> 	else
> 		noted(NDFLT);
> }
>
> void
> main(void)
> {
> 	char buf[1024];
> 	int fd, n;
>
> 	fd = open("/net/log", OREAD);
> 	if(fd == -1)
> 		sysfatal("open: %r");
> 	notify(nofun);
> 	alarm(500);
> 	n = read(fd, buf, 1024);
> 	alarm(0);
>
> 	print("read %d\n", n);
> 	if(n < 0)
> 		print("	%r\n");
> 	exits("");
> }
>
>
>
>




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

* Re: [9fans] Tread and alarm
  2010-10-27 21:40 ` cinap_lenrek
@ 2010-10-27 22:24   ` Adriano Verardo
  0 siblings, 0 replies; 6+ messages in thread
From: Adriano Verardo @ 2010-10-27 22:24 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

cinap_lenrek@gmx.de wrote:
> you have to implement flush in the 9p server.
>
> --
> cinap
>
>
Ah ...

I've just (re)read the 9p(2) man page ... it seems clear now.

Thank you very much, cinap :-)
> ------------------------------------------------------------------------
>
> Subject:
> [9fans] Tread and alarm
> From:
> Adriano Verardo <a.verardo@tecmav.com>
> Date:
> Wed, 27 Oct 2010 23:09:22 +0200
> To:
> Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
>
> To:
> Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
>
>
> Hi, all
>
> In a user space file server (9p(2)/9pfile(2)/...) I postpone the Rread
> response if there are no available data,
> in order to implement a suspensive read().
>
> The client is (really?) suspended until Tread, but the read() sys call
> cannot be interrupted by alarm().
>
> It seems to me that the alarm note is received after Tread, as if the
> process were totally freezed
> waiting for the 9P transaction.
>
> Could anyone kindly explain to me if this is correct and where is my
> mistake ?
>
> Thanks in advance
>
> adriano
>




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

end of thread, other threads:[~2010-10-27 22:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-27 21:09 [9fans] Tread and alarm Adriano Verardo
2010-10-27 21:16 ` Adriano Verardo
2010-10-27 21:26   ` erik quanstrom
2010-10-27 21:56     ` Adriano Verardo
2010-10-27 21:40 ` cinap_lenrek
2010-10-27 22:24   ` Adriano Verardo

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