static void calcFunc() { wchar_t nameString0[1024]; TMacroOpCode nFunc = (TMacroOpCode)funcLook(nameString); if (nFunc != MCODE_F_NOFUNC) { IsProcessFunc++; int paramcount=0; for (;;) { xwcsncpy(nameString0,nameString,ARRAYSIZE(nameString)); getToken(); if (currTok != tRp) paramcount++; if ( currTok == tComma) // Mantis#0001863: Отсутствие строки как параметр функции { put(MCODE_OP_PUSHUNKNOWN); put64(0); continue; } expr(); xwcsncpy(nameString,nameString0,ARRAYSIZE(nameString)); if (currTok == tRp) break; if ( currTok != tComma ) { keyMacroParseError(err_Expected_Token, L")"); currTok = tEnd; break; } } put(MCODE_OP_PUSHINT); put64(paramcount); put(nFunc); IsProcessFunc--; } else if (currTok == tFunc) { keyMacroParseError(err_Unrecognized_function, nameString); } }
void showkre(void) { float f1, f2; int psiz; int i, lc; long inttotal; long l; static int failcnt = 0; double total_time; etime = 0; CP_UPDATE(cp_time.cp_user); CP_UPDATE(cp_time.cp_nice); CP_UPDATE(cp_time.cp_sys); CP_UPDATE(cp_time.cp_intr); CP_UPDATE(cp_time.cp_idle); total_time = etime; if (total_time == 0.0) total_time = 1.0; if (etime < 100000.0) { /* < 100ms ignore this trash */ if (failcnt++ >= MAXFAIL) { clear(); mvprintw(2, 10, "The alternate system clock has died!"); mvprintw(3, 10, "Reverting to ``pigs'' display."); move(CMDLINE, 0); refresh(); failcnt = 0; sleep(5); command("pigs"); } return; } failcnt = 0; etime /= 1000000.0; etime /= ncpu; if (etime == 0) etime = 1; inttotal = 0; for (i = 0; i < nintr; i++) { if (s.intrcnt[i] == 0) continue; if (intrloc[i] == 0) { if (nextintsrow == LINES) continue; intrloc[i] = nextintsrow++; mvprintw(intrloc[i], INTSCOL + 9, "%-10.10s", intrname[i]); } X(intrcnt); l = (long)((float)s.intrcnt[i]/etime + 0.5); inttotal += l; put64(l, intrloc[i], INTSCOL + 2, 6, 'D'); } put64(inttotal, INTSROW + 1, INTSCOL + 2, 6, 'D'); Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss); Z(ncs_longhits); Z(ncs_longmiss); Z(ncs_neghits); s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits + nchtotal.ncs_miss + nchtotal.ncs_neghits; s.nchpathcount = nchtotal.ncs_longhits + nchtotal.ncs_longmiss; if (state == TIME) { s1.nchcount = s.nchcount; s1.nchpathcount = s.nchpathcount; } psiz = 0; f2 = 0.0; for (lc = 0; lc < CPUSTATES; lc++) { uint64_t val = *(uint64_t *)(((uint8_t *)&s.cp_time) + cpuoffsets[lc]); f1 = 100.0 * val / total_time; f2 += f1; l = (int) ((f2 + 1.0) / 2.0) - psiz; if (f1 > 99.9) f1 = 99.9; /* no room to display 100.0 */ putfloat(f1, GRAPHROW, GRAPHCOL + 10 * lc, 4, 1, 0); move(GRAPHROW + 2, psiz); psiz += l; while (l-- > 0) addch(cpuchar[lc]); } put64(ucount(), STATROW, STATCOL, 3, 'D'); putfloat(avenrun[0], STATROW, STATCOL + 18, 6, 2, 0); putfloat(avenrun[1], STATROW, STATCOL + 25, 6, 2, 0); putfloat(avenrun[2], STATROW, STATCOL + 32, 6, 2, 0); mvaddstr(STATROW, STATCOL + 53, buf); #define pgtokb(pg) (int64_t)((intmax_t)(pg) * vms.v_page_size / 1024) #define pgtomb(pg) (int64_t)((intmax_t)(pg) * vms.v_page_size / (1024 * 1024)) #define pgtob(pg) (int64_t)((intmax_t)(pg) * vms.v_page_size) put64(pgtob(total.t_arm), MEMROW + 2, MEMCOL + 4, 6, 0); put64(pgtob(total.t_armshr), MEMROW + 2, MEMCOL + 11, 6, 0); put64(pgtob(total.t_avm), MEMROW + 2, MEMCOL + 19, 6, 0); put64(pgtob(total.t_avmshr), MEMROW + 2, MEMCOL + 26, 6, 0); put64(pgtob(total.t_rm), MEMROW + 3, MEMCOL + 4, 6, 0); put64(pgtob(total.t_rmshr), MEMROW + 3, MEMCOL + 11, 6, 0); put64(pgtob(total.t_vm), MEMROW + 3, MEMCOL + 19, 6, 0); put64(pgtob(total.t_vmshr), MEMROW + 3, MEMCOL + 26, 6, 0); put64(pgtob(total.t_free), MEMROW + 2, MEMCOL + 34, 6, 0); put64(total.t_rq - 1, PROCSROW + 1, PROCSCOL + 0, 3, 'D'); put64(total.t_pw, PROCSROW + 1, PROCSCOL + 3, 3, 'D'); put64(total.t_dw, PROCSROW + 1, PROCSCOL + 6, 3, 'D'); put64(total.t_sl, PROCSROW + 1, PROCSCOL + 9, 3, 'D'); put64(total.t_sw, PROCSROW + 1, PROCSCOL + 12, 3, 'D'); if (extended_vm_stats == 0) { PUTRATE(Vmm.v_zfod, VMSTATROW + 0, VMSTATCOL, 7); } PUTRATE(Vmm.v_cow_faults, VMSTATROW + 1, VMSTATCOL, 7); put64(pgtob(vms.v_wire_count), VMSTATROW + 2, VMSTATCOL, 7, 0); put64(pgtob(vms.v_active_count), VMSTATROW + 3, VMSTATCOL, 7, 0); put64(pgtob(vms.v_inactive_count), VMSTATROW + 4, VMSTATCOL, 7, 0); put64(pgtob(vms.v_cache_count), VMSTATROW + 5, VMSTATCOL, 7, 0); put64(pgtob(vms.v_free_count), VMSTATROW + 6, VMSTATCOL, 7, 0); PUTRATE(Vmm.v_dfree, VMSTATROW + 7, VMSTATCOL, 7); PUTRATE(Vmm.v_pfree, VMSTATROW + 8, VMSTATCOL, 7); PUTRATE(Vmm.v_reactivated, VMSTATROW + 9, VMSTATCOL, 7); PUTRATE(Vmm.v_pdwakeups, VMSTATROW + 10, VMSTATCOL, 7); PUTRATE(Vmm.v_pdpages, VMSTATROW + 11, VMSTATCOL, 7); PUTRATE(Vmm.v_intrans, VMSTATROW + 12, VMSTATCOL, 7); if (extended_vm_stats) { PUTRATE(Vmm.v_zfod, VMSTATROW + 11, VMSTATCOL - 16, 9); PUTRATE(Vmm.v_ozfod, VMSTATROW + 12, VMSTATCOL - 16, 9); #define nz(x) ((x) ? (x) : 1) put64((s.Vmm.v_zfod - s.Vmm.v_ozfod) * 100 / nz(s.Vmm.v_zfod), VMSTATROW + 13, VMSTATCOL - 16, 9, 'D'); #undef nz PUTRATE(Vmm.v_tfree, VMSTATROW + 14, VMSTATCOL - 16, 9); } put64(s.bufspace, VMSTATROW + 13, VMSTATCOL, 7, 0); put64(s.dirtybufspace/1024, VMSTATROW + 14, VMSTATCOL, 7, 'k'); put64(s.desiredvnodes, VMSTATROW + 15, VMSTATCOL, 7, 'D'); put64(s.numvnodes, VMSTATROW + 16, VMSTATCOL, 7, 'D'); put64(s.freevnodes, VMSTATROW + 17, VMSTATCOL, 7, 'D'); PUTRATE(Vmm.v_vnodein, PAGEROW + 2, PAGECOL + 6, 4); PUTRATE(Vmm.v_vnodeout, PAGEROW + 2, PAGECOL + 11, 4); PUTRATE(Vmm.v_swapin, PAGEROW + 2, PAGECOL + 18, 4); PUTRATE(Vmm.v_swapout, PAGEROW + 2, PAGECOL + 23, 4); PUTRATE(Vmm.v_vnodepgsin, PAGEROW + 3, PAGECOL + 6, 4); PUTRATE(Vmm.v_vnodepgsout, PAGEROW + 3, PAGECOL + 11, 4); PUTRATE(Vmm.v_swappgsin, PAGEROW + 3, PAGECOL + 18, 4); PUTRATE(Vmm.v_swappgsout, PAGEROW + 3, PAGECOL + 23, 4); PUTRATE(Vmm.v_swtch, GENSTATROW + 1, GENSTATCOL + 1, 4); PUTRATE(Vmm.v_trap, GENSTATROW + 1, GENSTATCOL + 6, 4); PUTRATE(Vmm.v_syscall, GENSTATROW + 1, GENSTATCOL + 11, 4); PUTRATE(Vmm.v_intr, GENSTATROW + 1, GENSTATCOL + 16, 4); PUTRATE(Vmm.v_soft, GENSTATROW + 1, GENSTATCOL + 21, 4); PUTRATE(Vmm.v_vm_faults, GENSTATROW + 1, GENSTATCOL + 26, 4); mvprintw(DISKROW, DISKCOL + 5, " "); for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++) if (dev_select[i].selected) { char tmpstr[80]; sprintf(tmpstr, "%s%d", dev_select[i].device_name, dev_select[i].unit_number); mvprintw(DISKROW, DISKCOL + 5 + 6 * lc, " %5.5s", tmpstr); switch(state) { case TIME: dinfo(i, ++lc, &cur, &last); break; case RUN: dinfo(i, ++lc, &cur, &run); break; case BOOT: dinfo(i, ++lc, &cur, NULL); break; } } #define nz(x) ((x) ? (x) : 1) put64(s.nchpathcount, NAMEIROW + 1, NAMEICOL + 3, 9, 'D'); put64(nchtotal.ncs_longhits, NAMEIROW + 1, NAMEICOL + 12, 7, 'D'); putfloat(nchtotal.ncs_longhits * 100.0 / nz(s.nchpathcount), NAMEIROW + 1, NAMEICOL + 19, 4, 0, 0); putfloat((double)s.nchcount / nz(s.nchpathcount), NAMEIROW + 1, NAMEICOL + 27, 5, 2, 1); #undef nz }
static Proc* singlerunproc(void) { Mach *m = machp(); Schedq *rq; Proc *p; uint32_t start, now, skipscheds; int i; start = perfticks(); /* cooperative scheduling until the clock ticks */ if((p=m->readied) && p->mach==0 && p->state==Ready && &run.runq[Nrq-1].head == nil && &run.runq[Nrq-2].head == nil){ skipscheds++; rq = &run.runq[p->priority]; if(0)hi("runproc going to found before loop...\n"); goto found; } run.preempts++; loop: /* * find a process that last ran on this processor (affinity), * or one that hasn't moved in a while (load balancing). Every * time around the loop affinity goes down. */ spllo(); for(i = 0;; i++){ /* * find the highest priority target process that this * processor can run given affinity constraints. * */ for(rq = &run.runq[Nrq-1]; rq >= run.runq; rq--){ for(p = rq->head; p; p = p->rnext){ if(p->mp == nil || p->mp == sys->machptr[m->machno] || (!p->wired && i > 0)) { if(0)hi("runproc going to found inside loop...\n"); goto found; } } } /* waste time or halt the CPU */ idlehands(); /* remember how much time we're here */ now = perfticks(); m->perf.inidle += now-start; start = now; } found: splhi(); if(0)hi("runproc into found...\n"); p = dequeueproc(&run, rq, p); if(p == nil) { if(0)hi("runproc p=nil :(\n"); goto loop; } p->state = Scheding; if(0)hi("runproc, pm->mp = sys->machptr[m->machno]\n"); p->mp = sys->machptr[m->machno]; if(0){hi("runproc, sys->machptr[m->machno] = "); put64((uint64_t)p->mp); hi("\n");} if(edflock(p)){ edfrun(p, rq == &run.runq[PriEdf]); /* start deadline timer and do admin */ edfunlock(); } if(p->trace) proctrace(p, SRun, 0); /* avoiding warnings, this will be removed */ USED(mach0sched); USED(smprunproc); if(0){hi("runproc, returning p "); put64((uint64_t)p); hi("\n");} return p; }
static void prim() { switch (currTok) { case tEnd: break; case tFunc: calcFunc(); getToken(); break; case tVar: put(MCODE_OP_PUSHVAR); putstr(nameString); getToken(); break; case tConst: put(MCODE_OP_PUSHCONST); putstr(nameString); getToken(); break; case tInt: put(MCODE_OP_PUSHINT); put64(currVar.i()); getToken(); break; case tFloat: put(MCODE_OP_PUSHFLOAT); putDouble(currVar.d()); getToken(); break; case tFARVar: put(FARVar); // nFARVar получаем в getToken() getToken(); break; case tStr: put(MCODE_OP_PUSHSTR); putstr(currVar.s()); getToken(); break; case tMinus: getToken(); prim(); put(MCODE_OP_NEGATE); break; case tBitNot: getToken(); prim(); put(MCODE_OP_BITNOT); break; case tNot: getToken(); prim(); put(MCODE_OP_NOT); break; case tLp: getToken(); expr(); if (currTok != tRp) keyMacroParseError(err_Expected_Token, L")"); getToken(); break; case tRp: //??? break; default: keyMacroParseError(err_Expr_Expected); break; } }