Annotation of researchv10dc/630/src/task.c, revision 1.1.1.1

1.1       root        1: #include <jerq.h>
                      2: #include <layer.h>
                      3: #define        TASK_C
                      4: #include <jerqproc.h>
                      5: 
                      6: #define STACK  16
                      7: int    swstk[STACK];
                      8: int    swpcbp[20];
                      9: extern int (*Sys[])();         /* pcb for the switcher */
                     10: #define        PSW     0x281A100       /* ipl 13 */
                     11: 
                     12: struct Proc *
                     13: newproc(f)
                     14:        int (*f)();
                     15: {
                     16:        register struct Proc *u;
                     17:        register i;
                     18:        for(i=0,u=proctab; i<NPROC; i++,u++) {
                     19:                if((u->state&BUSY)==0){
                     20:                        u->state |= BUSY;
                     21:                        restart(u, f);
                     22:                        u->layer=0;
                     23:                        u->nchars=0;
                     24:                        u->cbufpin=u->cbuf;
                     25:                        u->cbufpout=u->cbuf;
                     26:                        u->traptype=0;
                     27:                        u->traploc=0;
                     28:                        u->defaultfont = (struct Font*)Sys[1];
                     29:                        return u;
                     30:                }
                     31:        }
                     32:        return 0;
                     33: }
                     34: restart(p, loc)
                     35:        register struct Proc *p;
                     36:        register (*loc)();
                     37: {
                     38:        register i;
                     39:        p->pcb.psw=PSW;
                     40:        p->pcb.pc=(char(*)())loc;
                     41:        p->pcb.sp=(int)(p->stack);
                     42:        p->pcb.lower=p->pcb.sp;
                     43:        p->pcb.upper=p->pcb.lower+STKSIZ;
                     44:        p->pcb.ap=p->pcb.sp;
                     45:        p->pcb.fp=p->pcb.sp;
                     46:        for(i=8; i>=0; i--)
                     47:                p->pcb.reg[i]=0;
                     48:        p->pcb.blkmv=0; /* no block moves */
                     49:        p->text=(char *)(loc);
                     50: }
                     51: sw(run){
                     52:        if(!run)
                     53:                setnorun(P);
                     54:        callps(swpcbp);
                     55:        return;
                     56: }
                     57: switcher()
                     58: {
                     59:        register struct Proc *p=P;
                     60:        for(;;){
                     61:                p++;    /* 'cos we are the current p */
                     62:                if(p>=&proctab[NPROC])
                     63:                        p=proctab;
                     64:                if((p->state&(RUN|ZOMBIE))==RUN)
                     65:                        resume(P=p);
                     66:        }
                     67: }
                     68: swinit()
                     69: {
                     70:        register int * pcbptr = swpcbp;
                     71: 
                     72:        *pcbptr=0x281a180;              /* psw, r+i bits set only */
                     73:        *(pcbptr+1)=(int)switcher;      /* initial pc */
                     74:        *(pcbptr+2)=(int)swstk;         /* initial stack */
                     75:        *(pcbptr+3)=0x1a100;
                     76:        *(pcbptr+4)=(int)switcher;      /* initial pc */
                     77:        *(pcbptr+5)=(int)swstk;
                     78:        *(pcbptr+6)=(int)swstk;
                     79:        *(pcbptr+7)=(int)&swstk[STACK-1];
                     80:        *(pcbptr+8)=(int)swstk; /* ap */
                     81:        *(pcbptr+9)=(int)swstk; /* fp */
                     82:        *(pcbptr+19)=0;         /* no block moves */
                     83: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.