Cleaned up process table structure: removed p_type, p_pendcount.

Removed stop sequence when MINIX is shut down.
Disabled send mask checks --- to be replaced by proper mechanism.
Fixed bug relating to 'shutdown -x'.
Simplified clock accounting of realtime.
Updated Makefiles for mkdept script.
This commit is contained in:
Jorrit Herder
2005-06-24 16:24:40 +00:00
parent 5654996c07
commit a408699ce0
19 changed files with 153 additions and 630 deletions

View File

@@ -3,14 +3,6 @@
# Directories
u = /usr
i = $u/include
s = $i/sys
h = $i/minix
m = $i/ibm
l = $u/lib
n = $i/net
g = $n/gen
x = .
k = ..
# Programs, flags, etc.
CC = exec cc
@@ -20,35 +12,19 @@ CFLAGS = -I$i
LDFLAGS = -i
SYS = clock.o copying.o debugging.o devio.o irqctl.o proctl.o \
sysctl.o misc.o sigctl.o tracing.o \
sysctl.o misc.o sigctl.o tracing.o
# What to make.
all build: $(SYS)
aal cr system.a $(SYS)
clean:
rm -f *.a *.o *.bak
# Dependencies from src/kernel/kernel.h
a = $h/config.h $h/const.h $h/type.h $h/ipc.h \
$i/string.h $i/limits.h $i/errno.h $i/stddef.h \
$s/types.h \
$m/portio.h \
$k/proc.h $k/const.h $k/type.h $k/proto.h $k/glo.h
depend:
/usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
# Dependencies from src/kernel/system.h
b = $k/system.h $h/com.h $k/proc.h
clock.o: $a $b
copying.o: $a $b
debugging.o: $a $b
devio.o: $a $b $h/devio.h
irqctl.o: $a $b
misc.o: $a $b $i/unistd.h
proctl.o: $a $b $k/sendmask.h $k/protect.h $i/signal.h
sigctl.o: $a $b $i/signal.h $s/sigcontext.h
sysctl.o: $a $b $s/svrctl.h $k/sendmask.h
tracing.o: $a $b $s/ptrace.h
# Include generated dependencies.
include .depend

View File

