lexlist* fsm::newchar(int c,int ln) { line=ln; if (c==0) if (state!=Home) throw scanerr("missed \"\n",line); else { lexlist *tmp; tmp=addnewlex(); return tmp; } else switch (state) { lexlist *temp; case Home: return homeproc(c); case Num: return numproc(c); case Fun: return funproc(c); case Var: return varproc(c); case Lab: return labproc(c); case Key: return keyproc(c); case Equ: return equproc(c); case Str: if (c=='"') { temp=addnewlex(String); return temp; } else { buffer.write(c); return 0; } } return 0; // g++ wants it... }
asmlinkage void sch$resched(void) { int cpuid = smp_processor_id(); struct _cpu * cpu=smp$gl_cpu_data[cpuid]; struct _pcb * curpcb; unsigned long curpri; unsigned long qhead; int before,after; // lock sched db, soon //if (spl(IPL$_SCHED)) return; // old=spl(IPL$_SCHED); // svpctx, do not think we need to do this here #ifdef __x86_64__ if (intr_blocked(IPL$_RESCHED)) return; regtrap(REG_INTR,IPL$_RESCHED); #endif /** spinlock sched and set ipl */ setipl(IPL$_SCHED); vmslock(&SPIN_SCHED,-1); spin_lock_irq(&runqueue_lock); /* eventually change to sched? */ /** get current pcb and priority */ curpcb=cpu->cpu$l_curpcb; release_kernel_lock(curpcb, cpuid); curpri=cpu->cpu$b_cur_pri; /** clear bit in cpu_priority table */ sch$al_cpu_priority[curpri]=sch$al_cpu_priority[curpri] & (~ cpu->cpu$l_cpuid_mask ); /** if no process with this pri on any cpu, clear bit in active_priority table */ if (!sch$al_cpu_priority[curpri]) sch$gl_active_priority=sch$gl_active_priority & (~ (1 << (31-curpri))); /** now some if's remaining from linux - TODO: check if still needed */ if (curpcb == idle_task(curpcb->pcb$l_cpu_id)) goto out; if (curpcb->state==TASK_INTERRUPTIBLE) if (signal_pending(curpcb)) { curpcb->state = TASK_RUNNING; curpcb->pcb$w_state = SCH$C_CUR; } #if 0 if (curpcb->state!=TASK_RUNNING) { curpcb->pcb$w_state=SCH$C_LEF; // use here temporarily } #endif #if 0 if (curpcb->state==TASK_RUNNING) { #endif #ifdef DEBUG_SCHED before=numproc(); // printcom(); //if (curpcb==0xa018c000 && qhead==0xa018c000) // panic("aieeeeeh\n"); mycheckaddr(0); //if (curpcb==qhead) panic(" a panic\n"); #endif /** set pri bit in comqs */ sch$gl_comqs=sch$gl_comqs | (1 << curpri); // curpcb->state=TASK_INTERRUPTIBLE; /* soon SCH$C_COM ? */ /** set state of cur pcb to COM */ curpcb->pcb$w_state=SCH$C_COM; /** insert pcb at tail of comqueue */ #ifdef __i386__ qhead=*(unsigned long *)&sch$aq_comt[curpri]; #else qhead=*(unsigned long *)&sch$aq_comh[curpri][1]; #endif if (!task_on_comqueue(curpcb)) { if (curpcb==qhead) panic(" a panic\n"); insque(curpcb,qhead); } else { panic("something\n"); } #ifdef DEBUG_SCHED mycheckaddr(42); #endif /** linux leftover */ nr_running++; #ifdef DEBUG_SCHED after=numproc(); if(after-before!=1) { //printk("entry qhead %x %x\n",curpcb,qhead); printcom(); panic("insq2 %x %x\n",before,after); } #endif out: /** clear idle_cpus to signal all idle cpus to try to reschedule */ sch$gl_idle_cpus=0; #if 0 } #endif /** go some intro sch$sched */ sch$sched(1); }
/* * Wake up a process. Put it on the run-queue if it's not * already there. The "current" process is always on the * run-queue (except when the actual re-schedule is in * progress), and as such you're allowed to do the simpler * "current->state = TASK_RUNNING" to mark yourself runnable * without the overhead of this. */ static inline int try_to_wake_up(struct task_struct * p, int synchronous) { unsigned long flags; int success = 0; unsigned long qhead; int curpri; int before,after; int cpuid = smp_processor_id(); struct _cpu * cpu=smp$gl_cpu_data[cpuid]; spin_lock_irqsave(&runqueue_lock, flags); p->state = TASK_RUNNING; p->pcb$w_state = SCH$C_COM; if (p==ctl$gl_pcb) goto out; if (task_on_comqueue(p)) /* argh! */ goto out; // p->pcb$b_pri=p->pcb$b_prib-3; /* boost */ /* not here */ curpri=p->pcb$b_pri; if (mydebug4) printk("add tyr %x %x\n",p->pcb$l_pid,curpri); #ifdef __i386__ qhead=*(unsigned long *)&sch$aq_comt[curpri]; #else qhead=*(unsigned long *)&sch$aq_comh[curpri][1]; #endif if (mydebug4) printk("eq qhead %x %x %x %x\n", (unsigned long *)qhead,(unsigned long *)(qhead+4), *(unsigned long *)qhead,*(unsigned long *)(qhead+4)); if (mydebug4) printk("p %x %x %x\n",qhead,*(void**)qhead,p); if (mydebug4) printk("iq3 %x\n",sch$aq_comh[curpri]); before=numproc(); // printcom(); // printcom2(); mycheckaddr(0); insque(p,qhead); nr_running++; after=numproc(); if(after-before!=1) { printcom(); printcom2(); panic("insq1 %x %x %x %x\n",p,p->pcb$l_pid,before,after); } if (mydebug4) printk("p %x %x %x\n",qhead,*(void**)qhead,p); if (mydebug4) printk("iq3 %x\n",sch$aq_comh[curpri]); if (mydebug4) printk("eq qhead %x %x %x %x\n", (unsigned long *)qhead,(unsigned long *)(qhead+4), *(unsigned long *)qhead,*(unsigned long *)(qhead+4)); if (mydebug4) printk("comq1 %x %x\n",curpri,sch$gl_comqs); sch$gl_comqs=sch$gl_comqs | (1 << curpri); mycheckaddr(0); if (mydebug4) printk("comq1 %x %x\n",curpri,sch$gl_comqs); if (mydebug4) { int i; struct _pcb *tmp2,*tmp3=qhead; unsigned long tmp; printk("p %x\n",p); printk("%x %x %x %x\n",tmp3,tmp3->pcb$l_sqfl,tmp3->pcb$l_sqfl->pcb$l_sqfl,tmp3->pcb$l_sqfl->pcb$l_sqfl->pcb$l_sqfl); for(i=0;i<32;i++) { tmp=&sch$aq_comh[i]; // printk("i %x %x i",i,tmp); if(*(unsigned long *)tmp == tmp) {; } else { tmp2=((struct _pcb *)tmp)->pcb$l_sqfl->pcb$l_sqfl; do { printk("com2 %x %x %x %x\n",tmp2,tmp2->pcb$l_pid,tmp2->pcb$b_pri,i); tmp2=tmp2->pcb$l_sqfl; } while (tmp2!=tmp); } } } if (!synchronous || !(p->cpus_allowed & (1 << smp_processor_id()))) reschedule_idle(p); success = 1; out: spin_unlock_irqrestore(&runqueue_lock, flags); return success; }