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("");
}





Reply via email to