@@ -157,7 +157,7 @@ check_runqueues(char *when)
}
for (xp = BEG_PROC_ADDR; xp < END_PROC_ADDR; ++xp) {
if(isalivep(xp) && xp->p_ready && !xp->p_found) {
if(! isempty(xp) && xp->p_ready && ! xp->p_found) {
kprintf("scheduling error: ready not on queue: %s\n", (karg_t) when);
panic("ready proc not on scheduling queue", NO_NUM);
if(l++ > PROCLIMIT) { panic("loop in proc.t?", NO_NUM); }

View File

@@ -39,7 +39,7 @@ message *m_ptr; /* pointer to request message */
int how = m_ptr->ABRT_HOW;
if (how == RBT_MONITOR) {
/* The monitor is to run user specified instructions. */
/* The monitor is to run the specified instructions. */
int proc_nr = m_ptr->ABRT_MON_PROC;
int length = m_ptr->ABRT_MON_LEN + 1;
vir_bytes src_vir = (vir_bytes) m_ptr->ABRT_MON_ADDR;
@@ -47,7 +47,7 @@ message *m_ptr; /* pointer to request message */
/* Validate length and address of shutdown code before copying. */
if (length > kinfo.params_size || src_phys == 0)
kprintf("Warning, skipping shutdown code\n", NO_NUM);
phys_copy(vir2phys("delay;boot"), kinfo.params_base, 11);
else
phys_copy(src_phys, kinfo.params_base, (phys_bytes) length);
}

View File

@@ -47,15 +47,13 @@ register message *m_ptr; /* pointer to request message */
#endif
rpc->p_nr = m_ptr->PR_PROC_NR; /* this was obliterated by copy */
rpc->p_ntf_q = NULL; /* remove pending notifications */
/* Only one in group should have SIGNALED, child doesn't inherit tracing. */
rpc->p_flags |= NO_MAP; /* inhibit process from running */
rpc->p_flags &= ~(PENDING | SIG_PENDING | P_STOP);
/* Only 1 in group should have PENDING, child does not inherit trace status*/
rpc->p_flags &= ~(SIGNALED | SIG_PENDING | P_STOP);
sigemptyset(&rpc->p_pending);
rpc->p_pendcount = 0;
rpc->p_reg.retreg = 0; /* child sees pid = 0 to know it is child */
rpc->p_reg.retreg = 0; /* child sees pid = 0 to know it is child */
rpc->p_user_time = 0; /* set all the accounting times to 0 */
rpc->p_sys_time = 0;
@@ -175,7 +173,6 @@ register message *m_ptr; /* pointer to request message */
*
* The parameters for this system call are:
* m1_i1: PR_PROC_NR (slot number of exiting process)
* m1_i2: PR_PPROC_NR (slot number of parent process)
*/
@@ -186,36 +183,27 @@ register message *m_ptr; /* pointer to request message */
PUBLIC int do_xit(m_ptr)
message *m_ptr; /* pointer to request message */
{
/* Handle sys_exit. A user process has exited (the PM sent the request).
/* Handle sys_exit. A user process has exited or a system process requests
* to exit. Only the PM can request other process slots to be cleared.
* The routine to clean up a process table slot cancels outstanding timers,
* possibly removes the process from the message queues, and resets certain
* process table fields to the default values.
*/
register struct proc *rc;
int exit_proc_nr;
/* Get a pointer to the process that exited. */
exit_proc_nr = m_ptr->PR_PROC_NR;
if (exit_proc_nr == SELF) exit_proc_nr = m_ptr->m_source;
if (! isokprocn(exit_proc_nr)) return(EINVAL);
rc = proc_addr(exit_proc_nr);
/* Determine what process exited. */
if (PM_PROC_NR == m_ptr->m_source) {
exit_proc_nr = m_ptr->PR_PROC_NR; /* get exiting process */
if (exit_proc_nr != SELF) { /* PM tries to exit self */
if (! isokprocn(exit_proc_nr)) return(EINVAL);
clear_proc(exit_proc_nr); /* exit a user process */
return(OK); /* report back to PM */
}
}
#if DEAD_CODE
/* 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(15, "do_xit");
rp->child_utime += rc->user_time + rc->child_utime;
rp->child_stime += rc->sys_time + rc->child_stime;
unlock(15);
}
#endif
/* 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.
*/
clear_proc(exit_proc_nr);
return(OK); /* tell PM that cleanup succeeded */
/* The PM or some other system process requested to be exited. */
clear_proc(m_ptr->m_source);
return(EDONTREPLY);
}

View File

@@ -33,11 +33,11 @@ message *m_ptr; /* pointer to request message */
/* Find the next process with pending signals. */
for (rp = BEG_USER_ADDR; rp < END_PROC_ADDR; rp++) {
if (rp->p_flags & PENDING) {
if (rp->p_flags & SIGNALED) {
m_ptr->SIG_PROC = rp->p_nr;
m_ptr->SIG_MAP = rp->p_pending;
sigemptyset(&rp->p_pending); /* ball is in PM's court */
rp->p_flags &= ~PENDING; /* blocked by SIG_PENDING */
rp->p_flags &= ~SIGNALED; /* blocked by SIG_PENDING */
return(OK);
}
}
@@ -57,12 +57,12 @@ message *m_ptr; /* pointer to request message */
register struct proc *rp;
rp = proc_addr(m_ptr->SIG_PROC);
if (isemptyp(rp)) return(EINVAL); /* process already dead? */
if (isemptyp(rp)) return(EINVAL); /* process already dead? */
/* PM has finished one kernel signal. Perhaps process is ready now? */
if (rp->p_pendcount != 0 && --rp->p_pendcount == 0
&& (rp->p_flags &= ~SIG_PENDING) == 0)
lock_ready(rp);
if (! (rp->p_flags & SIGNALED)) /* new signal arrived */
if ((rp->p_flags &= ~SIG_PENDING) == 0) /* remove pending flag */
lock_ready(rp); /* ready if no flags */
return(OK);
}

View File

@@ -1,14 +1,3 @@
/* The system call implemented in this file:
* m_type: SYS_EXIT
*
* The parameters for this system call are:
* m1_i1: EXIT_STATUS (exit status, 0 if normal exit)
*
* Author:
* Jorrit N. Herder <jnherder@cs.vu.nl>
*/
#include "../kernel.h"
#include "../ipc.h"
#include "../system.h"
@@ -16,36 +5,6 @@
#include <sys/svrctl.h>
#include "../sendmask.h"
/*===========================================================================*
* do_exit *
*===========================================================================*/
PUBLIC int do_exit(m_ptr)
message *m_ptr; /* pointer to request message */
{
/* Handle sys_exit. A server or driver wants to exit. This may happen
* on a panic, but also is done when MINIX is shutdown.
*/
int proc_nr = m_ptr->m_source; /* can only exit own process */
if (m_ptr->EXIT_STATUS != 0) {
kprintf("WARNING: system process %d exited with an error.\n", proc_nr );
}
/* 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 reset important process table fields.
*/
clear_proc(proc_nr);
/* If the shutdown sequence is active, see if it was awaiting the shutdown
* of this system service. If so, directly continue the stop sequence.
*/
if (shutting_down && shutdown_process == proc_addr(proc_nr)) {
stop_sequence(&shutdown_timer);
}
return(EDONTREPLY); /* no reply is sent */
}
/* The system call implemented in this file:
@@ -98,7 +57,6 @@ message *m_ptr; /* pointer to request message */
}
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);
send_mask_allow(proc_addr(PM_PROC_NR)->p_sendmask, proc_nr);