Moved stime, time, times POSIX calls from FS to PM. Removed child time
accounting from kernel (now in PM). Large amount of files in this commit is due to system time problems during development.
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
* process. Thus NR_PROCS must be the same as in the kernel. It is not
|
||||
* possible or even necessary to tell when a slot is free here.
|
||||
*/
|
||||
|
||||
|
||||
EXTERN struct fproc {
|
||||
mode_t fp_umask; /* mask set by umask system call */
|
||||
struct inode *fp_workdir; /* pointer to working directory's inode */
|
||||
|
||||
@@ -71,10 +71,12 @@ PUBLIC void main()
|
||||
}
|
||||
|
||||
/* Call the internal function that does the work. */
|
||||
if (call_nr < 0 || call_nr >= NCALLS)
|
||||
if (call_nr < 0 || call_nr >= NCALLS) {
|
||||
error = ENOSYS;
|
||||
else
|
||||
printf("FS, warning illegal %d system call by %d\n", call_nr, who);
|
||||
} else {
|
||||
error = (*call_vec[call_nr])();
|
||||
}
|
||||
|
||||
/* Copy the results back to the user and send reply. */
|
||||
if (error != SUSPEND) { reply(who, error); }
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#define whence m2_i2
|
||||
#define svrctl_req m2_i1
|
||||
#define svrctl_argp m2_p1
|
||||
#define pm_stime m1_i1
|
||||
|
||||
/* The following names are synonyms for the variables in the output message. */
|
||||
#define reply_type m_type
|
||||
|
||||
@@ -153,9 +153,8 @@ _PROTOTYPE( int get_block_size, (dev_t dev) );
|
||||
|
||||
/* time.c */
|
||||
_PROTOTYPE( int do_stime, (void) );
|
||||
_PROTOTYPE( int do_time, (void) );
|
||||
_PROTOTYPE( int do_tims, (void) );
|
||||
_PROTOTYPE( int do_utime, (void) );
|
||||
|
||||
/* cmostime.c */
|
||||
_PROTOTYPE( int do_cmostime, (void) );
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
|
||||
do_unlink, /* 10 = unlink */
|
||||
no_sys, /* 11 = waitpid */
|
||||
do_chdir, /* 12 = chdir */
|
||||
do_time, /* 13 = time */
|
||||
no_sys, /* 13 = time */
|
||||
do_mknod, /* 14 = mknod */
|
||||
do_chmod, /* 15 = chmod */
|
||||
do_chown, /* 16 = chown */
|
||||
@@ -58,7 +58,7 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
|
||||
do_unlink, /* 40 = rmdir */
|
||||
do_dup, /* 41 = dup */
|
||||
do_pipe, /* 42 = pipe */
|
||||
do_tims, /* 43 = times */
|
||||
no_sys, /* 43 = times */
|
||||
no_sys, /* 44 = (prof) */
|
||||
no_sys, /* 45 = unused */
|
||||
do_set, /* 46 = setgid */
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
*
|
||||
* The entry points into this file are
|
||||
* do_utime: perform the UTIME system call
|
||||
* do_time: perform the TIME system call
|
||||
* do_stime: perform the STIME system call
|
||||
* do_tims: perform the TIMES system call
|
||||
* do_stime: PM informs FS about STIME system call
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
@@ -58,54 +56,14 @@ PUBLIC int do_utime()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* do_time *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_time()
|
||||
|
||||
{
|
||||
/* Perform the time(tp) system call. */
|
||||
|
||||
m_out.reply_l1 = clock_time(); /* return time in seconds */
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* do_stime *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_stime()
|
||||
{
|
||||
/* Perform the stime(tp) system call. Retrieve the system's uptime (ticks
|
||||
* since boot) and store the time in seconds at system boot in the global
|
||||
* variable 'boottime'.
|
||||
*/
|
||||
|
||||
register int k;
|
||||
clock_t uptime;
|
||||
|
||||
if (!super_user) return(EPERM);
|
||||
if ( (k=sys_getuptime(&uptime)) != OK) panic("do_stime error", k);
|
||||
boottime = (long) m_in.tp - (uptime/HZ);
|
||||
/* Perform the stime(tp) system call. */
|
||||
boottime = (long) m_in.pm_stime;
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* do_tims *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_tims()
|
||||
{
|
||||
/* Perform the times(buffer) system call. */
|
||||
|
||||
clock_t t[5];
|
||||
|
||||
sys_times(who, t);
|
||||
m_out.reply_t1 = t[0];
|
||||
m_out.reply_t2 = t[1];
|
||||
m_out.reply_t3 = t[2];
|
||||
m_out.reply_t4 = t[3];
|
||||
m_out.reply_t5 = t[4];
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -400,12 +400,12 @@ PRIVATE void sendmask_dmp()
|
||||
printf("%8s ", rp->p_name);
|
||||
j = proc_nr(rp);
|
||||
switch(rp->p_type) {
|
||||
case P_IDLE: printf("/%3d/ ", proc_nr(rp)); break;
|
||||
case P_TASK: printf("[%3d] ", proc_nr(rp)); break;
|
||||
case P_SYSTEM: printf("<%3d> ", proc_nr(rp)); break;
|
||||
case P_DRIVER: printf("{%3d} ", proc_nr(rp)); break;
|
||||
case P_SERVER: printf("(%3d) ", proc_nr(rp)); break;
|
||||
default: printf(" %3d ", proc_nr(rp));
|
||||
case P_IDLE: printf("/%2d/ ", proc_nr(rp)); break;
|
||||
case P_TASK: printf("[%2d] ", proc_nr(rp)); break;
|
||||
case P_SYSTEM: printf("<%2d> ", proc_nr(rp)); break;
|
||||
case P_DRIVER: printf("{%2d} ", proc_nr(rp)); break;
|
||||
case P_SERVER: printf("(%2d) ", proc_nr(rp)); break;
|
||||
default: printf(" %2d ", proc_nr(rp));
|
||||
}
|
||||
|
||||
for (j=proc_nr(BEG_PROC_ADDR); j<INIT_PROC_NR+2; j++) {
|
||||
@@ -440,7 +440,7 @@ PRIVATE void proctab_dmp()
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\n-pid- -pri- --pc-- --sp-- -user- -sys- -text- -data- -size- -flags- -command-\n");
|
||||
printf("\n--nr/name--- -q- -sc- -user- -sys- -text- -data- -size- -flags- -command-\n");
|
||||
|
||||
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
|
||||
if (isemptyp(rp)) continue;
|
||||
@@ -450,18 +450,18 @@ PRIVATE void proctab_dmp()
|
||||
size = rp->p_memmap[T].mem_len
|
||||
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - data);
|
||||
switch(rp->p_type) {
|
||||
case P_IDLE: printf("/%3d/ ", proc_nr(rp)); break;
|
||||
case P_TASK: printf("[%3d] ", proc_nr(rp)); break;
|
||||
case P_SYSTEM: printf("<%3d> ", proc_nr(rp)); break;
|
||||
case P_DRIVER: printf("{%3d} ", proc_nr(rp)); break;
|
||||
case P_SERVER: printf("(%3d) ", proc_nr(rp)); break;
|
||||
default: printf(" %3d ", proc_nr(rp));
|
||||
case P_IDLE: printf("/%2d/ ", proc_nr(rp)); break;
|
||||
case P_TASK: printf("[%2d] ", proc_nr(rp)); break;
|
||||
case P_SYSTEM: printf("<%2d> ", proc_nr(rp)); break;
|
||||
case P_DRIVER: printf("{%2d} ", proc_nr(rp)); break;
|
||||
case P_SERVER: printf("(%2d) ", proc_nr(rp)); break;
|
||||
default: printf(" %2d ", proc_nr(rp));
|
||||
}
|
||||
printf("%3u %7lx%7lx %6lu%6lu%6uK%6uK%6uK %3x",
|
||||
printf("%-7.7s %2u %02.2x %6lu%6lu%6uK%6uK%6uK %3x",
|
||||
rp->p_name,
|
||||
rp->p_priority,
|
||||
(unsigned long) rp->p_reg.pc,
|
||||
(unsigned long) rp->p_reg.sp,
|
||||
rp->user_time, rp->sys_time,
|
||||
(char) rp->p_call_mask,
|
||||
rp->p_user_time, rp->p_sys_time,
|
||||
click_to_round_k(text), click_to_round_k(data),
|
||||
click_to_round_k(size),
|
||||
rp->p_flags);
|
||||
@@ -474,7 +474,7 @@ PRIVATE void proctab_dmp()
|
||||
if (rp->p_flags == 0) {
|
||||
printf(" ");
|
||||
}
|
||||
printf(" %s\n", rp->p_name);
|
||||
printf("\n");
|
||||
}
|
||||
if (rp == END_PROC_ADDR) rp = BEG_PROC_ADDR; else printf("--more--\r");
|
||||
oldrp = rp;
|
||||
@@ -487,7 +487,7 @@ PRIVATE void proctab_dmp()
|
||||
PRIVATE void memmap_dmp()
|
||||
{
|
||||
register struct proc *rp;
|
||||
static struct proc *oldrp = cproc_addr(HARDWARE);
|
||||
static struct proc *oldrp = proc;
|
||||
int r, n = 0;
|
||||
phys_clicks size;
|
||||
|
||||
@@ -497,22 +497,24 @@ PRIVATE void memmap_dmp()
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\n--proc name- -----text----- -----data----- ----stack----- -size-\n");
|
||||
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 %4x %4x %4x %4x %4x %4x %4x %4x %4x %5uK\n",
|
||||
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 = cproc_addr(HARDWARE);
|
||||
if (rp == END_PROC_ADDR) rp = proc;
|
||||
else printf("--more--\r");
|
||||
oldrp = rp;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ CC = exec cc
|
||||
CFLAGS = -I$i
|
||||
LDFLAGS = -i
|
||||
|
||||
OBJ = main.o forkexit.o break.o exec.o dmp.o \
|
||||
OBJ = main.o forkexit.o break.o exec.o dmp.o time.o \
|
||||
signal.o alloc.o utility.o table.o trace.o getset.o misc.o
|
||||
|
||||
# build local binary
|
||||
|
||||
@@ -133,6 +133,7 @@ int exit_status; /* the process' exit status (for parent) */
|
||||
int parent_waiting, right_child;
|
||||
pid_t pidarg, procgrp;
|
||||
struct mproc *p_mp;
|
||||
clock_t t[5];
|
||||
|
||||
proc_nr = (int) (rmp - mproc); /* get process slot number */
|
||||
|
||||
@@ -142,6 +143,12 @@ int exit_status; /* the process' exit status (for parent) */
|
||||
/* If the exited process has a timer pending, kill it. */
|
||||
if (rmp->mp_flags & ALARM_ON) set_alarm(proc_nr, (unsigned) 0);
|
||||
|
||||
/* Do accounting: fetch usage times and accumulate at parent. */
|
||||
sys_times(proc_nr, t);
|
||||
p_mp = &mproc[rmp->mp_parent]; /* process' parent */
|
||||
p_mp->mp_child_utime = t[2];
|
||||
p_mp->mp_child_stime = t[3];
|
||||
|
||||
/* Tell the kernel and FS that the process is no longer runnable. */
|
||||
tell_fs(EXIT, proc_nr, 0, 0); /* file system can free the proc slot */
|
||||
sys_xit(rmp->mp_parent, proc_nr);
|
||||
@@ -161,7 +168,6 @@ int exit_status; /* the process' exit status (for parent) */
|
||||
/* The process slot can only be freed if the parent has done a WAIT. */
|
||||
rmp->mp_exitstatus = (char) exit_status;
|
||||
|
||||
p_mp = &mproc[rmp->mp_parent]; /* process' parent */
|
||||
pidarg = p_mp->mp_wpid; /* who's being waited for? */
|
||||
parent_waiting = p_mp->mp_flags & WAITING;
|
||||
|
||||
@@ -271,8 +277,10 @@ register struct mproc *child; /* tells which process is exiting */
|
||||
setreply(child->mp_parent, child->mp_pid);
|
||||
parent->mp_flags &= ~WAITING; /* parent no longer waiting */
|
||||
|
||||
/* Release the process table entry. */
|
||||
/* Release the process table entry and reinitialize some field. */
|
||||
child->mp_flags = 0;
|
||||
child->mp_child_utime = 0;
|
||||
child->mp_child_stime = 0;
|
||||
procs_in_use--;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ PUBLIC int do_getset()
|
||||
if (rmp->mp_procgrp == rmp->mp_pid) return(EPERM);
|
||||
rmp->mp_procgrp = rmp->mp_pid;
|
||||
tell_fs(SETSID, who, 0, 0);
|
||||
/*FALL THROUGH*/
|
||||
/* fall through */
|
||||
|
||||
case GETPGRP:
|
||||
r = rmp->mp_procgrp;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "mproc.h"
|
||||
#include "param.h"
|
||||
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/type.h"
|
||||
|
||||
FORWARD _PROTOTYPE( void get_work, (void) );
|
||||
|
||||
@@ -14,6 +14,10 @@ EXTERN struct mproc {
|
||||
pid_t mp_wpid; /* pid this process is waiting for */
|
||||
int mp_parent; /* index of parent process */
|
||||
|
||||
/* Child user and system times. Accounting done on child exit. */
|
||||
clock_t mp_child_utime; /* cumulative user time of children */
|
||||
clock_t mp_child_stime; /* cumulative sys time of children */
|
||||
|
||||
/* Real and effective uids and gids. */
|
||||
uid_t mp_realuid; /* process' real uid */
|
||||
uid_t mp_effuid; /* process' effective uid */
|
||||
@@ -61,3 +65,4 @@ EXTERN struct mproc {
|
||||
#define DONT_SWAP 0x1000 /* never swap out this process */
|
||||
|
||||
#define NIL_MPROC ((struct mproc *) 0)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define reboot_size m1_i2
|
||||
#define svrctl_req m2_i1
|
||||
#define svrctl_argp m2_p1
|
||||
#define stime m2_l1
|
||||
|
||||
/* The following names are synonyms for the variables in a reply message. */
|
||||
#define reply_res m_type
|
||||
@@ -39,6 +40,12 @@
|
||||
#define reply_ptr m2_p1
|
||||
#define reply_mask m2_l1
|
||||
#define reply_trace m2_l2
|
||||
#define reply_time m2_l1
|
||||
#define reply_t1 m4_l1
|
||||
#define reply_t2 m4_l2
|
||||
#define reply_t3 m4_l3
|
||||
#define reply_t4 m4_l4
|
||||
#define reply_t5 m4_l5
|
||||
|
||||
/* The following names are used to inform the FS about certain events. */
|
||||
#define tell_fs_arg1 m1_i1
|
||||
|
||||
@@ -79,6 +79,11 @@ _PROTOTYPE( int do_sigreturn, (void) );
|
||||
_PROTOTYPE( int do_sigsuspend, (void) );
|
||||
_PROTOTYPE( void check_pending, (struct mproc *rmp) );
|
||||
|
||||
/* time.c */
|
||||
_PROTOTYPE( int do_stime, (void) );
|
||||
_PROTOTYPE( int do_time, (void) );
|
||||
_PROTOTYPE( int do_times, (void) );
|
||||
|
||||
/* trace.c */
|
||||
_PROTOTYPE( int do_trace, (void) );
|
||||
_PROTOTYPE( void stop_proc, (struct mproc *rmp, int sig_nr) );
|
||||
|
||||
@@ -27,7 +27,7 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
|
||||
no_sys, /* 10 = unlink */
|
||||
do_waitpid, /* 11 = waitpid */
|
||||
no_sys, /* 12 = chdir */
|
||||
no_sys, /* 13 = time */
|
||||
do_time, /* 13 = time */
|
||||
no_sys, /* 14 = mknod */
|
||||
no_sys, /* 15 = chmod */
|
||||
no_sys, /* 16 = chown */
|
||||
@@ -39,7 +39,7 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
|
||||
no_sys, /* 22 = umount */
|
||||
do_getset, /* 23 = setuid */
|
||||
do_getset, /* 24 = getuid */
|
||||
no_sys, /* 25 = stime */
|
||||
do_stime, /* 25 = stime */
|
||||
do_trace, /* 26 = ptrace */
|
||||
do_alarm, /* 27 = alarm */
|
||||
no_sys, /* 28 = fstat */
|
||||
@@ -57,7 +57,7 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
|
||||
no_sys, /* 40 = rmdir */
|
||||
no_sys, /* 41 = dup */
|
||||
no_sys, /* 42 = pipe */
|
||||
no_sys, /* 43 = times */
|
||||
do_times, /* 43 = times */
|
||||
no_sys, /* 44 = (prof) */
|
||||
no_sys, /* 45 = unused */
|
||||
do_getset, /* 46 = setgid */
|
||||
|
||||
@@ -134,6 +134,7 @@ int what, p1, p2, p3;
|
||||
* tell_fs(SETSID, proc, 0, 0)
|
||||
* tell_fs(SETUID, proc, realuid, effuid)
|
||||
* tell_fs(UNPAUSE, proc, signr, 0)
|
||||
* tell_fs(STIME, time, 0, 0)
|
||||
*/
|
||||
message m;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user