Better interface for sys_times.
This commit is contained in:
parent
341270673b
commit
9c3f85d14f
5 changed files with 24 additions and 21 deletions
|
@ -73,7 +73,8 @@ _PROTOTYPE( int sys_sdevio, (int req, long port, endpoint_t proc_nr,
|
|||
void *buffer, int count, vir_bytes offset));
|
||||
|
||||
/* Clock functionality: get system times or (un)schedule an alarm call. */
|
||||
_PROTOTYPE( int sys_times, (endpoint_t proc_nr, clock_t *ptr));
|
||||
_PROTOTYPE( int sys_times, (endpoint_t proc_nr, clock_t *user_time,
|
||||
clock_t *sys_time, clock_t *uptime));
|
||||
_PROTOTYPE(int sys_setalarm, (clock_t exp_time, int abs_time));
|
||||
|
||||
/* Shorthands for sys_irqctl() system call. */
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_times(proc, ptr)
|
||||
PUBLIC int sys_times(proc, user_time, sys_time, uptime)
|
||||
int proc; /* proc whose times are needed */
|
||||
clock_t ptr[5]; /* pointer to time buffer */
|
||||
clock_t *user_time; /* time spend in the process itself */
|
||||
clock_t *sys_time; /* time spend in system on behalf of the
|
||||
* process
|
||||
*/
|
||||
clock_t *uptime; /* time the system is running */
|
||||
{
|
||||
/* Fetch the accounting info for a proc. */
|
||||
message m;
|
||||
|
@ -10,10 +14,8 @@ clock_t ptr[5]; /* pointer to time buffer */
|
|||
|
||||
m.T_ENDPT = proc;
|
||||
r = _taskcall(SYSTASK, SYS_TIMES, &m);
|
||||
ptr[0] = m.T_USER_TIME;
|
||||
ptr[1] = m.T_SYSTEM_TIME;
|
||||
ptr[2] = 0;
|
||||
ptr[3] = 0;
|
||||
ptr[4] = m.T_BOOT_TICKS;
|
||||
if (user_time) *user_time = m.T_USER_TIME;
|
||||
if (sys_time) *sys_time = m.T_SYSTEM_TIME;
|
||||
if (uptime) *uptime = m.T_BOOT_TICKS;
|
||||
return(r);
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ int for_trace;
|
|||
int parent_waiting, right_child, r;
|
||||
pid_t pidarg, procgrp;
|
||||
struct mproc *p_mp;
|
||||
clock_t t[5];
|
||||
clock_t user_time, sys_time;
|
||||
|
||||
proc_nr = (int) (rmp - mproc); /* get process slot number */
|
||||
proc_nr_e = rmp->mp_endpoint;
|
||||
|
@ -257,12 +257,12 @@ int for_trace;
|
|||
if (rmp->mp_flags & ALARM_ON) set_alarm(proc_nr_e, (unsigned) 0);
|
||||
|
||||
/* Do accounting: fetch usage times and accumulate at parent. */
|
||||
if((r=sys_times(proc_nr_e, t)) != OK)
|
||||
if((r=sys_times(proc_nr_e, &user_time, &sys_time, NULL)) != OK)
|
||||
panic(__FILE__,"pm_exit: sys_times failed", r);
|
||||
|
||||
p_mp = &mproc[rmp->mp_parent]; /* process' parent */
|
||||
p_mp->mp_child_utime += t[0] + rmp->mp_child_utime; /* add user time */
|
||||
p_mp->mp_child_stime += t[1] + rmp->mp_child_stime; /* add system time */
|
||||
p_mp->mp_child_utime += user_time + rmp->mp_child_utime; /* add user time */
|
||||
p_mp->mp_child_stime += sys_time + rmp->mp_child_stime; /* add system time */
|
||||
|
||||
/* Tell the kernel the process is no longer runnable to prevent it from
|
||||
* being scheduled in between the following steps. Then tell FS that it
|
||||
|
|
|
@ -691,7 +691,7 @@ register struct mproc *rmp; /* whose core is to be dumped */
|
|||
pid_t procgrp;
|
||||
vir_bytes current_sp;
|
||||
struct mproc *p_mp;
|
||||
clock_t t[5];
|
||||
clock_t user_time, sys_time;
|
||||
|
||||
#if 0
|
||||
printf("dumpcore for %d / %s\n", rmp->mp_pid, rmp->mp_name);
|
||||
|
@ -731,12 +731,12 @@ register struct mproc *rmp; /* whose core is to be dumped */
|
|||
if (rmp->mp_flags & ALARM_ON) set_alarm(proc_nr_e, (unsigned) 0);
|
||||
|
||||
/* Do accounting: fetch usage times and accumulate at parent. */
|
||||
if((r=sys_times(proc_nr_e, t)) != OK)
|
||||
if((r=sys_times(proc_nr_e, &user_time, &sys_time, NULL)) != OK)
|
||||
panic(__FILE__,"pm_exit: sys_times failed", r);
|
||||
|
||||
p_mp = &mproc[rmp->mp_parent]; /* process' parent */
|
||||
p_mp->mp_child_utime += t[0] + rmp->mp_child_utime; /* add user time */
|
||||
p_mp->mp_child_stime += t[1] + rmp->mp_child_stime; /* add system time */
|
||||
p_mp->mp_child_utime += user_time + rmp->mp_child_utime; /* add user time */
|
||||
p_mp->mp_child_stime += sys_time + rmp->mp_child_stime; /* add system time */
|
||||
|
||||
/* Tell the kernel the process is no longer runnable to prevent it from
|
||||
* being scheduled in between the following steps. Then tell FS that it
|
||||
|
|
|
@ -67,16 +67,16 @@ PUBLIC int do_times()
|
|||
{
|
||||
/* Perform the times(buffer) system call. */
|
||||
register struct mproc *rmp = mp;
|
||||
clock_t t[5];
|
||||
clock_t user_time, sys_time, uptime;
|
||||
int s;
|
||||
|
||||
if (OK != (s=sys_times(who_e, t)))
|
||||
if (OK != (s=sys_times(who_e, &user_time, &sys_time, &uptime)))
|
||||
panic(__FILE__,"do_times couldn't get times", s);
|
||||
rmp->mp_reply.reply_t1 = t[0]; /* user time */
|
||||
rmp->mp_reply.reply_t2 = t[1]; /* system time */
|
||||
rmp->mp_reply.reply_t1 = user_time; /* user time */
|
||||
rmp->mp_reply.reply_t2 = sys_time; /* system time */
|
||||
rmp->mp_reply.reply_t3 = rmp->mp_child_utime; /* child user time */
|
||||
rmp->mp_reply.reply_t4 = rmp->mp_child_stime; /* child system time */
|
||||
rmp->mp_reply.reply_t5 = t[4]; /* uptime since boot */
|
||||
rmp->mp_reply.reply_t5 = uptime; /* uptime since boot */
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue