/*===========================================================================* * memmap_dmp * *===========================================================================*/ PUBLIC void memmap_dmp() { register struct proc *rp; static struct proc *oldrp = proc; int r, n = 0; phys_clicks size; /* First obtain a fresh copy of the current process table. */ if ((r = sys_getproctab(proc)) != OK) { report("IS","warning: couldn't get copy of process table", r); return; } printf("\n-nr/name--- --pc-- --sp-- -----text----- -----data----- ----stack----- --size-\n"); for (rp = oldrp; rp < END_PROC_ADDR; rp++) { if (isemptyp(rp)) continue; if (++n > 23) break; size = rp->p_memmap[T].mem_len + ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - rp->p_memmap[D].mem_phys); printf("%3d %-7.7s%7lx%7lx %4x %4x %4x %4x %4x %4x %4x %4x %4x %5uK\n", proc_nr(rp), rp->p_name, (unsigned long) rp->p_reg.pc, (unsigned long) rp->p_reg.sp, rp->p_memmap[T].mem_vir, rp->p_memmap[T].mem_phys, rp->p_memmap[T].mem_len, rp->p_memmap[D].mem_vir, rp->p_memmap[D].mem_phys, rp->p_memmap[D].mem_len, rp->p_memmap[S].mem_vir, rp->p_memmap[S].mem_phys, rp->p_memmap[S].mem_len, click_to_round_k(size)); } if (rp == END_PROC_ADDR) rp = proc; else printf("--more--\r"); oldrp = rp; }
struct schedproc* rearrange_order(struct schedproc* rmp) { // Get a copy of the process table sys_getproctab((struct proc *) &tempProc); // Loop through all the processes in the process table for ( int j = 0; j < (NR_PROCS+NR_TASKS); j++ ) { // Check if the process is one of the fake ones. If it is, assign it an endpoint for ( int i = 0; i < PROCNUM; i++ ) { if ( tempProc[j].p_name == sjf[i].p_name ) { sjf[i].p_endpoint = tempProc[j].p_endpoint; // Math? 3/4 instead of .75 sjf[i].predBurst = (.75)*(tempProc[j].p_cycles) + (.25)*sjf[i].predBurst; } } } // Then compare to the endpoint of rmp to see if it's one of the target processes for ( int i = 0; i < PROCNUM; i++ ) { if ( rmp->endpoint == sjf[i].p_endpoint ) { // sjf[i] is the new (incoming) process // Order proc based on spn int minExpectedBurst = sjf[0].predBurst; int indexOfMin = 0; // Find shortest processes (based on expected burst) for ( int j = 0; j < PROCNUM; j++ ) { if ( sjf[j].predBurst < minExpectedBurst ) { minExpectedBurst = sjf[j].predBurst; indexOfMin = j; } } // Move all the processes that are ahead of the minimum to end of queue for ( int k = 0; k < indexOfMin; k++ ) { // Move process to end of queue sys_qptab(rmp->endpoint); } break; } } return rmp; }
/*===========================================================================* * privileges_dmp * *===========================================================================*/ PUBLIC void privileges_dmp() { register struct proc *rp; static struct proc *oldrp = BEG_PROC_ADDR; register struct priv *sp; static char ipc_to[NR_SYS_PROCS + 1 + NR_SYS_PROCS/8]; int r, i,j, n = 0; /* First obtain a fresh copy of the current process and system table. */ if ((r = sys_getprivtab(priv)) != OK) { report("IS","warning: couldn't get copy of system privileges table", r); return; } if ((r = sys_getproctab(proc)) != OK) { report("IS","warning: couldn't get copy of process table", r); return; } printf("\n--nr-id-name---- -flags- -traps- -ipc_to mask------------------------ \n"); for (rp = oldrp; rp < END_PROC_ADDR; rp++) { if (isemptyp(rp)) continue; if (++n > 23) break; if (proc_nr(rp) == IDLE) printf("(%2d) ", proc_nr(rp)); else if (proc_nr(rp) < 0) printf("[%2d] ", proc_nr(rp)); else printf(" %2d ", proc_nr(rp)); r = -1; for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++) if (sp->s_proc_nr == rp->p_nr) { r ++; break; } if (r == -1 && ! (rp->p_rts_flags & SLOT_FREE)) { sp = &priv[USER_PRIV_ID]; } printf("(%02u) %-7.7s %s %s ", sp->s_id, rp->p_name, s_flags_str(sp->s_flags), s_traps_str(sp->s_trap_mask) ); for (i=j=0; i < NR_SYS_PROCS; i++, j++) { ipc_to[j] = get_sys_bit(sp->s_ipc_to, i) ? '1' : '0'; if (i % 8 == 7) ipc_to[++j] = ' '; } ipc_to[j] = '\0'; printf(" %s \n", ipc_to); } if (rp == END_PROC_ADDR) rp = BEG_PROC_ADDR; else printf("--more--\r"); oldrp = rp; }
/* * Get the process table from the kernel. Check the magic number in the table * entries. */ static int update_proc_table(void) { int r, slot; if ((r = sys_getproctab(proc)) != OK) return r; for (slot = 0; slot < NR_PROCS + NR_TASKS; slot++) { if (proc[slot].p_magic != PMAGIC) { printf("PROCFS: system version mismatch!\n"); return EINVAL; } } return OK; }
/*===========================================================================* * sendmask_dmp * *===========================================================================*/ PUBLIC void sendmask_dmp() { register struct proc *rp; static struct proc *oldrp = BEG_PROC_ADDR; int r, i,j, n = 0; /* First obtain a fresh copy of the current process table. */ if ((r = sys_getproctab(proc)) != OK) { report("IS","warning: couldn't get copy of process table", r); return; } printf("\n\n"); printf("Sendmask dump for process table. User processes (*) don't have []."); printf("\n"); printf("The rows of bits indicate to which processes each process may send."); printf("\n\n"); #if DEAD_CODE printf(" "); for (j=proc_nr(BEG_PROC_ADDR); j< INIT_PROC_NR+1; j++) { printf("%3d", j); } printf(" *\n"); for (rp = oldrp; rp < END_PROC_ADDR; rp++) { if (isemptyp(rp)) continue; if (++n > 20) break; printf("%8s ", rp->p_name); if (proc_nr(rp) == IDLE) printf("(%2d) ", proc_nr(rp)); else if (proc_nr(rp) < 0) printf("[%2d] ", proc_nr(rp)); else printf(" %2d ", proc_nr(rp)); for (j=proc_nr(BEG_PROC_ADDR); j<INIT_PROC_NR+2; j++) { if (isallowed(rp->p_sendmask, j)) printf(" 1 "); else printf(" 0 "); } printf("\n"); } if (rp == END_PROC_ADDR) { printf("\n"); rp = BEG_PROC_ADDR; } else printf("--more--\r"); oldrp = rp; #endif }
PUBLIC void proctab_dmp() { /* Proc table dump */ register struct proc *rp; static struct proc *oldrp = BEG_PROC_ADDR; int r, n = 0; phys_clicks text, data, size; /* First obtain a fresh copy of the current process table. */ if ((r = sys_getproctab(proc)) != OK) { report("IS","warning: couldn't get copy of process table", r); return; } printf("\n-nr-----gen---endpoint--name--- -prior-quant- -user---sys----size-rts flags-\n"); for (rp = oldrp; rp < END_PROC_ADDR; rp++) { if (isemptyp(rp)) continue; if (++n > 23) break; text = rp->p_memmap[T].mem_phys; data = rp->p_memmap[D].mem_phys; size = rp->p_memmap[T].mem_len + ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - data); if (proc_nr(rp) == IDLE) printf("(%2d) ", proc_nr(rp)); else if (proc_nr(rp) < 0) printf("[%2d] ", proc_nr(rp)); else printf(" %2d ", proc_nr(rp)); printf(" %5d %10d ", _ENDPOINT_G(rp->p_endpoint), rp->p_endpoint); printf(" %-8.8s %02u/%02u %02d/%02u %6lu%6lu %6uK %s", rp->p_name, rp->p_priority, rp->p_max_priority, rp->p_ticks_left, rp->p_quantum_size, rp->p_user_time, rp->p_sys_time, click_to_round_k(size), p_rts_flags_str(rp->p_rts_flags)); if (rp->p_rts_flags & (SENDING|RECEIVING)) { printf(" %-7.7s", proc_name(_ENDPOINT_P(rp->p_getfrom_e))); } printf("\n"); } if (rp == END_PROC_ADDR) rp = BEG_PROC_ADDR; else printf("--more--\r"); oldrp = rp; }
/*===========================================================================* * update_proc_table * *===========================================================================*/ static int update_proc_table(void) { /* Get the process table from the kernel. * Check the magic number in the table entries. */ int r, slot; if ((r = sys_getproctab(proc)) != OK) return r; for (slot = 0; slot < NR_PROCS + NR_TASKS; slot++) { if (proc[slot].p_magic != PMAGIC) { printf("PROCFS: system version mismatch!\n"); return EINVAL; } } return OK; }
/*===========================================================================* * privileges_dmp * *===========================================================================*/ void privileges_dmp() { register struct proc *rp; static struct proc *oldrp = BEG_PROC_ADDR; register struct priv *sp; int r, i; /* First obtain a fresh copy of the current process and system table. */ if ((r = sys_getprivtab(priv)) != OK) { printf("IS: warning: couldn't get copy of system privileges table: %d\n", r); return; } if ((r = sys_getproctab(proc)) != OK) { printf("IS: warning: couldn't get copy of process table: %d\n", r); return; } printf("-nr- -id- -name-- -flags- traps grants -ipc_to--" " -kernel calls-\n"); PROCLOOP(rp, oldrp) r = -1; for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++) if (sp->s_proc_nr == rp->p_nr) { r ++; break; } if (r == -1 && !isemptyp(rp)) { sp = &priv[USER_PRIV_ID]; } printf("(%02u) %-7.7s %s %s %6d", sp->s_id, rp->p_name, s_flags_str(sp->s_flags), s_traps_str(sp->s_trap_mask), sp->s_grant_entries); for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) { printf(" %08x", get_sys_bits(sp->s_ipc_to, i)); } printf(" "); for (i=0; i < NR_SYS_CALLS; i += BITCHUNK_BITS) { printf(" %08x", sp->s_k_call_mask[i/BITCHUNK_BITS]); } printf("\n"); }
void OSSendPtab(){ // printf("Scheduler (sched/ospex.c): %d \n", our_message.m_source); // printf("Scheduler int: %d \n", our_message.m1_i1); if (recordSched == 1) { struct pi pi_struct[NR_PROCS+NR_TASKS]; struct proc process_table[NR_PROCS+NR_TASKS]; sys_getproctab((struct proc *) &process_table); if (process_count < HISTORY) { int i; for (i = 0; i < NR_PROCS + NR_TASKS; i++) { strcpy(pi_struct[i].p_name, process_table[i].p_name); pi_struct[i].p_endpoint = process_table[i].p_endpoint; pi_struct[i].p_priority = process_table[i].p_priority; pi_struct[i].p_cpu_time_left = process_table[i].p_cpu_time_left; pi_struct[i].p_rts_flags = process_table[i].p_rts_flags; pi_struct[i].p_user_time = process_table[i].p_user_time; pi_struct[i].p_sys_time = process_table[i].p_sys_time; pi_struct[i].p_cycles = process_table[i].p_cycles; pi_struct[i].p_times.enter_queue = process_table[i].p_accounting.enter_queue; pi_struct[i].p_times.time_in_queue = process_table[i].p_accounting.time_in_queue; pi_struct[i].p_times.dequeues = process_table[i].p_accounting.dequeues; pi_struct[i].p_times.ipc_sync = process_table[i].p_accounting.ipc_sync; pi_struct[i].p_times.ipc_async = process_table[i].p_accounting.ipc_async; pi_struct[i].p_times.preempted = process_table[i].p_accounting.preempted; } sys_vircopy(SELF, (vir_bytes) &pi_struct, srcAddr, (vir_bytes) pInfoPtrs[process_count], sizeof(pi_struct)); process_count++; } sys_getrunqhead(1, SELF); // u64_t cpuFreq = cpu_get_freq(0); } }
/*===========================================================================* * schedule_process * *===========================================================================*/ static int schedule_process(struct schedproc * rmp, unsigned flags) { int err; int new_prio, new_quantum, new_cpu; pick_cpu(rmp); if (flags & SCHEDULE_CHANGE_PRIO) new_prio = rmp->priority; else new_prio = -1; if (flags & SCHEDULE_CHANGE_QUANTUM) new_quantum = rmp->time_slice; else new_quantum = -1; if (flags & SCHEDULE_CHANGE_CPU) new_cpu = rmp->cpu; else new_cpu = -1; sys_getproctab((struct proc *) &tempProc); const char* currentName = tempProc[_ENDPOINT_P(rmp->endpoint) + 5].p_name; unsigned realRuntime = tempProc[_ENDPOINT_P(rmp->endpoint) + 5].p_cycles; int fake_proc_flag = 0; for (int i = 0; i < PROCNUM; i++) { if (!strcmp(sjf[i].p_name, currentName)) { sjf[i].p_endpoint = rmp->endpoint; sjf[i].predBurst = ALPHA * realRuntime + (1 - ALPHA) * sjf[i].predBurst; fake_proc_flag = 1; } } printf("Before flag \n"); if (fake_proc_flag == 1) { printf("In flag statement \n"); int c, d, i; struct sjf swap; for (c = 0; c < (PROCNUM - 1); c++) { for (d = 0; d < (PROCNUM - c - 1); d++) { if (sjf[d].predBurst > sjf[d+1].predBurst) { swap = sjf[d]; sjf[d] = sjf[d+1]; sjf[d+1] = swap; } } } for (i = 0; i < PROCNUM; i++) { printf("Process name: %s - Predicted Runtime: %ld", sjf[i].p_name, sjf[i].predBurst); } for (i = PROCNUM - 1; i >= 0; i--) { sys_qptab(sjf[i].p_endpoint); } } printf("After flag, before break \n"); if ((err = sys_schedule(rmp->endpoint, new_prio, new_quantum, new_cpu)) != OK) { printf("PM: An error occurred when trying to schedule %d: %d\n", rmp->endpoint, err); } else{ OSSendPtab(); } return err; }
void vm_dmp() { static struct proc proc[NR_TASKS + NR_PROCS]; static struct vm_region_info vri[LINES]; struct vm_stats_info vsi; struct vm_usage_info vui; static int prev_i = -1; static vir_bytes prev_base = 0; int r, r2, i, j, first, n = 0; if (prev_i == -1) { if ((r = vm_info_stats(&vsi)) != OK) { printf("IS: warning: couldn't talk to VM: %d\n", r); return; } printf("Total %lu kB, free %lu kB, largest free %lu kB, cached %lu kB\n", vsi.vsi_total * (vsi.vsi_pagesize / 1024), vsi.vsi_free * (vsi.vsi_pagesize / 1024), vsi.vsi_largest * (vsi.vsi_pagesize / 1024), vsi.vsi_cached * (vsi.vsi_pagesize / 1024)); n++; printf("\n"); n++; prev_i++; } if ((r = sys_getproctab(proc)) != OK) { printf("IS: warning: couldn't get copy of process table: %d\n", r); return; } for (i = prev_i; i < NR_TASKS + NR_PROCS && n < LINES; i++, prev_base = 0) { if (i < NR_TASKS || isemptyp(&proc[i])) continue; /* The first batch dump for each process contains a header line. */ first = prev_base == 0; r = vm_info_region(proc[i].p_endpoint, vri, LINES - first, &prev_base); if (r < 0) { printf("Process %d (%s): error %d\n", proc[i].p_endpoint, proc[i].p_name, r); n++; continue; } if (first) { /* The entire batch should fit on the screen. */ if (n + 1 + r > LINES) { prev_base = 0; /* restart on next page */ break; } if ((r2 = vm_info_usage(proc[i].p_endpoint, &vui)) != OK) { printf("Process %d (%s): error %d\n", proc[i].p_endpoint, proc[i].p_name, r2); n++; continue; } printf("Process %d (%s): total %lu kB, common %lu kB, " "shared %lu kB\n", proc[i].p_endpoint, proc[i].p_name, vui.vui_total / 1024L, vui.vui_common / 1024L, vui.vui_shared / 1024L); n++; } while (r > 0) { for (j = 0; j < r; j++) { print_region(&vri[j], &n); } if (LINES - n - 1 <= 0) break; r = vm_info_region(proc[i].p_endpoint, vri, LINES - n - 1, &prev_base); if (r < 0) { printf("Process %d (%s): error %d\n", proc[i].p_endpoint, proc[i].p_name, r); n++; } } print_region(NULL, &n); if (n > LINES) printf("IS: internal error\n"); if (n == LINES) break; /* This may have to wipe out the "--more--" from below. */ printf(" \n"); n++; } if (i >= NR_TASKS + NR_PROCS) { i = -1; prev_base = 0; } else printf("--more--\r"); prev_i = i; }
void OSSendPtab(void) { if(snapNum == HISTORY || !firstCall) return; int i; struct qh qHistCur[NR_SCHED_QUEUES]; //Copy the queue head sys_getqhead(&qHistCur, &cpuFreq); for(i = 0; i < (NR_SCHED_QUEUES); i++) { strcpy(qHist[snapNum][i].p_name, qHistCur[i].p_name); qHist[snapNum][i].p_endpoint = qHistCur[i].p_endpoint; } //Get a copy of the current scheduling process table sys_getproctab((struct proc *) &tmpPtab); //Check all processes for(i=0;i<(NR_PROCS+NR_TASKS);i++) { //Copy the process name strcpy(snapShotHist[snapNum][i].p_name,tmpPtab[i].p_name); //Copy endpoint snapShotHist[snapNum][i].p_endpoint = tmpPtab[i].p_endpoint; //Copy priority snapShotHist[snapNum][i].p_priority = tmpPtab[i].p_priority; //Copy remaining CPU time snapShotHist[snapNum][i].p_cpu_time_left = tmpPtab[i].p_cpu_time_left; // Copy flags? (What are flags? For blocked processes?) snapShotHist[snapNum][i].p_rts_flags = tmpPtab[i].p_rts_flags; //PI Has queue head but proc does not. //Queue head copy goes here if needed //Copy NextReady if(tmpPtab[i].p_nextready) { //Copy the process sys_vircopy(SYSTEM,(vir_bytes) tmpPtab[i].p_nextready, SELF,(vir_bytes) &nextProc,sizeof(struct proc)); //Copy name strcpy(snapShotHist[snapNum][i].p_nextready,nextProc.p_name); //Copy next processes endpoint snapShotHist[snapNum][i].p_nextready_endpoint = nextProc.p_endpoint; } else { //Copy no Name and -1 for endpoint strcpy(snapShotHist[snapNum][i].p_nextready, NOPROC); snapShotHist[snapNum][i].p_nextready_endpoint = -1; } //Copy the p_accounting sys_vircopy(SYSTEM,(vir_bytes) &tmpPtab[i].p_accounting, SELF,(vir_bytes) &(snapShotHist[snapNum][i].p_times) ,sizeof(struct p_accounting)); //Copy user time snapShotHist[snapNum][i].p_user_time = tmpPtab[i].p_user_time; //Copy sys time snapShotHist[snapNum][i].p_sys_time = tmpPtab[i].p_sys_time; //Copy cycles snapShotHist[snapNum][i].p_cycles = tmpPtab[i].p_cycles; } //Incr number of snapshots taken snapNum++; }
void OSSendPtab(void){ int i; if(recordSched == 1){ struct pi sendPi[NR_PROCS + NR_TASKS]; /*Use the following array to recover the next ready processes before we lose the addresses*/ struct proc nextReady[NR_PROCS + NR_TASKS]; struct proc tmpPtab[NR_PROCS +NR_TASKS]; struct proc queuehds[NR_SCHED_QUEUES]; if(pos_count < HISTORY ){ /*Get the current process table */ sys_getproctab((struct proc *) &tmpPtab); sys_cpuvar((char *) &queuehds,SELF); /* Handle the heads of each queue */ struct qh qh_send[NR_SCHED_QUEUES]; for(i=0;i<NR_SCHED_QUEUES;i++){ if(queuehds[i].p_priority!=-1){ strcpy(qh_send[i].p_name,queuehds[i].p_name); qh_send[i].p_endpoint = queuehds[i].p_endpoint; } else{ qh_send[i].p_endpoint = -1; } } for(i=0;i<(NR_PROCS+NR_TASKS);i++){ strcpy(sendPi[i].p_name,tmpPtab[i].p_name); sendPi[i].p_endpoint = tmpPtab[i].p_endpoint; for (int l=0; l<PROCNUM; l++) { if (0 == strcmp(tmpPtab[i].p_name, proc_name[l])) { strcpy(sjf[l].p_name,tmpPtab[i].p_name); sjf[l].p_endpoint = tmpPtab[i].p_endpoint; sjf[l].ticks = tmpPtab[i].p_cycles; if(!proc_is_runnable(&tmpPtab[i])) { sjf[l].is_blocked = 1; // sjf[l].predBurst = INT_MAX; // sjf[l].ticks = INT_MAX; } else { sjf[l].is_blocked = 0; } } } sendPi[i].p_priority = tmpPtab[i].p_priority; sendPi[i].p_cpu_time_left = tmpPtab[i].p_cpu_time_left; sendPi[i].p_rts_flags = tmpPtab[i].p_rts_flags; if(tmpPtab[i].p_nextready){ sys_vircopy(SYSTEM,(vir_bytes) tmpPtab[i].p_nextready, SELF,(vir_bytes) &(nextReady[i]),sizeof(struct proc)); strcpy(sendPi[i].p_nextready,nextReady[i].p_name); sendPi[i].p_nextready_endpoint = nextReady[i].p_endpoint; } else{ strcpy(sendPi[i].p_nextready, NOPROC); sendPi[i].p_nextready_endpoint = -1; } /*Copy the accounting structure. Using CPU cycles instead of times, because CPU speeds will vary*/ sendPi[i].p_times.enter_queue = tmpPtab[i].p_accounting.enter_queue; sendPi[i].p_times.time_in_queue = tmpPtab[i].p_accounting.time_in_queue; sendPi[i].p_times.dequeues = tmpPtab[i].p_accounting.dequeues; sendPi[i].p_times.ipc_sync = tmpPtab[i].p_accounting.ipc_sync; sendPi[i].p_times.ipc_async = tmpPtab[i].p_accounting.ipc_async; sendPi[i].p_times.preempted = tmpPtab[i].p_accounting.preempted; } sys_vircopy(SELF,(vir_bytes) &sendPi, srcAddr,(vir_bytes) pInfoPtrs[pos_count],sizeof(sendPi)); sys_vircopy(SELF,(vir_bytes) &qh_send, srcAddr,(vir_bytes) pQhPtrs[pos_count],sizeof(qh_send)); int piReady = pos_count; sys_vircopy(SELF,(vir_bytes) &piReady, srcAddr, (vir_bytes) srcPtr2, sizeof(piReady)); pos_count++; /* Ensure the proc history buffer does not overflow*/ } } }
/* * Update the process tables by pulling in new copies from the kernel, PM, and * VFS, but only every so often and only if it has not failed before. Return * TRUE iff the tables are now valid. */ static int update_tables(void) { clock_t now; pid_t pid; int r, kslot, mslot, hslot; /* * If retrieving the tables failed at some point, do not keep trying * all the time. Such a failure is very unlikely to be transient. */ if (tabs_valid == FALSE) return FALSE; /* * Update the tables once per clock tick at most. The update operation * is rather heavy, transferring several hundreds of kilobytes between * servers. Userland should be able to live with information that is * outdated by at most one clock tick. */ now = getticks(); if (tabs_updated != 0 && tabs_updated == now) return TRUE; /* Perform an actual update now. */ tabs_valid = FALSE; /* Retrieve and check the kernel process table. */ if ((r = sys_getproctab(proc_tab)) != OK) { printf("MIB: unable to obtain kernel process table (%d)\n", r); return FALSE; } for (kslot = 0; kslot < NR_TASKS + NR_PROCS; kslot++) { if (proc_tab[kslot].p_magic != PMAGIC) { printf("MIB: kernel process table mismatch\n"); return FALSE; } } /* Retrieve and check the PM process table. */ r = getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc_tab, sizeof(mproc_tab)); if (r != OK) { printf("MIB: unable to obtain PM process table (%d)\n", r); return FALSE; } for (mslot = 0; mslot < NR_PROCS; mslot++) { if (mproc_tab[mslot].mp_magic != MP_MAGIC) { printf("MIB: PM process table mismatch\n"); return FALSE; } } /* Retrieve an extract of the VFS process table. */ r = getsysinfo(VFS_PROC_NR, SI_PROCLIGHT_TAB, fproc_tab, sizeof(fproc_tab)); if (r != OK) { printf("MIB: unable to obtain VFS process table (%d)\n", r); return FALSE; } tabs_valid = TRUE; tabs_updated = now; /* * Build a hash table mapping from process IDs to slot numbers, for * fast access. TODO: decide if this is better done on demand only. */ for (hslot = 0; hslot < HASH_SLOTS; hslot++) hash_tab[hslot] = NO_SLOT; for (mslot = 0; mslot < NR_PROCS; mslot++) { if (mproc_tab[mslot].mp_flags & IN_USE) { if ((pid = mproc_tab[mslot].mp_pid) <= 0) continue; hslot = mproc_tab[mslot].mp_pid % HASH_SLOTS; hnext_tab[mslot] = hash_tab[hslot]; hash_tab[hslot] = mslot; } } return TRUE; }