*===========================================================================*/
static char *flags_str(int flags)
{
- static char str[13];
+ static char str[12];
str[0] = (flags & WAITING) ? 'W' : '-';
str[1] = (flags & ZOMBIE) ? 'Z' : '-';
str[2] = (flags & ALARM_ON) ? 'A' : '-';
str[3] = (flags & EXITING) ? 'E' : '-';
str[4] = (flags & TRACE_STOPPED) ? 'T' : '-';
str[5] = (flags & SIGSUSPENDED) ? 'U' : '-';
- str[6] = (flags & REPLY) ? 'R' : '-';
- str[7] = (flags & VFS_CALL) ? 'F' : '-';
- str[8] = (flags & PROC_STOPPED) ? 's' : '-';
- str[9] = (flags & PRIV_PROC) ? 'p' : '-';
- str[10] = (flags & PARTIAL_EXEC) ? 'x' : '-';
- str[11] = (flags & DELAY_CALL) ? 'd' : '-';
- str[12] = '\0';
+ str[6] = (flags & VFS_CALL) ? 'F' : '-';
+ str[7] = (flags & PROC_STOPPED) ? 's' : '-';
+ str[8] = (flags & PRIV_PROC) ? 'p' : '-';
+ str[9] = (flags & PARTIAL_EXEC) ? 'x' : '-';
+ str[10] = (flags & DELAY_CALL) ? 'd' : '-';
+ str[11] = '\0';
return str;
}
}
printf("Process manager (PM) process table dump\n");
- printf("-process- -nr-pnr-tnr- --pid--ppid--pgrp- -uid-- -gid-- -nice- -flags------\n");
+ printf("-process- -nr-pnr-tnr- --pid--ppid--pgrp- -uid-- -gid-- -nice- -flags-----\n");
for (i=prev_i; i<NR_PROCS; i++) {
mp = &mproc[i];
if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
sig_proc(rmc, SIGSTOP, TRUE /*trace*/, FALSE /* ksig */);
/* Wakeup the newly created process */
- setreply(rmc-mproc, OK);
+ reply(rmc-mproc, OK);
return rmc->mp_pid;
}
{
/* Wake up the tracer, completing the ptrace(T_EXIT) call */
mproc[rmp->mp_tracer].mp_reply.reply_trace = 0;
- setreply(rmp->mp_tracer, OK);
+ reply(rmp->mp_tracer, OK);
}
/* Clean up if the parent has collected the exit status */
/* Wake up the parent by sending the reply message. */
exitstatus = (child->mp_exitstatus << 8) | (child->mp_sigstatus & 0377);
parent->mp_reply.reply_res2 = exitstatus;
- setreply(child->mp_parent, child->mp_pid);
+ reply(child->mp_parent, child->mp_pid);
parent->mp_flags &= ~WAITING; /* parent no longer waiting */
child->mp_flags &= ~ZOMBIE; /* child no longer a zombie */
child->mp_flags |= TOLD_PARENT; /* avoid informing parent twice */
exitstatus = (child->mp_exitstatus << 8) | (child->mp_sigstatus & 0377);
tracer->mp_reply.reply_res2 = exitstatus;
- setreply(child->mp_tracer, child->mp_pid);
+ reply(child->mp_tracer, child->mp_pid);
tracer->mp_flags &= ~WAITING; /* tracer no longer waiting */
child->mp_flags &= ~TRACE_ZOMBIE; /* child no longer zombie to tracer */
child->mp_flags |= ZOMBIE; /* child is now zombie to parent */
*
* The entry points into this file are:
* main: starts PM running
- * setreply: set the reply to be sent to process making an PM system call
+ * reply: send a reply to a process making a PM system call
*/
#include "pm.h"
EXTERN unsigned long calls_stats[NCALLS];
#endif
-static void sendreply(void);
static int get_nice_value(int queue);
static void handle_vfs_reply(void);
/* SEF functions and variables. */
static void sef_local_startup(void);
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
-static int sef_cb_signal_manager(endpoint_t target, int signo);
/*===========================================================================*
* main *
expire_timers(m_in.NOTIFY_TIMESTAMP);
}
- /* done, send reply and continue */
- sendreply();
+ /* done, continue */
continue;
}
}
/* Send reply. */
- if (result != SUSPEND) setreply(who_p, result);
- sendreply();
+ if (result != SUSPEND) reply(who_p, result);
}
return(OK);
}
/* No live update support for now. */
/* Register signal callbacks. */
- sef_setcb_signal_manager(sef_cb_signal_manager);
+ sef_setcb_signal_manager(process_ksig);
/* Let SEF perform startup. */
sef_startup();
}
/*===========================================================================*
- * sef_cb_signal_manager *
+ * reply *
*===========================================================================*/
-static int sef_cb_signal_manager(endpoint_t target, int signo)
-{
-/* Process signal on behalf of the kernel. */
- int r;
-
- r = process_ksig(target, signo);
- sendreply();
-
- return r;
-}
-
-/*===========================================================================*
- * setreply *
- *===========================================================================*/
-void setreply(proc_nr, result)
+void reply(proc_nr, result)
int proc_nr; /* process to reply to */
int result; /* result of call (usually OK or error #) */
{
-/* Fill in a reply message to be sent later to a user process. System calls
- * may occasionally fill in other fields, this is only for the main return
- * value, and for setting the "must send reply" flag.
+/* Send a reply to a user process. System calls may occasionally fill in other
+ * fields, this is only for the main return value and for sending the reply.
*/
- register struct mproc *rmp = &mproc[proc_nr];
+ struct mproc *rmp;
+ int r;
if(proc_nr < 0 || proc_nr >= NR_PROCS)
- panic("setreply arg out of range: %d", proc_nr);
+ panic("reply arg out of range: %d", proc_nr);
+ rmp = &mproc[proc_nr];
rmp->mp_reply.reply_res = result;
- rmp->mp_flags |= REPLY; /* reply pending */
-}
-/*===========================================================================*
- * sendreply *
- *===========================================================================*/
-static void sendreply()
-{
- int proc_nr;
- int s;
- struct mproc *rmp;
-
- /* Send out all pending reply messages, including the answer to
- * the call just made above.
- */
- for (proc_nr=0, rmp=mproc; proc_nr < NR_PROCS; proc_nr++, rmp++) {
- /* In the meantime, the process may have been killed by a
- * signal (e.g. if a lethal pending signal was unblocked)
- * without the PM realizing it. If the slot is no longer in
- * use or the process is exiting, don't try to reply.
- */
- if ((rmp->mp_flags & (REPLY | IN_USE | EXITING)) ==
- (REPLY | IN_USE)) {
- s=sendnb(rmp->mp_endpoint, &rmp->mp_reply);
- if (s != OK) {
- printf("PM can't reply to %d (%s): %d\n",
- rmp->mp_endpoint, rmp->mp_name, s);
- }
- rmp->mp_flags &= ~REPLY;
- }
- }
+ if ((r = sendnb(rmp->mp_endpoint, &rmp->mp_reply)) != OK)
+ printf("PM can't reply to %d (%s): %d\n", rmp->mp_endpoint,
+ rmp->mp_name, r);
}
/*===========================================================================*
case PM_SETGID_REPLY:
case PM_SETGROUPS_REPLY:
/* Wake up the original caller */
- setreply(rmp-mproc, OK);
+ reply(rmp-mproc, OK);
break;
case PM_SETSID_REPLY:
/* Wake up the original caller */
- setreply(rmp-mproc, rmp->mp_procgrp);
+ reply(rmp-mproc, rmp->mp_procgrp);
break;
/* Wake up the parent with a failed fork (unless dead) */
if (!new_parent)
- setreply(rmp->mp_parent, -1);
+ reply(rmp->mp_parent, -1);
}
else {
/* Wake up the child */
- setreply(proc_n, OK);
+ reply(proc_n, OK);
/* Wake up the parent, unless the parent is already dead */
if (!new_parent)
- setreply(rmp->mp_parent, rmp->mp_pid);
+ reply(rmp->mp_parent, rmp->mp_pid);
}
break;