Better interface for sys_times.
This commit is contained in:
parent
341270673b
commit
9c3f85d14f
@ -73,7 +73,8 @@ _PROTOTYPE( int sys_sdevio, (int req, long port, endpoint_t proc_nr,
|
|||||||
void *buffer, int count, vir_bytes offset));
|
void *buffer, int count, vir_bytes offset));
|
||||||
|
|
||||||
/* Clock functionality: get system times or (un)schedule an alarm call. */
|
/* 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));
|
_PROTOTYPE(int sys_setalarm, (clock_t exp_time, int abs_time));
|
||||||
|
|
||||||
/* Shorthands for sys_irqctl() system call. */
|
/* Shorthands for sys_irqctl() system call. */
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#include "syslib.h"
|
#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 */
|
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. */
|
/* Fetch the accounting info for a proc. */
|
||||||
message m;
|
message m;
|
||||||
@ -10,10 +14,8 @@ clock_t ptr[5]; /* pointer to time buffer */
|
|||||||
|
|
||||||
m.T_ENDPT = proc;
|
m.T_ENDPT = proc;
|
||||||
r = _taskcall(SYSTASK, SYS_TIMES, &m);
|
r = _taskcall(SYSTASK, SYS_TIMES, &m);
|
||||||
ptr[0] = m.T_USER_TIME;
|
if (user_time) *user_time = m.T_USER_TIME;
|
||||||
ptr[1] = m.T_SYSTEM_TIME;
|
if (sys_time) *sys_time = m.T_SYSTEM_TIME;
|
||||||
ptr[2] = 0;
|
if (uptime) *uptime = m.T_BOOT_TICKS;
|
||||||
ptr[3] = 0;
|
|
||||||
ptr[4] = m.T_BOOT_TICKS;
|
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ int for_trace;
|
|||||||
int parent_waiting, right_child, r;
|
int parent_waiting, right_child, r;
|
||||||
pid_t pidarg, procgrp;
|
pid_t pidarg, procgrp;
|
||||||
struct mproc *p_mp;
|
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 = (int) (rmp - mproc); /* get process slot number */
|
||||||
proc_nr_e = rmp->mp_endpoint;
|
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);
|
if (rmp->mp_flags & ALARM_ON) set_alarm(proc_nr_e, (unsigned) 0);
|
||||||
|
|
||||||
/* Do accounting: fetch usage times and accumulate at parent. */
|
/* 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);
|
panic(__FILE__,"pm_exit: sys_times failed", r);
|
||||||
|
|
||||||
p_mp = &mproc[rmp->mp_parent]; /* process' parent */
|
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_utime += user_time + 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_stime += sys_time + rmp->mp_child_stime; /* add system time */
|
||||||
|
|
||||||
/* Tell the kernel the process is no longer runnable to prevent it from
|
/* 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
|
* 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;
|
pid_t procgrp;
|
||||||
vir_bytes current_sp;
|
vir_bytes current_sp;
|
||||||
struct mproc *p_mp;
|
struct mproc *p_mp;
|
||||||
clock_t t[5];
|
clock_t user_time, sys_time;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("dumpcore for %d / %s\n", rmp->mp_pid, rmp->mp_name);
|
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);
|
if (rmp->mp_flags & ALARM_ON) set_alarm(proc_nr_e, (unsigned) 0);
|
||||||
|
|
||||||
/* Do accounting: fetch usage times and accumulate at parent. */
|
/* 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);
|
panic(__FILE__,"pm_exit: sys_times failed", r);
|
||||||
|
|
||||||
p_mp = &mproc[rmp->mp_parent]; /* process' parent */
|
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_utime += user_time + 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_stime += sys_time + rmp->mp_child_stime; /* add system time */
|
||||||
|
|
||||||
/* Tell the kernel the process is no longer runnable to prevent it from
|
/* 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
|
* 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. */
|
/* Perform the times(buffer) system call. */
|
||||||
register struct mproc *rmp = mp;
|
register struct mproc *rmp = mp;
|
||||||
clock_t t[5];
|
clock_t user_time, sys_time, uptime;
|
||||||
int s;
|
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);
|
panic(__FILE__,"do_times couldn't get times", s);
|
||||||
rmp->mp_reply.reply_t1 = t[0]; /* user time */
|
rmp->mp_reply.reply_t1 = user_time; /* user time */
|
||||||
rmp->mp_reply.reply_t2 = t[1]; /* system 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_t3 = rmp->mp_child_utime; /* child user time */
|
||||||
rmp->mp_reply.reply_t4 = rmp->mp_child_stime; /* child system 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);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user