struct mproc *mproc)
{
int p, nprocs;
- int idleticks = 0, kernelticks = 0;
+ int idleticks = 0, kernelticks = 0, systemticks = 0, userticks = 0;
for(p = nprocs = 0; p < PROCS; p++) {
if(proc2[p].p_rts_flags & SLOT_FREE)
/* Kernel task time, not counting IDLE */
if(proc2[p].p_nr < 0)
kernelticks += tick_procs[nprocs].ticks;
+ else if(mproc[proc2[p].p_nr].mp_procgrp == 0)
+ systemticks += tick_procs[nprocs].ticks;
+ else
+ userticks += tick_procs[nprocs].ticks;
nprocs++;
}
qsort(tick_procs, nprocs, sizeof(tick_procs[0]), cmp_ticks);
- printf("CPU states: %5.2f%% user, %5.2f%% kernel, %5.2f%% idle\n\n",
- 100.0*(dt-idleticks-kernelticks)/dt,
- 100.0*(kernelticks)/dt,
+ printf("CPU states: %5.2f%% user, %5.2f%% system, %5.2f%% kernel, %5.2f%% idle\n\n",
+ 100.0*userticks/dt,
+ 100.0*systemticks/dt,
+ 100.0*kernelticks/dt,
100.0*idleticks/dt);
maxlines -= 2;
the last 1-minute, 5-minute and 15-minute intervals. Then, over the
last top interval it displays: the number of alive, active, and sleeping
processes; memory free; and CPU usage. CPU usage is split into
-user, kernel and idle time. Kernel time is time spent by kernel tasks,
-that is tasks that run in kernel mode in kernel address space. User
-time is all other CPU time, including system processes such as servers
-and drivers, as top can't see the difference between a user process and
-a server or driver.
+user, kernel, system and idle time. Kernel time is time spent by kernel tasks,
+that is tasks that run in kernel mode in kernel address space. System
+time are system user processes, such as drivers and servers. User
+time is all other CPU time.
Then it displays all the alive processes sorted by CPU usage in the last
interval, with a number of fields for every process. Currently the
block_t b; /* block containing link text */
struct buf *bp; /* buffer containing link text */
register struct inode *rip; /* target inode */
+ int copylen;
+ copylen = m_in.m1_i2;
+ if(copylen < 0) return EINVAL;
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
if ((rip = parse_path(user_path, (char *) 0, EAT_PATH_OPAQUE)) == NIL_INODE)
if (m_in.name2_length <= 0) r = EINVAL;
else if (m_in.name2_length < rip->i_size) r = ERANGE;
else {
+ if(rip->i_size < copylen) copylen = rip->i_size;
bp = get_block(rip->i_dev, b, NORMAL);
r = sys_vircopy(SELF, D, (vir_bytes) bp->b_data,
- who_e, D, (vir_bytes) m_in.name2, (vir_bytes) rip->i_size);
+ who_e, D, (vir_bytes) m_in.name2, (vir_bytes) copylen);
- if (r == OK) r = rip->i_size;
+ if (r == OK) r = copylen;
put_block(bp, DIRECTORY_BLOCK);
}
}