new lsub nix patch: noknixcalls

13 views
Skip to first unread message

Fco. J. Ballesteros

unread,
Apr 15, 2012, 7:26:03 AM4/15/12
to nix...@googlegroups.com, ne...@lsub.org
http://lsub.org/magic/webls?dir=/nixpatch/noknixcalls

kernel support for nix calls is gone.
it was an experiment. moving forward now.
files:
/sys/src/nix/k10/k8cpufs k8cpufs
/sys/src/nix/k10/mkfile mkfile
/sys/src/nix/k10/k8cpu k8cpu
/sys/src/nix/port/portfns.h portfns.h
/sys/src/nix/port/proc.c proc.c
/sys/src/nix/port/sysproc.c sysproc.c
/sys/src/nix/port/syssem.c syssem.c
removed:
/sys/src/nix/port/devtube.c
/sys/src/nix/port/nixcall.c
/sys/src/nix/port/tube.h

removed: /sys/src/nix/port/devtube.c
removed: /sys/src/nix/port/nixcall.c
removed: /sys/src/nix/port/tube.h
/sys/src/nix/k10/k8cpufs:
k8cpufs.orig:180 d k8cpufs:179
< nixcall
/sys/src/nix/k10/mkfile:
mkfile.orig:94,95 d mkfile:93
< devtube.$O: ../port/tube.h
< syssem.$O: ../port/tube.h
/sys/src/nix/k10/k8cpu:
k8cpu.orig:15 c k8cpu:15
< # pmc pmcio
---
> pmc pmcio
k8cpu.orig:18 d k8cpu:17
< tube
k8cpu.orig:103 d k8cpu:101
< devtube 'T'
k8cpu.orig:112 d k8cpu:109
< nixcall 'n'
k8cpu.orig:165 d k8cpu:161
< nixcall
k8cpu.orig:184 a k8cpu:181
> # tcklock
/sys/src/nix/port/portfns.h:
portfns.h.orig:350 d portfns.h:349
< void stopnixproc(void);
/sys/src/nix/port/proc.c:
proc.c.orig:440 a proc.c:441
>
proc.c.orig:1420 d proc.c:1420
< stopnixproc();
/sys/src/nix/port/sysproc.c:
sysproc.c.orig:704 a sysproc.c:705,710
> void
> sysnixsyscall(Ar0* , va_list )
> {
> print("nixsyscall() called. recompile your binary\n");
> }
>
/sys/src/nix/port/syssem.c:
syssem.c.orig:8,9 d syssem.c:7
< #include "../port/tube.h"
<
syssem.c.orig:310,454 d syssem.c:307
< }
<
< /*
< * Tube entry points as seen by the kernel.
< * They use Sem*, and not int*
< */
<
< enum{Doblock, Dontblock, Already}; /* xsend() nb argument */
<
< /*
< * Assuming t points to valid memory,
< * create a KTube for the Tube pointed to by t.
< * This is suitable for using following functions to operate
< * on user tubes from the kernel.
< */
< KTube*
< u2ktube(Tube *t)
< {
< KTube *kt;
< Segment *sg;
<
< kt = smalloc(sizeof *kt);
< kt->t = t;
< if((sg = seg(up, PTR2UINT(&t->nhole), 0)) == nil)
< panic("u2ktube: was the tube verified?");
< kt->hole = segmksem(sg, &t->nhole);
< if(seg(up, PTR2UINT(&t->nmsg), 0) != sg)
< panic("u2ktube: tricked user tube?");
< kt->msg = segmksem(sg, &t->nmsg);
< return kt;
< }
<
< static int
< xsend(KTube *kt, void *p, int nb)
< {
< int n;
< uchar *c;
< Tube *t;
<
< t = kt->t;
< assert(t != nil && p != nil);
< if(nb != Already && downsem(kt->hole, nb) < 0)
< return -1;
< n = ainc(&t->tl) - 1;
< n %= t->tsz;
< c = (uchar*)&t[1];
< c += (1+t->msz) * n;
< memmove(c+1, p, t->msz);
< coherence();
< *c = 1;
< upsem(kt->msg);
< return 0;
< }
<
< static int
< xrecv(KTube *kt, void *p, int nb)
< {
< int n;
< uchar *c;
< Tube *t;
<
< t = kt->t;
< assert(t != nil && p != nil);
< if(nb != Already && downsem(kt->msg, nb) < 0)
< return -1;
< n = ainc(&t->hd) - 1;
< n %= t->tsz;
< c = (uchar*)&t[1];
< c += (1+t->msz) * n;
< while(*c == 0)
< yield();
< memmove(p, c+1, t->msz);
< coherence();
< *c = 0;
< upsem(kt->hole);
< return 0;
< }
<
< void
< tsend(KTube *t, void *p)
< {
< xsend(t, p, Doblock);
< }
<
< void
< trecv(KTube *t, void *p)
< {
< xrecv(t, p, Doblock);
< }
<
< int
< nbtsend(KTube *t, void *p)
< {
< return xsend(t, p, Dontblock);
< }
<
< int
< nbtrecv(KTube *t, void *p)
< {
< return xrecv(t, p, Dontblock);
< }
<
< int
< talt(KTalt a[], int na)
< {
< int i, n;
< Sem **ss;
<
< assert(a != nil && na > 0);
< ss = smalloc(sizeof(Sem*) * na);
< n = 0;
< for(i = 0; i < na; i++)
< switch(a[i].op){
< case TSND:
< ss[n++] = a[i].kt->hole;
< break;
< case TRCV:
< ss[n++] = a[i].kt->msg;
< break;
< case TNBSND:
< if(nbtsend(a[i].kt, a[i].m) != -1)
< return i;
< break;
< case TNBRCV:
< if(nbtrecv(a[i].kt, a[i].m) != -1)
< return i;
< break;
< }
< if(n == 0)
< return -1;
< i = altsems(ss, n);
< free(ss);
< if(i < 0)
< return -1;
< switch(a[i].op){
< case TSND:
< xsend(a[i].kt, a[i].m, Already);
< break;
< case TRCV:
< xrecv(a[i].kt, a[i].m, Already);
< break;
< default:
< panic("talt");
< }
< return i;

erik quanstrom

unread,
Apr 15, 2012, 12:54:54 PM4/15/12
to ne...@lsub.org, nix...@googlegroups.com
i'm okay with dropping nix calls.

could you explain what the thinking is in a bit more detail?
(i'm not arguing. i just want to have this clear in my head.)

by the way, can't we do asynchronous syscalls to some extent by
providing the proper device?

- erik

Nemo

unread,
Apr 15, 2012, 12:57:51 PM4/15/12
to erik quanstrom, nix...@googlegroups.com
I think I have a new way for doing this, that didn't make public
yet because I'm still thinking on it and changing it in the whiteboard.

But I'm sure now nixcalls are not the way to go and I don't think there's
any point in keeping them.

The thinking of the code I want to remove is to use channels to the kernel
to send messages to issue system calls. That's too complex and it's even
slower than synchronous calls when used from TCs.

And yes, I think the answer to your question is yes.
But I think there might be a better way.

Nemo

unread,
Apr 15, 2012, 1:02:04 PM4/15/12
to nix...@googlegroups.com
done in that case.

;; patch/Apply nonixcalls
applying to /n/src/nix...
;; patch/Apply noknixcalls
applying to /n/src/nix...


On Apr 15, 2012, at 6:54 PM, erik quanstrom wrote:

erik quanstrom

unread,
Apr 15, 2012, 1:02:29 PM4/15/12
to ne...@lsub.org, quan...@quanstro.net, nix...@googlegroups.com
> And yes, I think the answer to your question is yes.
> But I think there might be a better way.

without knowing what you're better way might be,
i'll just note that a device has the advantage (or disadvantage)
of being mountable from another machine.

- erik

Charles Forsyth

unread,
Apr 25, 2012, 5:10:32 AM4/25/12
to nix...@googlegroups.com

A system call is a protected procedure (function) call. An asynchronous function is a process!

Reply all
Reply to author
Forward
0 new messages