Renamed system library functionality.
Updated debug dumps of IS server.
This commit is contained in:
parent
279250889f
commit
570eac1f53
23 changed files with 168 additions and 93 deletions
|
@ -61,14 +61,17 @@ PUBLIC void main()
|
|||
super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */
|
||||
|
||||
/* Check for special control messages first. */
|
||||
#if DEAD_CODE
|
||||
if (call_nr == HARD_STOP) {
|
||||
do_sync();
|
||||
sys_exit(0); /* never returns */
|
||||
} else if(call_nr == SYN_ALARM) {
|
||||
} else
|
||||
#endif
|
||||
if(call_nr == SYN_ALARM) {
|
||||
/* Not a user request; system has expired one of our timers,
|
||||
* currently only in use for select(). Check it.
|
||||
*/
|
||||
fs_expire_timers(m_in.NOTIFY_ARG);
|
||||
fs_expire_timers(m_in.NOTIFY_TIMESTAMP);
|
||||
} else if(call_nr == DEV_SELECTED) {
|
||||
/* Device notify()s us of fd that has become usable. */
|
||||
select_notified(&m_in);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* 6 june 2005 Created (Ben Gras)
|
||||
*/
|
||||
|
||||
|
||||
/* TODO: check if close (pipe?) / exit works;
|
||||
* some printf()s are serious errors;
|
||||
* check combinations of cases listen in open group select
|
||||
|
@ -21,11 +20,10 @@
|
|||
#define DEBUG_SELECT 0
|
||||
|
||||
#include "fs.h"
|
||||
#include "dmap.h"
|
||||
#include "select.h"
|
||||
#include "file.h"
|
||||
#include "inode.h"
|
||||
#include "fs_timers.h"
|
||||
#include "dmap.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
*/
|
||||
|
||||
#include "fs.h"
|
||||
#include "fs_timers.h"
|
||||
|
||||
#define VERBOSE 1
|
||||
#define VERBOSE 0
|
||||
|
||||
#include <timers.h>
|
||||
#include <minix/syslib.h>
|
||||
|
@ -17,7 +16,7 @@ PUBLIC void fs_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
|
|||
int r;
|
||||
clock_t now, old_head = 0, new_head;
|
||||
|
||||
if((r = sys_getuptime(&now)) != OK)
|
||||
if((r = getuptime(&now)) != OK)
|
||||
panic(__FILE__, "FS couldn't get uptime from system task.", NO_NUM);
|
||||
|
||||
tmr_inittimer(tp);
|
||||
|
@ -45,8 +44,8 @@ PUBLIC void fs_expire_timers(clock_t now)
|
|||
if(new_head > 0) {
|
||||
if(sys_syncalrm(SELF, new_head, 1) != OK)
|
||||
panic(__FILE__, "FS expire timer couldn't set synchronous alarm.", NO_NUM);
|
||||
else
|
||||
#if VERBOSE
|
||||
else
|
||||
printf("timers: after expiry, set synalarm to %d\n", new_head);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ PUBLIC time_t clock_time()
|
|||
register int k;
|
||||
clock_t uptime;
|
||||
|
||||
if ( (k=sys_getuptime(&uptime)) != OK) panic(__FILE__,"clock_time err", k);
|
||||
if ( (k=getuptime(&uptime)) != OK) panic(__FILE__,"clock_time err", k);
|
||||
return( (time_t) (boottime + (uptime/HZ)));
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ PUBLIC time_t get_time()
|
|||
curr_time= mess.NEW_TIME;
|
||||
#else /* Minix 3 */
|
||||
int s;
|
||||
if ((s=sys_getuptime(&curr_time)) != OK)
|
||||
if ((s=getuptime(&curr_time)) != OK)
|
||||
ip_panic(("can't read clock"));
|
||||
#endif
|
||||
assert(curr_time >= prev_time);
|
||||
|
|
|
@ -103,7 +103,6 @@ PUBLIC void main()
|
|||
u8_t randbits[32];
|
||||
struct timeval tv;
|
||||
|
||||
printf("Hello, in inet\n");
|
||||
#if DEBUG
|
||||
printf("Starting inet...\n");
|
||||
printf("%s\n", version);
|
||||
|
@ -247,18 +246,11 @@ PUBLIC void main()
|
|||
mq_free(mq);
|
||||
}
|
||||
#else /* Minix 3 */
|
||||
else if (mq->mq_mess.m_type & NOTIFICATION)
|
||||
{
|
||||
if (mq->mq_mess.m_type == SYN_ALARM)
|
||||
else if (mq->mq_mess.m_type == SYN_ALARM)
|
||||
{
|
||||
clck_tick(&mq->mq_mess);
|
||||
mq_free(mq);
|
||||
}
|
||||
else if (mq->mq_mess.m_type == HARD_STOP)
|
||||
{
|
||||
sys_exit(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ Copyright 1995 Philip Homburg
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/utils.h>
|
||||
#include <minix/syslib.h>
|
||||
#include "inet_config.h"
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "is.h"
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/type.h"
|
||||
|
||||
/*==========================================================================*
|
||||
|
@ -20,8 +21,6 @@ PRIVATE void log_message(char *buf)
|
|||
|
||||
_sendrec(LOG_PROC_NR, &m);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,9 +123,7 @@ PUBLIC int do_diagnostics(message *m)
|
|||
}
|
||||
|
||||
if(i > 0) {
|
||||
/* This is safe; if i were too large,
|
||||
* this would have been done above.
|
||||
*/
|
||||
/* This is safe; above code ensures i doesn't exceed upper bound. */
|
||||
diagbuf[i] = '\0';
|
||||
log_message(diagbuf);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ PUBLIC int do_fkey_pressed(message *m)
|
|||
if (pressed(F1)) proctab_dmp();
|
||||
if (pressed(F2)) memmap_dmp();
|
||||
if (pressed(F3)) image_dmp();
|
||||
if (pressed(F4)) sendmask_dmp();
|
||||
if (pressed(F4)) privileges_dmp();
|
||||
if (pressed(F5)) monparams_dmp();
|
||||
if (pressed(F6)) irqtab_dmp();
|
||||
if (pressed(F7)) kmessages_dmp();
|
||||
|
@ -42,17 +42,15 @@ PUBLIC int do_fkey_pressed(message *m)
|
|||
if (pressed(F12)) sched_dmp();
|
||||
|
||||
if (pressed(F9)) {
|
||||
printf("IS server going into infinite loop, press F9 to break\n");
|
||||
printf("Five times any key is fine as well ...\n");
|
||||
s = 0;
|
||||
printf("IS server going into infinite loop... hit 5x a function key\n");
|
||||
printf("Five times a function key is fine as well ...\n");
|
||||
while(TRUE) {
|
||||
if (OK == nb_receive(ANY, m)) {
|
||||
s ++;
|
||||
if (pressed(F9) || s >= 5 ) break;
|
||||
else printf("IS server in infinite loop, press F9 to break\n");
|
||||
if (s++ >= 5 ) break;
|
||||
}
|
||||
}
|
||||
printf("IS server back to normal ... \n");
|
||||
return(EDONTREPLY);
|
||||
}
|
||||
|
||||
/* Also check Shift F1-F6 keys. */
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
#include <timers.h>
|
||||
#include <ibm/interrupt.h>
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/debug.h"
|
||||
#include "../../kernel/type.h"
|
||||
#include "../../kernel/proc.h"
|
||||
#include "../../kernel/sendmask.h"
|
||||
|
||||
#define click_to_round_k(n) \
|
||||
((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
|
||||
|
@ -20,7 +21,8 @@ FORWARD _PROTOTYPE( char *proc_name, (int proc_nr) );
|
|||
* so that most macros and definitions from proc.h also apply here.
|
||||
*/
|
||||
PUBLIC struct proc proc[NR_TASKS + NR_PROCS];
|
||||
PUBLIC struct system_image image[IMAGE_SIZE];
|
||||
PUBLIC struct priv priv[NR_SYS_PROCS];
|
||||
PUBLIC struct system_image image[NR_BOOT_PROCS];
|
||||
|
||||
|
||||
|
||||
|
@ -29,15 +31,15 @@ PUBLIC struct system_image image[IMAGE_SIZE];
|
|||
*===========================================================================*/
|
||||
PUBLIC void timing_dmp()
|
||||
{
|
||||
#if ! ENABLE_LOCK_TIMING
|
||||
printf("Enable the ENABLE_LOCK_TIMING definition in <minix/config.h>\n");
|
||||
#if ! DEBUG_TIME_LOCKS
|
||||
printf("Enable the DEBUG_TIME_LOCKS definition in src/kernel/config.h\n");
|
||||
#else
|
||||
static struct lock_timedata timingdata[TIMING_CATEGORIES];
|
||||
static struct lock_timingdata timingdata[TIMING_CATEGORIES];
|
||||
int r, c, f, skipped = 0, printed = 0, maxlines = 23, x = 0;
|
||||
static int offsetlines = 0;
|
||||
|
||||
if ((r = sys_getlocktimings(timingdata)) != OK) {
|
||||
report("warning: couldn't get copy of lock timings", r);
|
||||
if ((r = sys_getlocktimings(&timingdata[0])) != OK) {
|
||||
report("IS","warning: couldn't get copy of lock timings", r);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -190,10 +192,10 @@ PUBLIC void image_dmp()
|
|||
}
|
||||
printf("Image table dump showing all processes included in system image.\n");
|
||||
printf("---name-- -nr- -flags- -q- ----pc- -stack- ------sendmask-------\n");
|
||||
for (i=0; i<IMAGE_SIZE; i++) {
|
||||
for (i=0; i<NR_BOOT_PROCS; i++) {
|
||||
ip = &image[i];
|
||||
for (j=-NR_TASKS; j<INIT_PROC_NR+2; j++)
|
||||
maskstr[j+NR_TASKS] = (isallowed(ip->sendmask, j)) ? '1' : '0';
|
||||
maskstr[j+NR_TASKS] = '0';
|
||||
maskstr[j+NR_TASKS] = '\0';
|
||||
printf("%8s %4d 0x%02x %3d %7lu %7lu %s\n",
|
||||
ip->proc_name, ip->proc_nr, ip->flags, ip->priority,
|
||||
|
@ -293,13 +295,59 @@ PUBLIC void kenv_dmp()
|
|||
printf("- nr_tasks: %3u\n", kinfo.nr_tasks);
|
||||
printf("- release: %.6s\n", kinfo.release);
|
||||
printf("- version: %.6s\n", kinfo.version);
|
||||
#if ENABLE_K_LOCKCHECK
|
||||
#if DEBUG_LOCK_CHECK
|
||||
printf("- relocking: %d\n", kinfo.relocking);
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* privileges_dmp *
|
||||
*===========================================================================*/
|
||||
PUBLIC void privileges_dmp()
|
||||
{
|
||||
register struct proc *rp;
|
||||
static struct proc *oldrp = BEG_PROC_ADDR;
|
||||
register struct priv *sp;
|
||||
int r, i,j, n = 0;
|
||||
|
||||
/* First obtain a fresh copy of the current process and system table. */
|
||||
if ((r = sys_getprivtab(priv)) != OK) {
|
||||
report("IS","warning: couldn't get copy of system privileges table", r);
|
||||
return;
|
||||
}
|
||||
if ((r = sys_getproctab(proc)) != OK) {
|
||||
report("IS","warning: couldn't get copy of process table", r);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\n--nr-id-name---- -sanity- -flags- -sc-\n");
|
||||
|
||||
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
|
||||
if (isemptyp(rp)) continue;
|
||||
if (++n > 23) break;
|
||||
if (proc_nr(rp) == IDLE) printf("(%2d) ", proc_nr(rp));
|
||||
else if (proc_nr(rp) < 0) printf("[%2d] ", proc_nr(rp));
|
||||
else printf(" %2d ", proc_nr(rp));
|
||||
r = -1;
|
||||
for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++)
|
||||
if (sp->s_proc_nr == rp->p_nr) { r ++; break; }
|
||||
if (r == -1) {
|
||||
printf("... warning, no privileges found!\n");
|
||||
continue;
|
||||
}
|
||||
printf("(%02u) %-7.7s %3x %02.2u",
|
||||
sp->s_id,
|
||||
rp->p_name,
|
||||
sp->s_flags, sp->s_call_mask
|
||||
);
|
||||
printf("\n");
|
||||
}
|
||||
if (rp == END_PROC_ADDR) rp = BEG_PROC_ADDR; else printf("--more--\r");
|
||||
oldrp = rp;
|
||||
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sendmask_dmp *
|
||||
|
@ -322,6 +370,7 @@ PUBLIC void sendmask_dmp()
|
|||
printf("The rows of bits indicate to which processes each process may send.");
|
||||
printf("\n\n");
|
||||
|
||||
#if DEAD_CODE
|
||||
printf(" ");
|
||||
for (j=proc_nr(BEG_PROC_ADDR); j< INIT_PROC_NR+1; j++) {
|
||||
printf("%3d", j);
|
||||
|
@ -346,6 +395,7 @@ PUBLIC void sendmask_dmp()
|
|||
if (rp == END_PROC_ADDR) { printf("\n"); rp = BEG_PROC_ADDR; }
|
||||
else printf("--more--\r");
|
||||
oldrp = rp;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -369,7 +419,7 @@ PUBLIC void proctab_dmp()
|
|||
return;
|
||||
}
|
||||
|
||||
printf("\n--nr-name-flags-prior-quant-##-sc- -user---sys- -text---data---size- -rts flags-\n");
|
||||
printf("\n--nr-name---- -prior-quant-##- -user---sys- -text---data---size- -rts flags-\n");
|
||||
|
||||
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
|
||||
if (isemptyp(rp)) continue;
|
||||
|
@ -381,13 +431,11 @@ PUBLIC void proctab_dmp()
|
|||
if (proc_nr(rp) == IDLE) printf("(%2d) ", proc_nr(rp));
|
||||
else if (proc_nr(rp) < 0) printf("[%2d] ", proc_nr(rp));
|
||||
else printf(" %2d ", proc_nr(rp));
|
||||
printf("%-7.7s %2x %02u/%02u %02d/%02d %02u %02.2x %6lu%6lu %6uK%6uK%6uK %3x",
|
||||
printf(" %-7.7s %02u/%02u %02d/%02d %02u %6lu%6lu %6uK%6uK%6uK %3x",
|
||||
rp->p_name,
|
||||
rp->p_flags,
|
||||
rp->p_priority, rp->p_max_priority,
|
||||
rp->p_sched_ticks, rp->p_quantum_size,
|
||||
rp->p_full_quantums,
|
||||
(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),
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "is.h"
|
||||
#include "../pm/mproc.h"
|
||||
#include <timers.h>
|
||||
|
||||
|
||||
PUBLIC struct mproc mproc[NR_PROCS];
|
||||
|
|
|
@ -62,15 +62,12 @@ PUBLIC void main(void)
|
|||
case FKEY_PRESSED:
|
||||
result = do_fkey_pressed(&m_in);
|
||||
break;
|
||||
case HARD_STOP:
|
||||
sys_exit(0);
|
||||
/* never reached */
|
||||
continue;
|
||||
default:
|
||||
default: {
|
||||
printf("Warning, IS got unexpected request %d from %d\n",
|
||||
m_in.m_type, m_in.m_source);
|
||||
result = EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally send reply message, unless disabled. */
|
||||
if (result != EDONTREPLY) {
|
||||
|
@ -88,10 +85,10 @@ int sig; /* signal number */
|
|||
{
|
||||
/* Expect a SIGTERM signal when this server must shutdown. */
|
||||
if (sig == SIGTERM) {
|
||||
printf("Shutting down IS server.\n");
|
||||
printf("Shutting down IS server due to SIGTERM.\n");
|
||||
exit(0);
|
||||
} else {
|
||||
printf("IS got unknown signal\n");
|
||||
printf("IS got signal %d\n", sig);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,15 +103,12 @@ PRIVATE void init_server()
|
|||
int i, s;
|
||||
struct sigaction sigact;
|
||||
|
||||
#if DEAD_CODE
|
||||
/* Install signal handler.*/
|
||||
sigact.sa_handler = signal_handler;
|
||||
sigact.sa_mask = ~0; /* block all other signals */
|
||||
sigact.sa_flags = 0; /* default behaviour */
|
||||
printf("IS calls sigaction()\n");
|
||||
if (sigaction(SIGTERM, &sigact, NULL) != OK)
|
||||
report("IS","warning, sigaction() failed", errno);
|
||||
#endif
|
||||
|
||||
/* Set key mappings. IS takes all of F1-F12 and Shift+F1-F6 . */
|
||||
fkeys = sfkeys = 0;
|
||||
|
@ -122,9 +116,6 @@ PRIVATE void init_server()
|
|||
for (i=1; i<= 6; i++) bit_set(sfkeys, i);
|
||||
if ((s=fkey_map(&fkeys, &sfkeys)) != OK)
|
||||
report("IS", "warning, sendrec failed:", s);
|
||||
|
||||
/* Display status message ... */
|
||||
report("IS", "information service is alive and kicking", NO_NUM);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
|
@ -18,6 +18,7 @@ _PROTOTYPE( int do_fkey_pressed, (message *m) );
|
|||
/* dmp_kernel.c */
|
||||
_PROTOTYPE( void proctab_dmp, (void) );
|
||||
_PROTOTYPE( void memmap_dmp, (void) );
|
||||
_PROTOTYPE( void privileges_dmp, (void) );
|
||||
_PROTOTYPE( void sendmask_dmp, (void) );
|
||||
_PROTOTYPE( void image_dmp, (void) );
|
||||
_PROTOTYPE( void irqtab_dmp, (void) );
|
||||
|
|
|
@ -13,13 +13,13 @@ CC = exec cc
|
|||
CFLAGS = -I$i
|
||||
LDFLAGS = -i
|
||||
|
||||
OBJ = main.o forkexit.o break.o exec.o time.o \
|
||||
OBJ = main.o forkexit.o break.o exec.o time.o timers.o \
|
||||
signal.o alloc.o utility.o table.o trace.o getset.o misc.o
|
||||
|
||||
# build local binary
|
||||
all build: $(SERVER)
|
||||
$(SERVER): $(OBJ)
|
||||
$(CC) -o $@ $(LDFLAGS) $(OBJ) -lsys -lutils
|
||||
$(CC) -o $@ $(LDFLAGS) $(OBJ) -lsys -lutils -ltimers
|
||||
install -S 256w $@
|
||||
|
||||
# install with other servers
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "mproc.h"
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/type.h"
|
||||
|
||||
#define NR_HOLES (2*NR_PROCS) /* max # entries in hole table */
|
||||
|
|
|
@ -371,7 +371,7 @@ phys_bytes tot_bytes; /* total memory to allocate, including gap */
|
|||
base += bss_offset;
|
||||
bytes -= bss_offset;
|
||||
|
||||
if ((s=sys_physzero(base, bytes)) != OK) {
|
||||
if ((s=sys_memset(0, base, bytes)) != OK) {
|
||||
panic(__FILE__,"new_mem can't zero", s);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ int exit_status; /* the process' exit status (for parent) */
|
|||
/* Tell the kernel and FS that the process is no longer runnable. */
|
||||
DEBUG(proc_nr == PRINTER, printf("PM: telling FS and kernel about xit...\n"));
|
||||
tell_fs(EXIT, proc_nr, 0, 0); /* file system can free the proc slot */
|
||||
sys_xit(proc_nr);
|
||||
sys_exit(proc_nr);
|
||||
|
||||
/* Pending reply messages for the dead process cannot be delivered. */
|
||||
rmp->mp_flags &= ~REPLY;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "param.h"
|
||||
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/type.h"
|
||||
|
||||
FORWARD _PROTOTYPE( void get_work, (void) );
|
||||
|
@ -51,10 +52,9 @@ PUBLIC void main()
|
|||
get_work(); /* wait for an PM system call */
|
||||
|
||||
/* Check for system notifications first. Special cases. */
|
||||
if (call_nr == HARD_STOP) { /* MINIX is shutting down */
|
||||
check_sig(-1, SIGKILL); /* kill all processes */
|
||||
sys_exit(0);
|
||||
/* never reached */
|
||||
if (call_nr == SYN_ALARM) {
|
||||
pm_expire_timers(m_in.NOTIFY_TIMESTAMP);
|
||||
result = SUSPEND; /* don't reply */
|
||||
} else if (call_nr == KSIG_PENDING) { /* signals pending */
|
||||
(void) ksig_pending();
|
||||
result = SUSPEND; /* don't reply */
|
||||
|
@ -137,7 +137,7 @@ PRIVATE void pm_init()
|
|||
{
|
||||
/* Initialize the process manager. */
|
||||
int key, i, s;
|
||||
static struct system_image image[IMAGE_SIZE];
|
||||
static struct system_image image[NR_BOOT_PROCS];
|
||||
register struct system_image *ip;
|
||||
static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
|
||||
SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 };
|
||||
|
@ -150,6 +150,11 @@ PRIVATE void pm_init()
|
|||
struct mem_map mem_map[NR_LOCAL_SEGS];
|
||||
struct memory mem_chunks[NR_MEMS];
|
||||
|
||||
/* Initialize process table, including timers. */
|
||||
for (rmp=&mproc[0]; rmp<&mproc[NR_PROCS]; rmp++) {
|
||||
tmr_inittimer(&rmp->mp_timer);
|
||||
}
|
||||
|
||||
/* Build the set of signals which cause core dumps, and the set of signals
|
||||
* that are by default ignored.
|
||||
*/
|
||||
|
@ -182,7 +187,7 @@ PRIVATE void pm_init()
|
|||
if (OK != (s=sys_getimage(image)))
|
||||
panic(__FILE__,"PM: warning, couldn't get image table: %d\n", s);
|
||||
procs_in_use = 0; /* start populating table */
|
||||
for (ip = &image[0]; ip < &image[IMAGE_SIZE]; ip++) {
|
||||
for (ip = &image[0]; ip < &image[NR_BOOT_PROCS]; ip++) {
|
||||
if (ip->proc_nr >= 0) { /* task have negative nrs */
|
||||
procs_in_use += 1; /* found user process */
|
||||
|
||||
|
@ -223,8 +228,6 @@ PRIVATE void pm_init()
|
|||
|
||||
mproc[PM_PROC_NR].mp_pid = PM_PID;
|
||||
mproc[PM_PROC_NR].mp_parent = PM_PROC_NR;
|
||||
sigfillset(&mproc[PM_PROC_NR].mp_ignore);
|
||||
sigfillset(&mproc[PM_PROC_NR].mp_sigmask);
|
||||
|
||||
/* Tell FS that no more system processes follow and synchronize. */
|
||||
mess.PR_PROC_NR = NONE;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* systems have tables that are also indexed by process, with the contents
|
||||
* of corresponding slots referring to the same process in all three.
|
||||
*/
|
||||
#include <timers.h>
|
||||
|
||||
EXTERN struct mproc {
|
||||
struct mem_map mp_seg[NR_LOCAL_SEGS]; /* points to text, data, stack */
|
||||
|
@ -37,6 +38,7 @@ EXTERN struct mproc {
|
|||
sigset_t mp_sigpending; /* pending signals to be handled */
|
||||
struct sigaction mp_sigact[_NSIG + 1]; /* as in sigaction(2) */
|
||||
vir_bytes mp_sigreturn; /* address of C library __sigreturn function */
|
||||
struct timer mp_timer; /* watchdog timer for alarm(2) */
|
||||
|
||||
/* Backwards compatibility for signals. */
|
||||
sighandler_t mp_func; /* all sigs vectored to a single user fcn */
|
||||
|
|
|
@ -5,6 +5,8 @@ struct stat;
|
|||
struct mem_map;
|
||||
struct memory;
|
||||
|
||||
#include <timers.h>
|
||||
|
||||
/* alloc.c */
|
||||
_PROTOTYPE( phys_clicks alloc_mem, (phys_clicks clicks) );
|
||||
_PROTOTYPE( void free_mem, (phys_clicks base, phys_clicks clicks) );
|
||||
|
@ -88,6 +90,12 @@ _PROTOTYPE( int do_time, (void) );
|
|||
_PROTOTYPE( int do_times, (void) );
|
||||
_PROTOTYPE( int do_gettimeofday, (void) );
|
||||
|
||||
/* timers.c */
|
||||
_PROTOTYPE( void pm_set_timer, (timer_t *tp, int delta,
|
||||
tmr_func_t watchdog, int arg));
|
||||
_PROTOTYPE( void pm_expire_timers, (clock_t now));
|
||||
_PROTOTYPE( void pm_cancel_timer, (timer_t *tp));
|
||||
|
||||
/* trace.c */
|
||||
_PROTOTYPE( int do_trace, (void) );
|
||||
_PROTOTYPE( void stop_proc, (struct mproc *rmp, int sig_nr) );
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#define NEW_AL 1
|
||||
/* This file handles signals, which are asynchronous events and are generally
|
||||
* a messy and unpleasant business. Signals can be generated by the KILL
|
||||
* system call, or from the keyboard (SIGINT) or from the clock (SIGALRM).
|
||||
|
@ -36,7 +37,8 @@
|
|||
|
||||
FORWARD _PROTOTYPE( void dump_core, (struct mproc *rmp) );
|
||||
FORWARD _PROTOTYPE( void unpause, (int pro) );
|
||||
FORWARD _PROTOTYPE( void handle_ksig, (int proc_nr, sigset_t sig_map) );
|
||||
FORWARD _PROTOTYPE( void handle_sig, (int proc_nr, sigset_t sig_map) );
|
||||
FORWARD _PROTOTYPE( void cause_sigalrm, (struct timer *tp) );
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -208,11 +210,12 @@ PUBLIC int ksig_pending()
|
|||
sigset_t sig_map;
|
||||
|
||||
while (TRUE) {
|
||||
sys_getsig(&proc_nr, &sig_map); /* get an arbitrary pending signal */
|
||||
sys_getksig(&proc_nr, &sig_map); /* get an arbitrary pending signal */
|
||||
if (NONE == proc_nr) { /* stop if no more pending signals */
|
||||
break;
|
||||
} else {
|
||||
handle_ksig(proc_nr, sig_map); /* handle the receive signal */
|
||||
handle_sig(proc_nr, sig_map); /* handle the received signal */
|
||||
sys_endksig(proc_nr); /* tell kernel it's done */
|
||||
}
|
||||
}
|
||||
return(SUSPEND); /* prevents sending reply */
|
||||
|
@ -220,9 +223,9 @@ PUBLIC int ksig_pending()
|
|||
|
||||
|
||||
/*===========================================================================*
|
||||
* handle_ksig *
|
||||
* handle_sig *
|
||||
*===========================================================================*/
|
||||
PRIVATE void handle_ksig(proc_nr, sig_map)
|
||||
PRIVATE void handle_sig(proc_nr, sig_map)
|
||||
int proc_nr;
|
||||
sigset_t sig_map;
|
||||
{
|
||||
|
@ -233,7 +236,7 @@ sigset_t sig_map;
|
|||
rmp = &mproc[proc_nr];
|
||||
if ((rmp->mp_flags & (IN_USE | ZOMBIE)) != IN_USE) return;
|
||||
proc_id = rmp->mp_pid;
|
||||
mp = &mproc[0]; /* pretend kernel signals are from PM */
|
||||
mp = &mproc[0]; /* pretend signals are from PM */
|
||||
mp->mp_procgrp = rmp->mp_procgrp; /* get process group right */
|
||||
|
||||
/* Check each bit in turn to see if a signal is to be sent. Unlike
|
||||
|
@ -253,8 +256,7 @@ sigset_t sig_map;
|
|||
id = -1; break; /* broadcast to all except INIT */
|
||||
case SIGALRM:
|
||||
/* Disregard SIGALRM when the target process has not
|
||||
* requested an alarm. This only applies for a KERNEL
|
||||
* generated signal.
|
||||
* requested an alarm.
|
||||
*/
|
||||
if ((rmp->mp_flags & ALARM_ON) == 0) continue;
|
||||
rmp->mp_flags &= ~ALARM_ON;
|
||||
|
@ -264,7 +266,6 @@ sigset_t sig_map;
|
|||
break;
|
||||
}
|
||||
check_sig(id, i);
|
||||
sys_endsig(proc_nr); /* tell kernel it's done */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,11 +291,21 @@ int sec; /* how many seconds delay before the signal */
|
|||
* to turn the timer off when a process exits with the timer still on.
|
||||
*/
|
||||
clock_t ticks; /* number of ticks for alarm */
|
||||
clock_t exptime; /* needed for remaining time on previous alarm */
|
||||
clock_t uptime; /* current system time */
|
||||
int remaining; /* previous time left in seconds */
|
||||
int s;
|
||||
|
||||
if (sec != 0) mproc[proc_nr].mp_flags |= ALARM_ON;
|
||||
else mproc[proc_nr].mp_flags &= ~ALARM_ON;
|
||||
/* First determine remaining time of previous alarm, if set. */
|
||||
if (mproc[proc_nr].mp_flags & ALARM_ON) {
|
||||
if ( (s=getuptime(&uptime)) != OK)
|
||||
panic(__FILE__,"set_alarm couldn't get uptime", s);
|
||||
exptime = *tmr_exp_time(&mproc[proc_nr].mp_timer);
|
||||
remaining = (int) ((exptime - uptime + (HZ-1))/HZ);
|
||||
if (remaining < 0) remaining = 0;
|
||||
} else {
|
||||
remaining = 0;
|
||||
}
|
||||
|
||||
/* Tell the clock task to provide a signal message when the time comes.
|
||||
*
|
||||
|
@ -316,15 +327,35 @@ int sec; /* how many seconds delay before the signal */
|
|||
if ( (unsigned long) ticks / HZ != (unsigned) sec)
|
||||
ticks = LONG_MAX; /* eternity (really TMR_NEVER) */
|
||||
|
||||
if ((s=sys_signalrm(proc_nr, &ticks)) != OK)
|
||||
panic(__FILE__,"couldn't set signal alarm", s);
|
||||
|
||||
remaining = (int) ((ticks + (HZ-1))/HZ);
|
||||
if (remaining < 0) remaining = INT_MAX; /* true value is too large */
|
||||
if (ticks != 0) {
|
||||
pm_set_timer(&mproc[proc_nr].mp_timer, ticks, cause_sigalrm, proc_nr);
|
||||
mproc[proc_nr].mp_flags |= ALARM_ON;
|
||||
} else if (mproc[proc_nr].mp_flags & ALARM_ON) {
|
||||
pm_cancel_timer(&mproc[proc_nr].mp_timer);
|
||||
mproc[proc_nr].mp_flags &= ~ALARM_ON;
|
||||
}
|
||||
return(remaining);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* cause_sigalrm *
|
||||
*===========================================================================*/
|
||||
PRIVATE void cause_sigalrm(tp)
|
||||
struct timer *tp;
|
||||
{
|
||||
int proc_nr;
|
||||
register struct mproc *rmp;
|
||||
|
||||
proc_nr = tmr_arg(tp)->ta_int; /* get process from timer */
|
||||
rmp = &mproc[proc_nr];
|
||||
if ((rmp->mp_flags & (IN_USE | ZOMBIE)) != IN_USE) return;
|
||||
if ((rmp->mp_flags & ALARM_ON) == 0) return;
|
||||
rmp->mp_flags &= ~ALARM_ON;
|
||||
check_sig(rmp->mp_pid, SIGALRM);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* do_pause *
|
||||
*===========================================================================*/
|
||||
|
|
|
@ -29,7 +29,7 @@ PUBLIC int do_time()
|
|||
clock_t uptime;
|
||||
int s;
|
||||
|
||||
if ( (s=sys_getuptime(&uptime)) != OK)
|
||||
if ( (s=getuptime(&uptime)) != OK)
|
||||
panic(__FILE__,"do_time couldn't get uptime", s);
|
||||
|
||||
mp->mp_reply.reply_time = (time_t) (boottime + (uptime/HZ));
|
||||
|
@ -52,7 +52,7 @@ PUBLIC int do_stime()
|
|||
if (mp->mp_effuid != SUPER_USER) {
|
||||
return(EPERM);
|
||||
}
|
||||
if ( (s=sys_getuptime(&uptime)) != OK)
|
||||
if ( (s=getuptime(&uptime)) != OK)
|
||||
panic(__FILE__,"do_stime couldn't get uptime", s);
|
||||
boottime = (long) m_in.stime - (uptime/HZ);
|
||||
|
||||
|
@ -92,7 +92,7 @@ PUBLIC int do_gettimeofday(void)
|
|||
clock_t uptime;
|
||||
int s;
|
||||
|
||||
if ( (s=sys_getuptime(&uptime)) != OK)
|
||||
if ( (s=getuptime(&uptime)) != OK)
|
||||
panic(__FILE__,"do_gettimeofday couldn't get uptime", s);
|
||||
|
||||
mp->mp_reply.m2_l1 = boottime + uptime/HZ;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <timers.h>
|
||||
#include <string.h>
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/type.h"
|
||||
#include "../../kernel/proc.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue