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:
Jorrit Herder
2005-05-31 09:50:51 +00:00
parent cd72f80639
commit 322ec9ef8b
34 changed files with 141 additions and 143 deletions

View File

@@ -199,7 +199,7 @@ irq_hook_t *hook;
* due to a race, since this will only delay the high-level
* processing by one tick, or call the high level unnecessarily.
* The variables which are changed require more care:
* rp->user_time, rp->sys_time:
* rp->p_user_time, rp->p_sys_time:
* These are protected by explicit locks in system.c. They are
* not properly protected in dmp.c (the increment here is not
* atomic) but that hardly matters.
@@ -239,8 +239,8 @@ irq_hook_t *hook;
now = realtime + pending_ticks;
/* Update administration. */
proc_ptr->user_time += ticks;
if (proc_ptr != bill_ptr) bill_ptr->sys_time += ticks;
proc_ptr->p_user_time += ticks;
if (proc_ptr != bill_ptr) bill_ptr->p_sys_time += ticks;
/* Check if do_clocktick() must be called. Done for alarms and scheduling.
* If bill_ptr == prev_ptr, there are no ready users so don't need sched().

View File

@@ -24,6 +24,9 @@
/* How many bytes for the kernel stack. Space allocated in mpx.s. */
#define K_STACK_BYTES 1024
/* How long should the process names be in the kernel? */
#define P_NAME_LEN 8
/* How many bytes for (port,value)-pairs vector to copy in. */
#define VDEVIO_BUF_SIZE 128

View File

@@ -5,10 +5,25 @@
#define FRESH_ANSWER 0x20 /* ignore pending notifications as answer */
/* (default behaviour for SENDREC calls) */
/* System calls (numbers passed when trapping to the kernel) */
/* System calls (numbers passed when trapping to the kernel). */
#define ECHO 0 /* function code for echoing messages */
#define SEND 1 /* function code for sending messages */
#define RECEIVE 2 /* function code for receiving messages */
#define SENDREC 3 /* function code for SEND + RECEIVE */
#define NOTIFY 4 /* function code for notifications */
#if 0
/* Bit map operations used to bits of simple bit mask. */
#define set_bit(mask, n) ((mask) |= (1 << (n)))
#define clear_bit(mask, n) ((mask) &= ~(1 << (n)))
#define isset_bit(mask, n) ((mask) & (1 << (n)))
#define empty_mask (0)
#define filled_mask (~0)
#endif
/* Call masks indicating which system calls a process can make. */
#define EMPTY_CALL_MASK (0)
#define USER_CALL_MASK (1 << SENDREC)
#define SYSTEM_CALL_MASK (~0)

View File

@@ -77,9 +77,11 @@ PUBLIC void main()
for (i=0; i < IMAGE_SIZE; ++i) {
ttp = &image[i]; /* t's task attributes */
rp = proc_addr(ttp->proc_nr); /* t's process slot */
kstrncpy(rp->p_name, ttp->proc_name, PROC_NAME_LEN); /* set name */
kstrncpy(rp->p_name, ttp->proc_name, P_NAME_LEN); /* set name */
rp->p_name[P_NAME_LEN-1] = '\0'; /* just for safety */
rp->p_type = ttp->type; /* type of process */
rp->p_priority = ttp->priority; /* scheduling priority */
rp->p_call_mask = ttp->call_mask; /* allowed system calls */
rp->p_sendmask = ttp->sendmask; /* sendmask protection */
if (i-NR_TASKS < 0) { /* part of the kernel? */
if (ttp->stksize > 0) { /* HARDWARE stack size is 0 */

View File

@@ -111,10 +111,12 @@ message *m_ptr; /* pointer to message in the caller's space */
vir_bytes vb; /* message buffer pointer as vir_bytes */
vir_clicks vlo, vhi; /* virtual clicks containing message to send */
/* Calls directed to the kernel may only be sendrec(), because tasks always
* reply and may not block if the caller doesn't do receive().
/* Check if the process has privileges for the requested call. Calls to the
* kernel may only be SENDREC, because tasks always reply and may not block
* if the caller doesn't do receive().
*/
if (iskernel(src_dst) && function != SENDREC) return(ECALLDENIED);
if (! (caller_ptr->p_call_mask & (1 << function)) ||
iskernel(src_dst) && function != SENDREC) return(ECALLDENIED);
/* Verify that requested source and/ or destination is a valid process. */
if (! isoksrc_dst(src_dst) && function != ECHO) return(EBADSRCDST);

View File

@@ -38,11 +38,12 @@ struct proc {
char p_flags; /* SENDING, RECEIVING, etc. */
char p_type; /* task, system, driver, server, user, idle */
char p_priority; /* scheduling priority */
char p_call_mask; /* bit map with allowed system call traps */
clock_t user_time; /* user time in ticks */
clock_t sys_time; /* sys time in ticks */
clock_t child_utime; /* cumulative user time of children */
clock_t child_stime; /* cumulative sys time of children */
send_mask_t p_sendmask; /* mask indicating to whom proc may send */
clock_t p_user_time; /* user time in ticks */
clock_t p_sys_time; /* sys time in ticks */
timer_t p_signalrm; /* signal alarm timer */
timer_t p_flagalrm; /* flag alarm timer */
@@ -55,12 +56,11 @@ struct proc {
message *p_messbuf; /* pointer to message buffer */
proc_nr_t p_getfrom; /* from whom does process want to receive? */
proc_nr_t p_sendto; /* to whom does process want to send? */
send_mask_t p_sendmask; /* mask indicating to whom proc may send */
sigset_t p_pending; /* bit map for pending signals */
unsigned p_pendcount; /* count of pending and unfinished signals */
char p_name[PROC_NAME_LEN]; /* name of the process, including \0 */
char p_name[P_NAME_LEN]; /* name of the process, including \0 */
#if ENABLE_K_DEBUGGING
int p_ready, p_found;

View File

@@ -253,7 +253,7 @@ int proc_nr; /* slot of process to clean up */
}
/* Now clean up the process table entry. Reset to defaults. */
kstrncpy(rc->p_name, "<noname>", PROC_NAME_LEN); /* unset name */
kstrncpy(rc->p_name, "<none>", P_NAME_LEN); /* unset name */
sigemptyset(&rc->p_pending); /* remove pending signals */
rc->p_pendcount = 0; /* all signals are gone */
rc->p_flags = 0; /* remove all flags */

View File

@@ -5,8 +5,6 @@
* m4_l1: T_PROC_NR (get info for this process)
* m4_l1: T_USER_TIME (return values ...)
* m4_l2: T_SYSTEM_TIME
* m4_l3: T_CHILD_UTIME
* m4_l4: T_CHILD_STIME
* m4_l5: T_BOOT_TICKS
*/
@@ -31,11 +29,9 @@ register message *m_ptr; /* pointer to request message */
rp = proc_addr(m_ptr->T_PROC_NR);
lock(); /* halt the volatile time counters in rp */
m_ptr->T_USER_TIME = rp->user_time;
m_ptr->T_SYSTEM_TIME = rp->sys_time;
m_ptr->T_USER_TIME = rp->p_user_time;
m_ptr->T_SYSTEM_TIME = rp->p_sys_time;
unlock();
m_ptr->T_CHILD_UTIME = rp->child_utime;
m_ptr->T_CHILD_STIME = rp->child_stime;
}
m_ptr->T_BOOT_TICKS = get_uptime();
return(OK);

View File

@@ -57,10 +57,8 @@ register message *m_ptr; /* pointer to request message */
rpc->p_pendcount = 0;
rpc->p_reg.retreg = 0; /* child sees pid = 0 to know it is child */
rpc->user_time = 0; /* set all the accounting times to 0 */
rpc->sys_time = 0;
rpc->child_utime = 0;
rpc->child_stime = 0;
rpc->p_user_time = 0; /* set all the accounting times to 0 */
rpc->p_sys_time = 0;
return(OK);
}
@@ -139,7 +137,6 @@ register message *m_ptr; /* pointer to request message */
reg_t sp; /* new sp */
phys_bytes phys_name;
char *np;
#define NLEN (sizeof(rp->p_name)-1)
rp = proc_addr(m_ptr->PR_PROC_NR);
assert(isuserp(rp));
@@ -163,11 +160,13 @@ register message *m_ptr; /* pointer to request message */
/* Save command name for debugging, ps(1) output, etc. */
phys_name = numap_local(m_ptr->m_source, (vir_bytes) m_ptr->PR_NAME_PTR,
(vir_bytes) NLEN);
(vir_bytes) P_NAME_LEN - 1);
if (phys_name != 0) {
phys_copy(phys_name, vir2phys(rp->p_name), (phys_bytes) NLEN);
phys_copy(phys_name, vir2phys(rp->p_name), (phys_bytes) P_NAME_LEN - 1);
for (np = rp->p_name; (*np & BYTE) >= ' '; np++) {}
*np = 0;
*np = 0; /* mark end */
} else {
kstrncpy(rp->p_name, "<unset>", P_NAME_LEN);
}
return(OK);
}
@@ -201,17 +200,6 @@ message *m_ptr; /* pointer to request message */
if (! isokprocn(exit_proc_nr)) return(EINVAL);
rc = proc_addr(exit_proc_nr);
/* If this is a user process and the PM passed in a valid parent process,
* accumulate the child times at the parent.
*/
if (isuserp(rc) && isokprocn(m_ptr->PR_PPROC_NR)) {
rp = proc_addr(m_ptr->PR_PPROC_NR);
lock();
rp->child_utime += rc->user_time + rc->child_utime;
rp->child_stime += rc->sys_time + rc->child_stime;
unlock();
}
/* Now call the routine to clean up of the process table slot. This cancels
* outstanding timers, possibly removes the process from the message queues,
* and resets important process table fields.

View File

@@ -10,6 +10,7 @@
*/
#include "../kernel.h"
#include "../ipc.h"
#include "../system.h"
#include "../protect.h"
#include <sys/svrctl.h>
@@ -97,6 +98,7 @@ message *m_ptr; /* pointer to request message */
/* fall through */
}
case SYSSENDMASK: {
rp->p_call_mask = SYSTEM_CALL_MASK;
rp->p_type = P_SERVER;
rp->p_sendmask = ALLOW_ALL_MASK;
send_mask_allow(proc_addr(USR8139)->p_sendmask, proc_nr);

View File

@@ -32,6 +32,7 @@
#include "kernel.h"
#include "proc.h"
#include "ipc.h"
#include "sendmask.h"
#include <minix/com.h>
#include <ibm/int86.h>
@@ -61,31 +62,31 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
* routine and stack size is also provided.
*/
PUBLIC struct system_image image[] = {
{ IDLE, idle_task, P_IDLE, PPRI_IDLE, IDLE_STACK, IDLE_SENDMASK, "IDLE" },
{ CLOCK, clock_task, P_TASK, PPRI_TASK, CLOCK_STACK, CLOCK_SENDMASK, "CLOCK" },
{ SYSTASK, sys_task, P_TASK, PPRI_TASK, SYS_STACK, SYSTEM_SENDMASK, "SYS" },
{ HARDWARE, 0, P_TASK, PPRI_TASK, HARDWARE_STACK,HARDWARE_SENDMASK,"HARDWAR" },
{ PM_PROC_NR, 0, P_SERVER, PPRI_NORMAL, 0, PM_SENDMASK, "PM" },
{ FS_PROC_NR, 0, P_SERVER, PPRI_NORMAL, 0, FS_SENDMASK, "FS" },
{ IS_PROC_NR, 0, P_SYSTEM, PPRI_HIGH, 0, IS_SENDMASK, "IS" },
{ TTY, 0, P_SYSTEM, PPRI_HIGHER, 0, TTY_SENDMASK, "TTY" },
{ MEMORY, 0, P_DRIVER, PPRI_HIGH, 0, MEM_SENDMASK, "MEMORY" },
{ IDLE, idle_task, P_IDLE, PPRI_IDLE, IDLE_STACK, EMPTY_CALL_MASK, IDLE_SENDMASK, "IDLE" },
{ CLOCK, clock_task, P_TASK, PPRI_TASK, CLOCK_STACK, SYSTEM_CALL_MASK, CLOCK_SENDMASK, "CLOCK" },
{ SYSTASK, sys_task, P_TASK, PPRI_TASK, SYS_STACK, SYSTEM_CALL_MASK, SYSTEM_SENDMASK, "SYS" },
{ HARDWARE, 0, P_TASK, PPRI_TASK, HARDWARE_STACK, EMPTY_CALL_MASK, HARDWARE_SENDMASK,"HARDW." },
{ PM_PROC_NR, 0, P_SERVER, PPRI_NORMAL, 0, SYSTEM_CALL_MASK, PM_SENDMASK, "PM" },
{ FS_PROC_NR, 0, P_SERVER, PPRI_NORMAL, 0, SYSTEM_CALL_MASK, FS_SENDMASK, "FS" },
{ IS_PROC_NR, 0, P_SYSTEM, PPRI_HIGH, 0, SYSTEM_CALL_MASK, IS_SENDMASK, "IS" },
{ TTY, 0, P_SYSTEM, PPRI_HIGHER, 0, SYSTEM_CALL_MASK, TTY_SENDMASK, "TTY" },
{ MEMORY, 0, P_DRIVER, PPRI_HIGH, 0, SYSTEM_CALL_MASK, MEM_SENDMASK, "MEMORY" },
#if ENABLE_AT_WINI
{ AT_WINI, 0, P_DRIVER, PPRI_HIGH, 0, AT_SENDMASK, "AT_WINI" },
{ AT_WINI, 0, P_DRIVER, PPRI_HIGH, 0, SYSTEM_CALL_MASK, AT_SENDMASK, "AT_WINI" },
#endif
#if ENABLE_FLOPPY
{ FLOPPY, 0, P_DRIVER, PPRI_HIGH, 0, FLOPPY_SENDMASK, "FLOPPY" },
{ FLOPPY, 0, P_DRIVER, PPRI_HIGH, 0, SYSTEM_CALL_MASK, FLOPPY_SENDMASK, "FLOPPY" },
#endif
#if ENABLE_PRINTER
{ PRINTER, 0, P_DRIVER, PPRI_NORMAL, 0, PRN_SENDMASK, "PRINTER" },
{ PRINTER, 0, P_DRIVER, PPRI_NORMAL, 0, SYSTEM_CALL_MASK, PRN_SENDMASK, "PRINTER" },
#endif
#if ENABLE_RTL8139
{ USR8139, 0, P_DRIVER, PPRI_HIGH, 0, RTL8139_SENDMASK, "RTL8139" },
{ USR8139, 0, P_DRIVER, PPRI_HIGH, 0, SYSTEM_CALL_MASK, RTL8139_SENDMASK, "RTL8139" },
#endif
#if ENABLE_FXP
{ FXP, 0, P_DRIVER, PPRI_HIGH, 0, FXP_SENDMASK, "FXP" },
{ FXP, 0, P_DRIVER, PPRI_HIGH, 0, SYSTEM_CALL_MASK, FXP_SENDMASK, "FXP" },
#endif
{ INIT_PROC_NR, 0, P_USER, PPRI_USER, 0, INIT_SENDMASK, "INIT" },
{ INIT_PROC_NR, 0, P_USER, PPRI_USER, 0, USER_CALL_MASK, INIT_SENDMASK, "INIT" },
};
/* Verify the size of the system image table at compile time. If the number

View File

@@ -22,8 +22,9 @@ struct system_image {
int type; /* type of process */
int priority; /* scheduling priority */
int stksize; /* stack size for tasks */
char call_mask; /* allowed system calls */
send_mask_t sendmask; /* send mask protection */
char proc_name[PROC_NAME_LEN]; /* name in process table */
char proc_name[P_NAME_LEN]; /* name in process table */
};
struct memory {