Mostly bugfixes of bugs triggered by the test set.
bugfixes:
SYSTEM:
. removed
rc->p_priv->s_flags = 0;
for the priv struct shared by all user processes in get_priv(). this
should only be done once. doing a SYS_PRIV_USER in sys_privctl()
caused the flags of all user processes to be reset, so they were no
longer PREEMPTIBLE. this happened when RS executed a policy script.
(this broke test1 in the test set)
VFS/MFS:
. chown can change the mode of a file, and chmod arguments are only
part of the full file mode so the full filemode is slightly magic.
changed these calls so that the final modes are returned to VFS, so
that the vnode can be kept up-to-date.
(this broke test11 in the test set)
MFS:
. lookup() checked for sizeof(string) instead of sizeof(user_path),
truncating long path names
(caught by test 23)
. truncate functions neglected to update ctime
(this broke test16)
VFS:
. corner case of an empty filename lookup caused fields of a request
not to be filled in in the lookup functions, not making it clear
that the lookup had failed, causing messages to garbage processes,
causing strange failures.
(caught by test 30)
. trust v_size in vnode when doing reads or writes on non-special
files, truncating i/o where necessary; this is necessary for pipes,
as MFS can't tell when a pipe has been truncated without it being
told explicitly each time.
when the last reader/writer on a pipe closes, tell FS about
the new size using truncate_vn().
(this broke test 25, among others)
. permission check for chdir() had disappeared; added a
forbidden() call
(caught by test 23)
new code, shouldn't change anything:
. introduced RTS_SET, RTS_UNSET, and RTS_ISSET macro's, and their
LOCK variants. These macros set and clear the p_rts_flags field,
causing a lot of duplicated logic like
old_flags = rp->p_rts_flags; /* save value of the flags */
rp->p_rts_flags &= ~NO_PRIV;
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
to change into the simpler
RTS_LOCK_UNSET(rp, NO_PRIV);
so the macros take care of calling dequeue() and enqueue() (or lock_*()),
as the case may be). This makes the code a bit more readable and a
bit less fragile.
. removed return code from do_clocktick in CLOCK as it currently
never replies
. removed some debug code from VFS
. fixed grant debug message in device.c
preemptive checks, tests, changes:
. added return code checks of receive() to SYSTEM and CLOCK
. O_TRUNC should never arrive at MFS (added sanity check and removed
O_TRUNC code)
. user_path declared with PATH_MAX+1 to let it be null-terminated
. checks in MFS to see if strings passed by VFS are null-terminated
IS:
. static irq name table thrown out
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
*/
|
||||
FORWARD _PROTOTYPE( void init_clock, (void) );
|
||||
FORWARD _PROTOTYPE( int clock_handler, (irq_hook_t *hook) );
|
||||
FORWARD _PROTOTYPE( int do_clocktick, (message *m_ptr) );
|
||||
FORWARD _PROTOTYPE( void do_clocktick, (message *m_ptr) );
|
||||
FORWARD _PROTOTYPE( void load_update, (void));
|
||||
|
||||
/* The CLOCK's timers queue. The functions in <timers.h> operate on this.
|
||||
@@ -74,10 +74,13 @@ PUBLIC void clock_task()
|
||||
/* Go get a message. */
|
||||
result = receive(ANY, &m);
|
||||
|
||||
if(result != OK)
|
||||
panic("receive() failed", result);
|
||||
|
||||
/* Handle the request. Only clock ticks are expected. */
|
||||
switch (m.m_type) {
|
||||
case HARD_INT:
|
||||
result = do_clocktick(&m); /* handle clock tick */
|
||||
do_clocktick(&m); /* handle clock tick */
|
||||
break;
|
||||
default: /* illegal request type */
|
||||
kprintf("CLOCK: illegal request %d from %d.\n",
|
||||
@@ -89,7 +92,7 @@ PUBLIC void clock_task()
|
||||
/*===========================================================================*
|
||||
* do_clocktick *
|
||||
*===========================================================================*/
|
||||
PRIVATE int do_clocktick(m_ptr)
|
||||
PRIVATE void do_clocktick(m_ptr)
|
||||
message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Despite its name, this routine is not called on every clock tick. It
|
||||
@@ -103,9 +106,10 @@ message *m_ptr; /* pointer to request message */
|
||||
* place in the queues. As a side-effect a new process will be scheduled.
|
||||
*/
|
||||
if (prev_ptr->p_ticks_left <= 0 && priv(prev_ptr)->s_flags & PREEMPTIBLE) {
|
||||
if(prev_ptr->p_rts_flags == 0) /* if it was runnable .. */
|
||||
lock_dequeue(prev_ptr); /* take it off the queues */
|
||||
lock_enqueue(prev_ptr); /* and reinsert it again */
|
||||
if(prev_ptr->p_rts_flags == 0) { /* if it was runnable .. */
|
||||
lock_dequeue(prev_ptr); /* take it off the queues */
|
||||
lock_enqueue(prev_ptr); /* and reinsert it again */
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if a clock timer expired and run its watchdog function. */
|
||||
@@ -115,8 +119,7 @@ message *m_ptr; /* pointer to request message */
|
||||
TMR_NEVER : clock_timers->tmr_exp_time;
|
||||
}
|
||||
|
||||
/* Inhibit sending a reply. */
|
||||
return(EDONTREPLY);
|
||||
return;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
||||
@@ -150,12 +150,8 @@ PUBLIC void main()
|
||||
}
|
||||
|
||||
/* Set ready. The HARDWARE task is never ready. */
|
||||
if (rp->p_nr != HARDWARE) {
|
||||
rp->p_rts_flags = 0; /* runnable if no flags */
|
||||
lock_enqueue(rp); /* add to scheduling queues */
|
||||
} else {
|
||||
rp->p_rts_flags = NO_PRIORITY; /* prevent from running */
|
||||
}
|
||||
if (rp->p_nr == HARDWARE) RTS_LOCK_SET(rp, NO_PRIORITY);
|
||||
RTS_LOCK_UNSET(rp, SLOT_FREE); /* remove SLOT_FREE and schedule */
|
||||
|
||||
/* Code and data segments must be allocated in protected mode. */
|
||||
alloc_segments(rp);
|
||||
|
||||
@@ -104,7 +104,7 @@ long bit_map; /* notification event set or flags */
|
||||
vir_clicks vlo, vhi; /* virtual clicks containing message to send */
|
||||
|
||||
#if 1
|
||||
if (caller_ptr->p_rts_flags & SLOT_FREE)
|
||||
if (RTS_ISSET(caller_ptr, SLOT_FREE))
|
||||
{
|
||||
kprintf("called by the dead?!?\n");
|
||||
return EINVAL;
|
||||
@@ -243,10 +243,10 @@ int src_dst; /* src or dst process */
|
||||
/* Check whether the last process in the chain has a dependency. If it
|
||||
* has not, the cycle cannot be closed and we are done.
|
||||
*/
|
||||
if (xp->p_rts_flags & RECEIVING) { /* xp has dependency */
|
||||
if (RTS_ISSET(xp, RECEIVING)) { /* xp has dependency */
|
||||
if(xp->p_getfrom_e == ANY) src_dst = ANY;
|
||||
else okendpt(xp->p_getfrom_e, &src_dst);
|
||||
} else if (xp->p_rts_flags & SENDING) { /* xp has dependency */
|
||||
} else if (RTS_ISSET(xp, SENDING)) { /* xp has dependency */
|
||||
okendpt(xp->p_sendto_e, &src_dst);
|
||||
} else {
|
||||
return(0); /* not a deadlock */
|
||||
@@ -289,23 +289,22 @@ unsigned flags; /* system call flags */
|
||||
dst_p = _ENDPOINT_P(dst_e);
|
||||
dst_ptr = proc_addr(dst_p);
|
||||
|
||||
if (dst_ptr->p_rts_flags & NO_ENDPOINT) return EDSTDIED;
|
||||
if (RTS_ISSET(dst_ptr, NO_ENDPOINT)) return EDSTDIED;
|
||||
|
||||
/* Check if 'dst' is blocked waiting for this message. The destination's
|
||||
* SENDING flag may be set when its SENDREC call blocked while sending.
|
||||
*/
|
||||
if ( (dst_ptr->p_rts_flags & (RECEIVING | SENDING)) == RECEIVING &&
|
||||
if ( (RTS_ISSET(dst_ptr, RECEIVING) && !RTS_ISSET(dst_ptr, SENDING)) &&
|
||||
(dst_ptr->p_getfrom_e == ANY
|
||||
|| dst_ptr->p_getfrom_e == caller_ptr->p_endpoint)) {
|
||||
/* Destination is indeed waiting for this message. */
|
||||
CopyMess(caller_ptr->p_nr, caller_ptr, m_ptr, dst_ptr,
|
||||
dst_ptr->p_messbuf);
|
||||
if ((dst_ptr->p_rts_flags &= ~RECEIVING) == 0) enqueue(dst_ptr);
|
||||
RTS_UNSET(dst_ptr, RECEIVING);
|
||||
} else if ( ! (flags & NON_BLOCKING)) {
|
||||
/* Destination is not waiting. Block and dequeue caller. */
|
||||
caller_ptr->p_messbuf = m_ptr;
|
||||
if (caller_ptr->p_rts_flags == 0) dequeue(caller_ptr);
|
||||
caller_ptr->p_rts_flags |= SENDING;
|
||||
RTS_SET(caller_ptr, SENDING);
|
||||
caller_ptr->p_sendto_e = dst_e;
|
||||
|
||||
/* Process is now blocked. Put in on the destination's queue. */
|
||||
@@ -344,7 +343,7 @@ unsigned flags; /* system call flags */
|
||||
else
|
||||
{
|
||||
okendpt(src_e, &src_p);
|
||||
if (proc_addr(src_p)->p_rts_flags & NO_ENDPOINT) return ESRCDIED;
|
||||
if (RTS_ISSET(proc_addr(src_p), NO_ENDPOINT)) return ESRCDIED;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +351,7 @@ unsigned flags; /* system call flags */
|
||||
* The caller's SENDING flag may be set if SENDREC couldn't send. If it is
|
||||
* set, the process should be blocked.
|
||||
*/
|
||||
if (!(caller_ptr->p_rts_flags & SENDING)) {
|
||||
if (!RTS_ISSET(caller_ptr, SENDING)) {
|
||||
|
||||
/* Check if there are pending notifications, except for SENDREC. */
|
||||
if (! (caller_ptr->p_misc_flags & REPLY_PENDING)) {
|
||||
@@ -386,7 +385,7 @@ unsigned flags; /* system call flags */
|
||||
while (*xpp != NIL_PROC) {
|
||||
if (src_e == ANY || src_p == proc_nr(*xpp)) {
|
||||
#if 1
|
||||
if ((*xpp)->p_rts_flags & SLOT_FREE)
|
||||
if (RTS_ISSET(*xpp, SLOT_FREE))
|
||||
{
|
||||
kprintf("listening to the dead?!?\n");
|
||||
return EINVAL;
|
||||
@@ -395,7 +394,7 @@ unsigned flags; /* system call flags */
|
||||
|
||||
/* Found acceptable message. Copy it and update status. */
|
||||
CopyMess((*xpp)->p_nr, *xpp, (*xpp)->p_messbuf, caller_ptr, m_ptr);
|
||||
if (((*xpp)->p_rts_flags &= ~SENDING) == 0) enqueue(*xpp);
|
||||
RTS_UNSET(*xpp, SENDING);
|
||||
*xpp = (*xpp)->p_q_link; /* remove from queue */
|
||||
return(OK); /* report success */
|
||||
}
|
||||
@@ -409,8 +408,7 @@ unsigned flags; /* system call flags */
|
||||
if ( ! (flags & NON_BLOCKING)) {
|
||||
caller_ptr->p_getfrom_e = src_e;
|
||||
caller_ptr->p_messbuf = m_ptr;
|
||||
if (caller_ptr->p_rts_flags == 0) dequeue(caller_ptr);
|
||||
caller_ptr->p_rts_flags |= RECEIVING;
|
||||
RTS_SET(caller_ptr, RECEIVING);
|
||||
return(OK);
|
||||
} else {
|
||||
return(ENOTREADY);
|
||||
@@ -431,7 +429,7 @@ int dst; /* which process to notify */
|
||||
/* Check to see if target is blocked waiting for this message. A process
|
||||
* can be both sending and receiving during a SENDREC system call.
|
||||
*/
|
||||
if ((dst_ptr->p_rts_flags & (RECEIVING|SENDING)) == RECEIVING &&
|
||||
if ( (RTS_ISSET(dst_ptr, RECEIVING) && !RTS_ISSET(dst_ptr, SENDING)) &&
|
||||
! (dst_ptr->p_misc_flags & REPLY_PENDING) &&
|
||||
(dst_ptr->p_getfrom_e == ANY ||
|
||||
dst_ptr->p_getfrom_e == caller_ptr->p_endpoint)) {
|
||||
@@ -443,8 +441,7 @@ int dst; /* which process to notify */
|
||||
BuildMess(&m, proc_nr(caller_ptr), dst_ptr);
|
||||
CopyMess(proc_nr(caller_ptr), proc_addr(HARDWARE), &m,
|
||||
dst_ptr, dst_ptr->p_messbuf);
|
||||
dst_ptr->p_rts_flags &= ~RECEIVING; /* deblock destination */
|
||||
if (dst_ptr->p_rts_flags == 0) enqueue(dst_ptr);
|
||||
RTS_UNSET(dst_ptr, RECEIVING);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <minix/com.h>
|
||||
#include "const.h"
|
||||
#include "priv.h"
|
||||
|
||||
|
||||
struct proc {
|
||||
struct stackframe_s p_reg; /* process' registers saved in stack frame */
|
||||
struct segframe p_seg; /* segment descriptors */
|
||||
@@ -60,6 +60,50 @@ struct proc {
|
||||
#define NO_PRIV 0x80 /* keep forked system process from running */
|
||||
#define NO_ENDPOINT 0x100 /* process cannot send or receive messages */
|
||||
|
||||
/* These runtime flags can be tested and manipulated by these macros. */
|
||||
|
||||
#define RTS_ISSET(rp, f) (((rp)->p_rts_flags & (f)) == (f))
|
||||
|
||||
|
||||
/* Set flag and dequeue if the process was runnable. */
|
||||
#define RTS_SET(rp, f) \
|
||||
do { \
|
||||
if(!(rp)->p_rts_flags) { dequeue(rp); } \
|
||||
(rp)->p_rts_flags |= (f); \
|
||||
} while(0)
|
||||
|
||||
/* Clear flag and enqueue if the process was not runnable but is now. */
|
||||
#define RTS_UNSET(rp, f) \
|
||||
do { \
|
||||
int rts; \
|
||||
rts = (rp)->p_rts_flags; \
|
||||
(rp)->p_rts_flags &= ~(f); \
|
||||
if(rts && !(rp)->p_rts_flags) { enqueue(rp); } \
|
||||
} while(0)
|
||||
|
||||
/* Set flag and dequeue if the process was runnable. */
|
||||
#define RTS_LOCK_SET(rp, f) \
|
||||
do { \
|
||||
if(!(rp)->p_rts_flags) { lock_dequeue(rp); } \
|
||||
(rp)->p_rts_flags |= (f); \
|
||||
} while(0)
|
||||
|
||||
/* Clear flag and enqueue if the process was not runnable but is now. */
|
||||
#define RTS_LOCK_UNSET(rp, f) \
|
||||
do { \
|
||||
int rts; \
|
||||
rts = (rp)->p_rts_flags; \
|
||||
(rp)->p_rts_flags &= ~(f); \
|
||||
if(rts && !(rp)->p_rts_flags) { lock_enqueue(rp); } \
|
||||
} while(0)
|
||||
|
||||
/* Set flags to this value. */
|
||||
#define RTS_LOCK_SETFLAGS(rp, f) \
|
||||
do { \
|
||||
if(!(rp)->p_rts_flags && (f)) { lock_dequeue(rp); } \
|
||||
(rp)->p_rts_flags = (f); \
|
||||
} while(0)
|
||||
|
||||
/* Misc flags */
|
||||
#define REPLY_PENDING 0x01 /* reply to IPC_REQUEST is pending */
|
||||
#define MF_VM 0x08 /* process uses VM */
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "debug.h"
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
#include "proc.h"
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -67,8 +68,9 @@ PUBLIC void sys_task()
|
||||
initialize();
|
||||
|
||||
while (TRUE) {
|
||||
int r;
|
||||
/* Get work. Block and wait until a request message arrives. */
|
||||
receive(ANY, &m);
|
||||
if((r=receive(ANY, &m)) != OK) panic("system: receive() failed", r);
|
||||
sys_call_code = (unsigned) m.m_type;
|
||||
call_nr = sys_call_code - KERNEL_CALL;
|
||||
who_e = m.m_source;
|
||||
@@ -216,7 +218,8 @@ int proc_type; /* system or user process flag */
|
||||
} else {
|
||||
rc->p_priv = &priv[USER_PRIV_ID]; /* use shared slot */
|
||||
rc->p_priv->s_proc_nr = INIT_PROC_NR; /* set association */
|
||||
rc->p_priv->s_flags = 0; /* no initial flags */
|
||||
|
||||
/* s_flags of this shared structure are to be once at system startup. */
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
@@ -292,9 +295,8 @@ int sig_nr; /* signal to be sent, 1 to _NSIG */
|
||||
rp = proc_addr(proc_nr);
|
||||
if (! sigismember(&rp->p_pending, sig_nr)) {
|
||||
sigaddset(&rp->p_pending, sig_nr);
|
||||
if (! (rp->p_rts_flags & SIGNALED)) { /* other pending */
|
||||
if (rp->p_rts_flags == 0) lock_dequeue(rp); /* make not ready */
|
||||
rp->p_rts_flags |= SIGNALED | SIG_PENDING; /* update flags */
|
||||
if (! (RTS_ISSET(rp, SIGNALED))) { /* other pending */
|
||||
RTS_LOCK_SET(rp, SIGNALED | SIG_PENDING);
|
||||
send_sig(PM_PROC_NR, SIGKSIG);
|
||||
}
|
||||
}
|
||||
@@ -473,13 +475,12 @@ register struct proc *rc; /* slot of process to clean up */
|
||||
if(isemptyp(rc)) panic("clear_proc: empty process", proc_nr(rc));
|
||||
|
||||
/* Make sure that the exiting process is no longer scheduled. */
|
||||
if (rc->p_rts_flags == 0) lock_dequeue(rc);
|
||||
rc->p_rts_flags |= NO_ENDPOINT;
|
||||
RTS_LOCK_SET(rc, NO_ENDPOINT);
|
||||
|
||||
/* If the process happens to be queued trying to send a
|
||||
* message, then it must be removed from the message queues.
|
||||
*/
|
||||
if (rc->p_rts_flags & SENDING) {
|
||||
if (RTS_ISSET(rc, SENDING)) {
|
||||
int target_proc;
|
||||
|
||||
okendpt(rc->p_sendto_e, &target_proc);
|
||||
@@ -511,21 +512,20 @@ register struct proc *rc; /* slot of process to clean up */
|
||||
unset_sys_bit(priv(rp)->s_notify_pending, priv(rc)->s_id);
|
||||
|
||||
/* Check if process is receiving from exiting process. */
|
||||
if ((rp->p_rts_flags & RECEIVING) && rp->p_getfrom_e == rc->p_endpoint) {
|
||||
if (RTS_ISSET(rp, RECEIVING) && rp->p_getfrom_e == rc->p_endpoint) {
|
||||
rp->p_reg.retreg = ESRCDIED; /* report source died */
|
||||
rp->p_rts_flags &= ~RECEIVING; /* no longer receiving */
|
||||
RTS_LOCK_UNSET(rp, RECEIVING); /* no longer receiving */
|
||||
#if DEBUG_ENABLE_IPC_WARNINGS
|
||||
kprintf("Proc %d receive dead src %d\n", proc_nr(rp), proc_nr(rc));
|
||||
#endif
|
||||
if (rp->p_rts_flags == 0) lock_enqueue(rp);/* let process run again */
|
||||
}
|
||||
if ((rp->p_rts_flags & SENDING) && rp->p_sendto_e == rc->p_endpoint) {
|
||||
if (RTS_ISSET(rp, SENDING) &&
|
||||
rp->p_sendto_e == rc->p_endpoint) {
|
||||
rp->p_reg.retreg = EDSTDIED; /* report destination died */
|
||||
rp->p_rts_flags &= ~SENDING; /* no longer sending */
|
||||
RTS_LOCK_UNSET(rp, SENDING);
|
||||
#if DEBUG_ENABLE_IPC_WARNINGS
|
||||
kprintf("Proc %d send dead dst %d\n", proc_nr(rp), proc_nr(rc));
|
||||
#endif
|
||||
if (rp->p_rts_flags == 0) lock_enqueue(rp);/* let process run again */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,11 @@ message *m_ptr; /* pointer to request message */
|
||||
return EINVAL;
|
||||
|
||||
rp = proc_addr(proc);
|
||||
if (! (rp->p_rts_flags & SIG_PENDING)) return(EINVAL);
|
||||
if (!RTS_ISSET(rp, SIG_PENDING)) return(EINVAL);
|
||||
|
||||
/* PM has finished one kernel signal. Perhaps process is ready now? */
|
||||
if (! (rp->p_rts_flags & SIGNALED)) /* new signal arrived */
|
||||
if ((rp->p_rts_flags &= ~SIG_PENDING)==0) /* remove pending flag */
|
||||
lock_enqueue(rp); /* ready if no flags */
|
||||
if (!RTS_ISSET(rp, SIGNALED)) /* new signal arrived */
|
||||
RTS_LOCK_UNSET(rp, SIG_PENDING); /* remove pending flag */
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ register message *m_ptr; /* pointer to request message */
|
||||
(LDT_SIZE - EXTRA_LDT_INDEX) * sizeof(rp->p_seg.p_ldt[0]));
|
||||
#endif
|
||||
rp->p_reg.pc = (reg_t) m_ptr->PR_IP_PTR; /* set pc */
|
||||
rp->p_rts_flags &= ~RECEIVING; /* PM does not reply to EXEC call */
|
||||
if (rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
RTS_LOCK_UNSET(rp, RECEIVING); /* PM does not reply to EXEC call */
|
||||
/* Save command name for debugging, ps(1) output, etc. */
|
||||
phys_name = numap_local(who_p, (vir_bytes) m_ptr->PR_NAME_PTR,
|
||||
(vir_bytes) P_NAME_LEN - 1);
|
||||
|
||||
@@ -52,7 +52,6 @@ register struct proc *rc; /* slot of process to clean up */
|
||||
register struct proc **xpp; /* iterate over caller queue */
|
||||
int i;
|
||||
int sys_id;
|
||||
char saved_rts_flags;
|
||||
|
||||
/* Don't clear if already cleared. */
|
||||
if(isemptyp(rc)) return;
|
||||
@@ -63,8 +62,10 @@ register struct proc *rc; /* slot of process to clean up */
|
||||
/* Turn off any alarm timers at the clock. */
|
||||
reset_timer(&priv(rc)->s_alarm_timer);
|
||||
|
||||
/* Make sure that the exiting process is no longer scheduled. */
|
||||
if (rc->p_rts_flags == 0) lock_dequeue(rc);
|
||||
/* Make sure that the exiting process is no longer scheduled,
|
||||
* and mark slot as FREE.
|
||||
*/
|
||||
RTS_LOCK_SETFLAGS(rc, SLOT_FREE);
|
||||
|
||||
/* Check the table with IRQ hooks to see if hooks should be released. */
|
||||
for (i=0; i < NR_IRQ_HOOKS; i++) {
|
||||
@@ -80,8 +81,6 @@ register struct proc *rc; /* slot of process to clean up */
|
||||
* this point. All important fields are reinitialized when the
|
||||
* slots are assigned to another, new process.
|
||||
*/
|
||||
saved_rts_flags = rc->p_rts_flags;
|
||||
rc->p_rts_flags = SLOT_FREE;
|
||||
if (priv(rc)->s_flags & SYS_PROC) priv(rc)->s_proc_nr = NONE;
|
||||
|
||||
/* Clean up virtual memory */
|
||||
|
||||
@@ -26,7 +26,7 @@ register message *m_ptr; /* pointer to request message */
|
||||
register struct proc *rpc; /* child process pointer */
|
||||
struct proc *rpp; /* parent process pointer */
|
||||
struct mem_map *map_ptr; /* virtual address of map inside caller (PM) */
|
||||
int i, gen;
|
||||
int i, gen, r;
|
||||
int p_proc;
|
||||
|
||||
if(!isokendpt(m_ptr->PR_ENDPT, &p_proc))
|
||||
@@ -51,10 +51,6 @@ register message *m_ptr; /* pointer to request message */
|
||||
rpc->p_nr = m_ptr->PR_SLOT; /* this was obliterated by copy */
|
||||
rpc->p_endpoint = _ENDPOINT(gen, rpc->p_nr); /* new endpoint of slot */
|
||||
|
||||
/* Only one in group should have SIGNALED, child doesn't inherit tracing. */
|
||||
rpc->p_rts_flags &= ~(SIGNALED | SIG_PENDING | P_STOP);
|
||||
sigemptyset(&rpc->p_pending);
|
||||
|
||||
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;
|
||||
@@ -79,7 +75,13 @@ register message *m_ptr; /* pointer to request message */
|
||||
m_ptr->PR_ENDPT = rpc->p_endpoint;
|
||||
|
||||
/* Install new map */
|
||||
return newmap(rpc, map_ptr);
|
||||
r = newmap(rpc, map_ptr);
|
||||
|
||||
/* Only one in group should have SIGNALED, child doesn't inherit tracing. */
|
||||
RTS_LOCK_UNSET(rpc, (SIGNALED | SIG_PENDING | P_STOP));
|
||||
sigemptyset(&rpc->p_pending);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* USE_FORK */
|
||||
|
||||
@@ -29,12 +29,12 @@ 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_rts_flags & SIGNALED) {
|
||||
if (RTS_ISSET(rp, SIGNALED)) {
|
||||
/* store signaled process' endpoint */
|
||||
m_ptr->SIG_ENDPT = rp->p_endpoint;
|
||||
m_ptr->SIG_MAP = rp->p_pending; /* pending signals map */
|
||||
sigemptyset(&rp->p_pending); /* ball is in PM's court */
|
||||
rp->p_rts_flags &= ~SIGNALED; /* blocked by SIG_PENDING */
|
||||
RTS_LOCK_UNSET(rp, SIGNALED); /* blocked by SIG_PENDING */
|
||||
return(OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ message *m_ptr; /* pointer to request message */
|
||||
register struct proc *rp; /* process whose map is to be loaded */
|
||||
struct mem_map *map_ptr; /* virtual address of map inside caller (PM) */
|
||||
phys_bytes src_phys; /* physical address of map at the PM */
|
||||
int old_flags; /* value of flags before modification */
|
||||
int proc;
|
||||
|
||||
map_ptr = (struct mem_map *) m_ptr->PR_MEM_PTR;
|
||||
@@ -41,7 +40,6 @@ struct mem_map *map_ptr; /* virtual address of map inside caller (PM) */
|
||||
{
|
||||
/* Fetch the memory map from PM. */
|
||||
phys_bytes src_phys; /* physical address of map at the PM */
|
||||
int old_flags; /* value of flags before modification */
|
||||
int proc;
|
||||
|
||||
/* Copy the map from PM. */
|
||||
@@ -52,8 +50,6 @@ struct mem_map *map_ptr; /* virtual address of map inside caller (PM) */
|
||||
(phys_bytes)sizeof(rp->p_memmap));
|
||||
|
||||
alloc_segments(rp);
|
||||
old_flags = rp->p_rts_flags; /* save the previous value of the flags */
|
||||
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -28,10 +28,8 @@ PUBLIC int do_nice(message *m_ptr)
|
||||
rp = proc_addr(proc_nr);
|
||||
|
||||
if (pri == PRIO_STOP) {
|
||||
|
||||
/* Take process off the scheduling queues. */
|
||||
if(rp->p_rts_flags == 0) lock_dequeue(rp);
|
||||
rp->p_rts_flags |= NO_PRIORITY;
|
||||
RTS_LOCK_SET(rp, NO_PRIORITY);
|
||||
return(OK);
|
||||
}
|
||||
else if (pri >= PRIO_MIN && pri <= PRIO_MAX) {
|
||||
@@ -48,10 +46,9 @@ PUBLIC int do_nice(message *m_ptr)
|
||||
/* Make sure the process is not running while changing its priority.
|
||||
* Put the process back in its new queue if it is runnable.
|
||||
*/
|
||||
if(rp->p_rts_flags == 0) lock_dequeue(rp);
|
||||
rp->p_rts_flags &= ~NO_PRIORITY;
|
||||
RTS_LOCK_SET(rp, NO_PRIORITY);
|
||||
rp->p_max_priority = rp->p_priority = new_q;
|
||||
if (! rp->p_rts_flags) lock_enqueue(rp);
|
||||
RTS_LOCK_UNSET(rp, NO_PRIORITY);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ message *m_ptr; /* pointer to request message */
|
||||
register struct priv *sp;
|
||||
int proc_nr;
|
||||
int priv_id;
|
||||
int old_flags;
|
||||
int i;
|
||||
phys_bytes caller_phys, kernel_phys;
|
||||
struct io_range io_range;
|
||||
@@ -49,7 +48,7 @@ message *m_ptr; /* pointer to request message */
|
||||
switch(m_ptr->CTL_REQUEST)
|
||||
{
|
||||
case SYS_PRIV_INIT:
|
||||
if (! (rp->p_rts_flags & NO_PRIV)) return(EPERM);
|
||||
if (! RTS_ISSET(rp, NO_PRIV)) return(EPERM);
|
||||
|
||||
/* Make sure this process has its own privileges structure. This may
|
||||
* fail, since there are only a limited number of system processes.
|
||||
@@ -136,25 +135,17 @@ message *m_ptr; /* pointer to request message */
|
||||
}
|
||||
|
||||
/* Done. Privileges have been set. Allow process to run again. */
|
||||
old_flags = rp->p_rts_flags; /* save value of the flags */
|
||||
rp->p_rts_flags &= ~NO_PRIV;
|
||||
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
RTS_LOCK_UNSET(rp, NO_PRIV);
|
||||
return(OK);
|
||||
case SYS_PRIV_USER:
|
||||
if (! (rp->p_rts_flags & NO_PRIV)) return(EPERM);
|
||||
|
||||
/* Make this process an ordinary user process.
|
||||
*/
|
||||
/* Make this process an ordinary user process. */
|
||||
if (!RTS_ISSET(rp, NO_PRIV)) return(EPERM);
|
||||
if ((i=get_priv(rp, 0)) != OK) return(i);
|
||||
|
||||
/* Done. Privileges have been set. Allow process to run again. */
|
||||
old_flags = rp->p_rts_flags; /* save value of the flags */
|
||||
rp->p_rts_flags &= ~NO_PRIV;
|
||||
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
RTS_LOCK_UNSET(rp, NO_PRIV);
|
||||
return(OK);
|
||||
|
||||
case SYS_PRIV_ADD_IO:
|
||||
if (rp->p_rts_flags & NO_PRIV)
|
||||
if (RTS_ISSET(rp, NO_PRIV))
|
||||
return(EPERM);
|
||||
|
||||
/* Only system processes get I/O resources? */
|
||||
@@ -180,7 +171,7 @@ message *m_ptr; /* pointer to request message */
|
||||
return OK;
|
||||
|
||||
case SYS_PRIV_ADD_MEM:
|
||||
if (rp->p_rts_flags & NO_PRIV)
|
||||
if (RTS_ISSET(rp, NO_PRIV))
|
||||
return(EPERM);
|
||||
|
||||
/* Only system processes get memory resources? */
|
||||
@@ -208,7 +199,7 @@ message *m_ptr; /* pointer to request message */
|
||||
return OK;
|
||||
|
||||
case SYS_PRIV_ADD_IRQ:
|
||||
if (rp->p_rts_flags & NO_PRIV)
|
||||
if (RTS_ISSET(rp, NO_PRIV))
|
||||
return(EPERM);
|
||||
|
||||
/* Only system processes get IRQs? */
|
||||
|
||||
@@ -61,7 +61,7 @@ endpoint_t *e_granter; /* new granter (magic grants) */
|
||||
* EINVAL for grant-out-of-range, in case this turns out to be
|
||||
* interesting information.)
|
||||
*/
|
||||
if((granter_proc->p_rts_flags & NO_PRIV) || !(priv(granter_proc)) ||
|
||||
if(RTS_ISSET(granter_proc, NO_PRIV) || !(priv(granter_proc)) ||
|
||||
priv(granter_proc)->s_grant_table < 1) {
|
||||
kprintf("grant verify failed in ep %d proc %d: "
|
||||
"no priv table, or no grant table\n",
|
||||
|
||||
@@ -22,7 +22,7 @@ message *m_ptr;
|
||||
rp = proc_addr(who_p);
|
||||
|
||||
/* Copy grant table set in priv. struct. */
|
||||
if ((rp->p_rts_flags & NO_PRIV) || !(priv(rp))) {
|
||||
if (RTS_ISSET(rp, NO_PRIV) || !(priv(rp))) {
|
||||
r = EPERM;
|
||||
} else {
|
||||
_K_SET_GRANT_TABLE(rp,
|
||||
|
||||
@@ -93,10 +93,10 @@ message *m_ptr; /* pointer to request message */
|
||||
rp->p_reg.pc = (reg_t) smsg.sm_sighandler;
|
||||
|
||||
/* Reschedule if necessary. */
|
||||
if(rp->p_rts_flags & NO_PRIORITY) {
|
||||
rp->p_rts_flags &= ~NO_PRIORITY;
|
||||
if (rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
} else kprintf("system: warning: sigsend a running process\n");
|
||||
if(RTS_ISSET(rp, NO_PRIORITY))
|
||||
RTS_LOCK_UNSET(rp, NO_PRIORITY);
|
||||
else
|
||||
kprintf("system: warning: sigsend a running process\n");
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ register message *m_ptr;
|
||||
if (isemptyp(rp)) return(EIO);
|
||||
switch (tr_request) {
|
||||
case T_STOP: /* stop process */
|
||||
if (rp->p_rts_flags == 0) lock_dequeue(rp);
|
||||
rp->p_rts_flags |= P_STOP;
|
||||
RTS_LOCK_SET(rp, P_STOP);
|
||||
rp->p_reg.psw &= ~TRACEBIT; /* clear trace bit */
|
||||
return(OK);
|
||||
|
||||
@@ -126,15 +125,13 @@ register message *m_ptr;
|
||||
break;
|
||||
|
||||
case T_RESUME: /* resume execution */
|
||||
rp->p_rts_flags &= ~P_STOP;
|
||||
if (rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
RTS_LOCK_UNSET(rp, P_STOP);
|
||||
m_ptr->CTL_DATA = 0;
|
||||
break;
|
||||
|
||||
case T_STEP: /* set trace bit */
|
||||
rp->p_reg.psw |= TRACEBIT;
|
||||
rp->p_rts_flags &= ~P_STOP;
|
||||
if (rp->p_rts_flags == 0) lock_enqueue(rp);
|
||||
RTS_LOCK_UNSET(rp, P_STOP);
|
||||
m_ptr->CTL_DATA = 0;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user