Fixed some minor issues with the NOTIFY call.

This commit is contained in:
Jorrit Herder 2005-05-24 14:35:58 +00:00
parent 70cdffcc18
commit 0899f82ab2
22 changed files with 87 additions and 137 deletions

View File

@ -148,8 +148,6 @@ PRIVATE void init_buffer()
tmp_buf += left; tmp_buf += left;
tmp_phys += left; tmp_phys += left;
} }
#else /* CHIP != INTEL */
tmp_phys = vir2phys(tmp_buf);
#endif /* CHIP != INTEL */ #endif /* CHIP != INTEL */
} }

View File

@ -6,6 +6,7 @@
#include "driver.h" #include "driver.h"
#include "drvlib.h" #include "drvlib.h"
#include <unistd.h>
/* Extended partition? */ /* Extended partition? */
#define ext_part(s) ((s) == 0x05 || (s) == 0x0F) #define ext_part(s) ((s) == 0x05 || (s) == 0x0F)
@ -161,6 +162,9 @@ struct part_entry *table; /* four entries */
/* Read the partition table at 'offset'. */ /* Read the partition table at 'offset'. */
if (proc_nr == NONE) { if (proc_nr == NONE) {
#if DEAD_CODE
if ((s=getprocnr(&proc_nr)) != OK) {
#endif
if ((s=sys_getprocnr(&proc_nr,0,0)) != OK) { if ((s=sys_getprocnr(&proc_nr,0,0)) != OK) {
printf("%s: can't get own proc nr: %d\n", (*dp->dr_name)(), s); printf("%s: can't get own proc nr: %d\n", (*dp->dr_name)(), s);
return(0); return(0);

View File

@ -869,8 +869,9 @@ message *m;
int r; int r;
/* Try to get a fresh copy of the buffer with kernel messages. */ /* Try to get a fresh copy of the buffer with kernel messages. */
r=0;
if ((r=sys_getkmessages(&kmess)) != OK) { if ((r=sys_getkmessages(&kmess)) != OK) {
printf("TTY: couldn't get copy of kmessages: %d\n", r); printf("TTY: couldn't get copy of kmessages: %d, 0x%x\n", r,r);
return; return;
} }

View File

@ -107,23 +107,5 @@ extern int errno; /* place where the error numbers go */
#define EBADREQUEST (_SIGN 107) /* destination cannot handle request */ #define EBADREQUEST (_SIGN 107) /* destination cannot handle request */
#define EDONTREPLY (_SIGN 201) /* pseudo-code: don't send a reply */ #define EDONTREPLY (_SIGN 201) /* pseudo-code: don't send a reply */
/* The following error codes are generated by the kernel itself. */
#if DEAD_CODE /* replaced by above codes */
#ifdef _SYSTEM
#define E_TRY_AGAIN -1003 /* can't send -- tables full */
#define E_TASK -1006 /* can't send to task */
#define E_OVERRUN -1004 /* interrupt for task that is not waiting */
#define E_NO_PERM -1008 /* ordinary users can't send to tasks */
#define E_BAD_DEST -1001 /* destination address illegal */
#define E_BAD_BUF -1005 /* message buf outside caller's addr space */
#define E_BAD_FCN -1009 /* unknown (illegal) request type */
#define E_BAD_ADDR -1010 /* bad address given to utility routine */
#define E_BAD_PROC -1011 /* bad proc number given to utility */
#define E_BAD_REQUEST -1009 /* unknown (illegal) request type */
#define E_DONT_REPLY -2000 /* pseudo-code: do not send a reply message */
#endif /* DEAD_CODE */
#endif /* _SYSTEM */
#endif /* _ERRNO_H */ #endif /* _ERRNO_H */

View File

@ -36,7 +36,8 @@
#define IDLE -4 /* runs when no one else can run */ #define IDLE -4 /* runs when no one else can run */
#define CLOCK -3 /* alarms and other clock functions */ #define CLOCK -3 /* alarms and other clock functions */
#define SYSTASK -2 /* request system functionality */ #define SYSTASK -2 /* request system functionality */
#define HARDWARE -1 /* used as source on notify() messages */ #define KERNEL -1 /* used as source on notify() messages */
#define HARDWARE KERNEL /* for hardware interrupt handlers */
/* Number of tasks. Note that NR_PROCS is defined in <minix/config.h>. */ /* Number of tasks. Note that NR_PROCS is defined in <minix/config.h>. */
#define NR_TASKS 4 #define NR_TASKS 4

View File

@ -102,18 +102,7 @@ struct kinfo {
phys_bytes bootdev_size; phys_bytes bootdev_size;
phys_bytes params_base; /* parameters passed by boot monitor */ phys_bytes params_base; /* parameters passed by boot monitor */
phys_bytes params_size; phys_bytes params_size;
long notify_held; long nr_ntf_pending;
long notify_blocked;
long notify_switching;
long notify_reenter;
long notify_taskcall;
long notify_ok;
long notify_unhold;
long notify_int;
long notify_alarm;
long notify_sig;
long notify_kmess;
long notify_stop;
int nr_procs; /* number of user processes */ int nr_procs; /* number of user processes */
int nr_tasks; /* number of kernel tasks */ int nr_tasks; /* number of kernel tasks */
char version[8]; /* kernel version number */ char version[8]; /* kernel version number */

View File

@ -128,7 +128,7 @@ PUBLIC void clock_task()
*/ */
if (result != EDONTREPLY) { if (result != EDONTREPLY) {
m.m_type = result; m.m_type = result;
lock_send(CLOCK, m.m_source, &m); lock_send(m.m_source, &m);
} }
} }
} }
@ -186,8 +186,6 @@ irq_hook_t *hook;
* *
* Many global global and static variables are accessed here. The safety * Many global global and static variables are accessed here. The safety
* of this must be justified. Most of them are not changed here: * of this must be justified. Most of them are not changed here:
* k_reenter:
* This safely tells if the clock interrupt is nested.
* proc_ptr, bill_ptr: * proc_ptr, bill_ptr:
* These are used for accounting. It does not matter if proc.c * These are used for accounting. It does not matter if proc.c
* is changing them, provided they are always valid pointers, * is changing them, provided they are always valid pointers,
@ -238,9 +236,9 @@ irq_hook_t *hook;
pending_ticks += ticks; pending_ticks += ticks;
now = realtime + pending_ticks; now = realtime + pending_ticks;
rp = (k_reenter == 0) ? proc_ptr : proc_addr(HARDWARE); /* Update administration. */
rp->user_time += ticks; proc_ptr->user_time += ticks;
if (rp != bill_ptr && rp != proc_addr(IDLE)) bill_ptr->sys_time += ticks; if (proc_ptr != bill_ptr) bill_ptr->sys_time += ticks;
/* Check if do_clocktick() must be called. Done for alarms and scheduling. /* 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(). * If bill_ptr == prev_ptr, there are no ready users so don't need sched().
@ -249,10 +247,10 @@ irq_hook_t *hook;
&& rdy_head[PPRI_USER] != NIL_PROC)) && rdy_head[PPRI_USER] != NIL_PROC))
{ {
m.NOTIFY_TYPE = HARD_INT; m.NOTIFY_TYPE = HARD_INT;
lock_notify(HARDWARE, CLOCK, &m); lock_notify(CLOCK, &m);
} }
else if (--sched_ticks == 0) { else if (--sched_ticks == 0) {
sched_ticks = SCHED_RATE; /* reset quantum */ sched_ticks = SCHED_RATE; /* reset the quantum */
prev_ptr = bill_ptr; /* new previous process */ prev_ptr = bill_ptr; /* new previous process */
} }
return(1); /* reenable clock interrupts */ return(1); /* reenable clock interrupts */

View File

@ -11,8 +11,8 @@
* flag shutting_down must be initialized to FALSE. We rely on the compiler's * flag shutting_down must be initialized to FALSE. We rely on the compiler's
* default initialization (0) of global variables here. * default initialization (0) of global variables here.
*/ */
EXTERN int skip_stop_sequence; /* set to TRUE in case of an exception() */ EXTERN char skip_stop_sequence; /* set to TRUE in case of an exception() */
EXTERN int shutting_down; /* TRUE if the system is shutting down */ EXTERN char shutting_down; /* TRUE if the system is shutting down */
EXTERN struct proc *shutdown_process; /* process awaiting shutdown of */ EXTERN struct proc *shutdown_process; /* process awaiting shutdown of */
EXTERN timer_t shutdown_timer; /* watchdog function called after timeout */ EXTERN timer_t shutdown_timer; /* watchdog function called after timeout */
@ -23,10 +23,9 @@ EXTERN struct machine machine; /* machine information for users */
EXTERN struct kmessages kmess; /* diagnostic messages in kernel */ EXTERN struct kmessages kmess; /* diagnostic messages in kernel */
EXTERN struct memory mem[NR_MEMS]; /* base and size of chunks of memory */ EXTERN struct memory mem[NR_MEMS]; /* base and size of chunks of memory */
/* Process table. Here to stop too many things having to include proc.h. */ /* Process scheduling info and kernel entry count. */
EXTERN struct proc *proc_ptr; /* pointer to currently running process */ EXTERN struct proc *proc_ptr; /* pointer to currently running process */
EXTERN struct proc *next_ptr; /* pointer to next process to run */
/* Miscellaneous. */
EXTERN char k_reenter; /* kernel reentry count (entry count less 1) */ EXTERN char k_reenter; /* kernel reentry count (entry count less 1) */
EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */ EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */

View File

@ -6,6 +6,8 @@
*/ */
#include "kernel.h" #include "kernel.h"
#include "proc.h"
#include <minix/com.h>
#define ICW1_AT 0x11 /* edge triggered, cascade, need ICW4 */ #define ICW1_AT 0x11 /* edge triggered, cascade, need ICW4 */
#define ICW1_PC 0x13 /* edge triggered, no cascade, need ICW4 */ #define ICW1_PC 0x13 /* edge triggered, no cascade, need ICW4 */

View File

@ -162,7 +162,7 @@ int c; /* character to append */
kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE; kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
} else { } else {
m.NOTIFY_TYPE = NEW_KMESS; m.NOTIFY_TYPE = NEW_KMESS;
lock_notify(HARDWARE, TTY, &m); lock_notify(TTY, &m);
} }
} }

View File

@ -240,7 +240,7 @@ int how; /* 0 = halt, 1 = reboot, 2 = panic!, ... */
* primary console for stop sequence output, and one to actually exit. * primary console for stop sequence output, and one to actually exit.
*/ */
m.NOTIFY_TYPE = HARD_STOP; m.NOTIFY_TYPE = HARD_STOP;
lock_notify(HARDWARE, TTY, &m); lock_notify(TTY, &m);
/* Run the stop sequence. The timer argument passes the shutdown status. /* Run the stop sequence. The timer argument passes the shutdown status.
* The stop sequence is skipped for fatal CPU exceptions. * The stop sequence is skipped for fatal CPU exceptions.
@ -297,7 +297,7 @@ timer_t *tp;
shutdown_process = p; /* directly continue if exited */ shutdown_process = p; /* directly continue if exited */
m.NOTIFY_TYPE = HARD_STOP; m.NOTIFY_TYPE = HARD_STOP;
m.NOTIFY_ARG = tmr_arg(tp)->ta_int; /* how */ m.NOTIFY_ARG = tmr_arg(tp)->ta_int; /* how */
lock_notify(HARDWARE, proc_number(p), &m); lock_notify(proc_number(p), &m);
set_timer(tp, get_uptime()+STOP_TICKS, stop_sequence); set_timer(tp, get_uptime()+STOP_TICKS, stop_sequence);
return; /* allow the process to shut down */ return; /* allow the process to shut down */
} }

View File

@ -37,7 +37,7 @@ int n;
prepare_shutdown(RBT_PANIC); prepare_shutdown(RBT_PANIC);
} }
#if ENABLE_K_DEBUGGING
/*===========================================================================* /*===========================================================================*
* print_bitmap * * print_bitmap *
*===========================================================================*/ *===========================================================================*/
@ -55,6 +55,7 @@ bit_t nr_bits;
} }
kprintf("\n", NO_ARG); kprintf("\n", NO_ARG);
} }
#endif /* ENABLE_K_DEBUGGING */
/*===========================================================================* /*===========================================================================*
* free_bit * * free_bit *

View File

@ -213,35 +213,6 @@ csinit:
!* hwint00 - 07 * !* hwint00 - 07 *
!*===========================================================================* !*===========================================================================*
! Note this is a macro, it just looks like a subroutine. ! Note this is a macro, it just looks like a subroutine.
#define hwint_master_slave_fail(irq) \
call save /* save interrupted process state */;\
cli ;\
inb INT2_CTLMASK /* get current mask */ ;\
movb ah, al ;\
inb INT_CTLMASK /* get current mask */ ;\
push eax ;\
cli ;\
movb al, ~[0] ;\
outb INT_CTLMASK /* mask all */;\
outb INT2_CTLMASK /* */;\
cli ;\
push (_irq_handlers+4*irq) /* irq_handlers[irq] */;\
call _intr_handle /* intr_handle(irq_handlers[irq]) */;\
pop ecx ;\
pop eax ;\
cmp (_irq_actids+4*irq), 0 /* interrupt still active? */;\
jz 0f ;\
or eax, [1<<irq] /* mask irq */ ;\
0: outb INT_CTLMASK /* restore master irq mask */;\
movb al, ah ;\
outb INT2_CTLMASK /* restore slave irq mask */;\
movb al, END_OF_INT ;\
outb INT_CTL /* reenable master 8259 */;\
cmp (irq), 8 ;\
jb 1f ;\
outb INT2_CTL /* reenable slave 8259 */;\
1: ret /* restart (another) process */
#define hwint_master(irq) \ #define hwint_master(irq) \
call save /* save interrupted process state */;\ call save /* save interrupted process state */;\
push (_irq_handlers+4*irq) /* irq_handlers[irq] */;\ push (_irq_handlers+4*irq) /* irq_handlers[irq] */;\
@ -412,8 +383,13 @@ _restart:
! Restart the current process or the next process if it is set. ! Restart the current process or the next process if it is set.
mov esp, (_proc_ptr) ! will assume P_STACKBASE == 0 cmp (_next_ptr), 0 ! see if another process is scheduled
lldt P_LDT_SEL(esp) ! enable segment descriptors for task jz 0f
mov eax, (_next_ptr)
mov (_proc_ptr), eax
mov (_next_ptr), 0
0: mov esp, (_proc_ptr) ! will assume P_STACKBASE == 0
lldt P_LDT_SEL(esp) ! enable process' segment descriptors
lea eax, P_STACKTOP(esp) ! arrange for next interrupt lea eax, P_STACKTOP(esp) ! arrange for next interrupt
mov (_tss+TSS3_S_SP0), eax ! to save state in process table mov (_tss+TSS3_S_SP0), eax ! to save state in process table
restart1: restart1:

View File

@ -103,9 +103,8 @@ message *m_ptr; /* pointer to message in the caller's space */
/* Now check if the call is known and try to perform the request. The only /* Now check if the call is known and try to perform the request. The only
* system calls that exist in MINIX are sending and receiving messages. * system calls that exist in MINIX are sending and receiving messages.
* Receiving is straightforward. Sending requires checks to see if sending * Receiving is straightforward. Sending requires to check caller's send
* is allowed by the caller's send mask and to see if the destination is * mask and whether the destination is alive.
* alive.
*/ */
else { else {
switch(function) { switch(function) {
@ -281,6 +280,7 @@ int may_block; /* (dis)allow blocking */
sizeof(struct notification); sizeof(struct notification);
*ntf_q_pp = (*ntf_q_pp)->n_next;/* remove from queue */ *ntf_q_pp = (*ntf_q_pp)->n_next;/* remove from queue */
free_bit(bit_nr, notify_bitmap, NR_NOTIFY_BUFS); free_bit(bit_nr, notify_bitmap, NR_NOTIFY_BUFS);
kinfo.nr_ntf_pending --;
return(OK); /* report success */ return(OK); /* report success */
} }
ntf_q_pp = &(*ntf_q_pp)->n_next; /* proceed to next */ ntf_q_pp = &(*ntf_q_pp)->n_next; /* proceed to next */
@ -354,6 +354,7 @@ message *m_ptr; /* pointer to message buffer */
/* Add to end of queue. Get a free notification buffer. */ /* Add to end of queue. Get a free notification buffer. */
if ((ntf_index = alloc_bit(notify_bitmap, NR_NOTIFY_BUFS)) < 0) if ((ntf_index = alloc_bit(notify_bitmap, NR_NOTIFY_BUFS)) < 0)
return(ENOSPC); /* should be atomic! */ return(ENOSPC); /* should be atomic! */
kinfo.nr_ntf_pending ++;
ntf_p = &notify_buffer[ntf_index]; ntf_p = &notify_buffer[ntf_index];
ntf_p->n_source = proc_number(caller_ptr); ntf_p->n_source = proc_number(caller_ptr);
ntf_p->n_type = m_ptr->NOTIFY_TYPE; ntf_p->n_type = m_ptr->NOTIFY_TYPE;
@ -367,15 +368,23 @@ message *m_ptr; /* pointer to message buffer */
/*==========================================================================* /*==========================================================================*
* lock_notify * * lock_notify *
*==========================================================================*/ *==========================================================================*/
PUBLIC int lock_notify(src, dst, m_ptr) PUBLIC int lock_notify(dst, m_ptr)
int src; /* who is trying to send a message? */
int dst; /* to whom is message being sent? */ int dst; /* to whom is message being sent? */
message *m_ptr; /* pointer to message buffer */ message *m_ptr; /* pointer to message buffer */
{ {
/* Safe gateway to mini_notify() for tasks. */ /* Safe gateway to mini_notify() for tasks and interrupt handlers. This
* function checks if it is called from an interrupt handler and makes sure
* that the correct message source is put on the notification. All kernel
* generated notifications share the same pseudo-process number, to prevent
* conflicts with SENDREC calls to the kernel task.
*/
int result; int result;
struct proc *caller_ptr;
lock(); lock();
result = mini_notify(proc_addr(src), dst, m_ptr); caller_ptr = (k_reenter >= 0 || istaskp(proc_ptr)) ?
proc_addr(KERNEL) : proc_ptr;
result = mini_notify(caller_ptr, dst, m_ptr);
unlock(); unlock();
return(result); return(result);
} }
@ -385,7 +394,7 @@ message *m_ptr; /* pointer to message buffer */
*===========================================================================*/ *===========================================================================*/
PRIVATE void pick_proc() PRIVATE void pick_proc()
{ {
/* Decide who to run now. A new process is selected by setting 'proc_ptr'. /* Decide who to run now. A new process is selected by setting 'next_ptr'.
* When a fresh user (or idle) process is selected, record it in 'bill_ptr', * When a fresh user (or idle) process is selected, record it in 'bill_ptr',
* so the clock task can tell who to bill for system time. * so the clock task can tell who to bill for system time.
*/ */
@ -398,7 +407,7 @@ PRIVATE void pick_proc()
*/ */
for (q=0; q < NR_SCHED_QUEUES; q++) { for (q=0; q < NR_SCHED_QUEUES; q++) {
if ( (rp = rdy_head[q]) != NIL_PROC) { if ( (rp = rdy_head[q]) != NIL_PROC) {
proc_ptr = rp; /* run process 'rp' next */ next_ptr = rp; /* run process 'rp' next */
if (isuserp(rp) || isidlep(rp)) /* possible bill 'rp' */ if (isuserp(rp) || isidlep(rp)) /* possible bill 'rp' */
bill_ptr = rp; bill_ptr = rp;
return; return;
@ -413,7 +422,7 @@ PRIVATE void ready(rp)
register struct proc *rp; /* this process is now runnable */ register struct proc *rp; /* this process is now runnable */
{ {
/* Add 'rp' to one of the queues of runnable processes. */ /* Add 'rp' to one of the queues of runnable processes. */
int q = rp->p_priority; /* scheduling queue to use */ register int q = rp->p_priority; /* scheduling queue to use */
#if ENABLE_K_DEBUGGING #if ENABLE_K_DEBUGGING
if(rp->p_ready) { if(rp->p_ready) {
@ -441,11 +450,16 @@ register struct proc *rp; /* this process is now runnable */
rp->p_nextready = NIL_PROC; rp->p_nextready = NIL_PROC;
} }
/* Run 'rp' next if it has a higher priority than 'proc_ptr'. This actually /* Run 'rp' next if it has a higher priority than 'proc_ptr' or 'next_ptr'.
* should be done via pick_proc(), but the message passing functions rely * This actually should be done via pick_proc(), but the message passing
* on this side-effect. * functions rely on this side-effect. High priorities have a lower number.
*/ */
if (next_ptr && next_ptr->p_priority > rp->p_priority) next_ptr = rp;
else if (proc_ptr->p_priority > rp->p_priority) next_ptr = rp;
#if DEAD_CODE
if (rp->p_priority < proc_ptr->p_priority) proc_ptr = rp; if (rp->p_priority < proc_ptr->p_priority) proc_ptr = rp;
#endif
} }
/*===========================================================================* /*===========================================================================*
@ -458,7 +472,7 @@ register struct proc *rp; /* this process is no longer runnable */
register struct proc *xp; register struct proc *xp;
register struct proc **qtail; /* queue's rdy_tail */ register struct proc **qtail; /* queue's rdy_tail */
int q = rp->p_priority; /* queue to use */ register int q = rp->p_priority; /* queue to use */
#if ENABLE_K_DEBUGGING #if ENABLE_K_DEBUGGING
if(!rp->p_ready) { if(!rp->p_ready) {
@ -480,7 +494,7 @@ register struct proc *rp; /* this process is no longer runnable */
if ( (xp = rdy_head[q]) != NIL_PROC) { /* ready queue is empty */ if ( (xp = rdy_head[q]) != NIL_PROC) { /* ready queue is empty */
if (xp == rp) { /* check head of queue */ if (xp == rp) { /* check head of queue */
rdy_head[q] = xp->p_nextready; /* new head of queue */ rdy_head[q] = xp->p_nextready; /* new head of queue */
if (rp == proc_ptr) /* current process removed */ if (rp == proc_ptr || rp == next_ptr) /* current process removed */
pick_proc(); /* pick new process to run */ pick_proc(); /* pick new process to run */
if(rp == rdy_tail[q]) if(rp == rdy_tail[q])
rdy_tail[q] = NIL_PROC; rdy_tail[q] = NIL_PROC;
@ -531,15 +545,14 @@ PUBLIC void lock_pick_proc()
/*==========================================================================* /*==========================================================================*
* lock_send * * lock_send *
*==========================================================================*/ *==========================================================================*/
PUBLIC int lock_send(src, dst, m_ptr) PUBLIC int lock_send(dst, m_ptr)
int src; /* who is trying to send a message? */
int dst; /* to whom is message being sent? */ int dst; /* to whom is message being sent? */
message *m_ptr; /* pointer to message buffer */ message *m_ptr; /* pointer to message buffer */
{ {
/* Safe gateway to mini_send() for tasks. */ /* Safe gateway to mini_send() for tasks. */
int result; int result;
lock(); lock();
result = mini_send(proc_addr(src), dst, m_ptr, FALSE); result = mini_send(proc_ptr, dst, m_ptr, FALSE);
unlock(); unlock();
return(result); return(result);
} }

View File

@ -8,8 +8,8 @@
* 'proc', be sure to change sconst.h to match. * 'proc', be sure to change sconst.h to match.
* *
* Changes: * Changes:
* May 24, 2005 new field for pending notifications (Jorrit N. Herder)
* Nov 10, 2004 separated process types/ priorities (Jorrit N. Herder) * Nov 10, 2004 separated process types/ priorities (Jorrit N. Herder)
* Sep 30, 2004 bit masks for notifications (Jorrit N. Herder)
* Sep 24, 2004 one timer per type of alarm (Jorrit N. Herder) * Sep 24, 2004 one timer per type of alarm (Jorrit N. Herder)
* May 01, 2004 new p_sendmask to protect syscalls (Jorrit N. Herder) * May 01, 2004 new p_sendmask to protect syscalls (Jorrit N. Herder)
*/ */
@ -21,7 +21,7 @@ struct proc {
struct stackframe_s p_reg; /* process' registers saved in stack frame */ struct stackframe_s p_reg; /* process' registers saved in stack frame */
#if (CHIP == INTEL) #if (CHIP == INTEL)
reg_t p_ldt_sel; /* selector in gdt giving ldt base and limit*/ reg_t p_ldt_sel; /* selector in gdt with ldt base and limit */
struct segdesc_s p_ldt[2+NR_REMOTE_SEGS]; /* CS, DS and remote segments */ struct segdesc_s p_ldt[2+NR_REMOTE_SEGS]; /* CS, DS and remote segments */
#endif /* (CHIP == INTEL) */ #endif /* (CHIP == INTEL) */
@ -32,10 +32,10 @@ struct proc {
reg_t *p_stguard; /* stack guard word */ reg_t *p_stguard; /* stack guard word */
proc_nr_t p_nr; /* number of this process (for fast access) */ proc_nr_t p_nr; /* number of this process (for fast access) */
int p_flags; /* SENDING, RECEIVING, etc. */
struct mem_map p_memmap[NR_LOCAL_SEGS]; /* local memory map (T, D, S) */ struct mem_map p_memmap[NR_LOCAL_SEGS]; /* local memory map (T, D, S) */
struct far_mem p_farmem[NR_REMOTE_SEGS]; /* remote memory map */ struct far_mem p_farmem[NR_REMOTE_SEGS]; /* remote memory map */
short p_flags; /* SENDING, RECEIVING, etc. */
char p_type; /* task, system, driver, server, user, idle */ char p_type; /* task, system, driver, server, user, idle */
char p_priority; /* scheduling priority */ char p_priority; /* scheduling priority */
@ -48,16 +48,15 @@ struct proc {
timer_t p_flagalrm; /* flag alarm timer */ timer_t p_flagalrm; /* flag alarm timer */
timer_t p_syncalrm; /* synchronous alarm timer */ timer_t p_syncalrm; /* synchronous alarm timer */
send_mask_t p_sendmask; /* mask indicating to whom proc may send */ struct proc *p_nextready; /* pointer to next ready process */
struct notification *p_ntf_q; /* queue of pending notifications */
struct proc *p_caller_q; /* head of list of procs wishing to send */ struct proc *p_caller_q; /* head of list of procs wishing to send */
struct proc *p_sendlink; /* link to next proc wishing to send */ struct proc *p_sendlink; /* link to next proc wishing to send */
message *p_messbuf; /* pointer to message buffer */ message *p_messbuf; /* pointer to message buffer */
int p_getfrom; /* from whom does process want to receive? */ proc_nr_t p_getfrom; /* from whom does process want to receive? */
int p_sendto; /* to whom does process want to send? */ proc_nr_t p_sendto; /* to whom does process want to send? */
send_mask_t p_sendmask; /* mask indicating to whom proc may send */
struct notification *p_ntf_q; /* queue of pending notifications */
struct proc *p_nextready; /* pointer to next ready process */
sigset_t p_pending; /* bit map for pending signals */ sigset_t p_pending; /* bit map for pending signals */
unsigned p_pendcount; /* count of pending and unfinished signals */ unsigned p_pendcount; /* count of pending and unfinished signals */

View File

@ -44,8 +44,8 @@ _PROTOTYPE( void print_bitmap, (bitchunk_t *map, bit_t nr_bits) );
/* proc.c */ /* proc.c */
_PROTOTYPE( int sys_call, (int function, int src_dest, message *m_ptr) ); _PROTOTYPE( int sys_call, (int function, int src_dest, message *m_ptr) );
_PROTOTYPE( int lock_notify, (int src, int dst, message *m_ptr) ); _PROTOTYPE( int lock_notify, (int dst, message *m_ptr) );
_PROTOTYPE( int lock_send, (int src, int dst, message *m_ptr) ); _PROTOTYPE( int lock_send, (int dst, message *m_ptr) );
_PROTOTYPE( void lock_pick_proc, (void) ); _PROTOTYPE( void lock_pick_proc, (void) );
_PROTOTYPE( void lock_ready, (struct proc *rp) ); _PROTOTYPE( void lock_ready, (struct proc *rp) );
_PROTOTYPE( void lock_sched, (void) ); _PROTOTYPE( void lock_sched, (void) );
@ -83,6 +83,7 @@ _PROTOTYPE( void intr_handle, (irq_hook_t *hook) );
_PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq, _PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq,
irq_handler_t handler) ); irq_handler_t handler) );
_PROTOTYPE( int rm_irq_handler, (int irq, int id) ); _PROTOTYPE( int rm_irq_handler, (int irq, int id) );
/* klib*.s */ /* klib*.s */
_PROTOTYPE( void int86, (void) ); _PROTOTYPE( void int86, (void) );
_PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks,vir_bytes src_offset, _PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks,vir_bytes src_offset,

View File

@ -89,7 +89,7 @@ PUBLIC void sys_task()
*/ */
if (result != EDONTREPLY) { if (result != EDONTREPLY) {
m.m_type = result; /* report status of call */ m.m_type = result; /* report status of call */
lock_send(SYSTASK, m.m_source, &m); lock_send(m.m_source, &m);
} }
} }
} }
@ -246,7 +246,7 @@ irq_hook_t *hook;
message m; message m;
m.NOTIFY_TYPE = HARD_INT; m.NOTIFY_TYPE = HARD_INT;
m.NOTIFY_ARG = hook->irq; m.NOTIFY_ARG = hook->irq;
lock_notify(HARDWARE, hook->proc_nr, &m); lock_notify(hook->proc_nr, &m);
return(hook->policy & IRQ_REENABLE); return(hook->policy & IRQ_REENABLE);
} }
@ -285,7 +285,7 @@ int sig_nr; /* signal to be sent, 1 to _NSIG */
m.NOTIFY_TYPE = KSIG_PENDING; m.NOTIFY_TYPE = KSIG_PENDING;
m.NOTIFY_ARG = 0; m.NOTIFY_ARG = 0;
m.NOTIFY_FLAGS = 0; m.NOTIFY_FLAGS = 0;
lock_notify(HARDWARE, PM_PROC_NR, &m); lock_notify(PM_PROC_NR, &m);
} }

View File

@ -165,11 +165,11 @@ timer_t *tp;
* process given with a SYN_ALARM message. * process given with a SYN_ALARM message.
*/ */
message m; message m;
m.NOTIFY_SOURCE = HARDWARE; m.NOTIFY_SOURCE = SYSTASK;
m.NOTIFY_TYPE = SYN_ALARM; m.NOTIFY_TYPE = SYN_ALARM;
m.NOTIFY_ARG = get_uptime(); m.NOTIFY_ARG = get_uptime();
m.NOTIFY_FLAGS = 0; m.NOTIFY_FLAGS = 0;
lock_notify(HARDWARE, tmr_arg(tp)->ta_int, &m); lock_notify(tmr_arg(tp)->ta_int, &m);
} }

View File

@ -150,10 +150,8 @@ register message *m_ptr; /* pointer to request message */
} }
case GET_PROCNR: { case GET_PROCNR: {
if (m_ptr->I_KEY_LEN == 0) { /* get own process nr */ if (m_ptr->I_KEY_LEN == 0) { /* get own process nr */
#if DEAD_CODE
/* GET_PROCNR functionality will be moved to the Process Manager! */ /* GET_PROCNR functionality will be moved to the Process Manager! */
kprintf("GET_PROCNR (own) from %d\n", m_ptr->m_source); kprintf("GET_PROCNR (own) from %d\n", m_ptr->m_source);
#endif
src_phys = vir2phys(&proc_nr); src_phys = vir2phys(&proc_nr);
length = sizeof(int); length = sizeof(int);
} else { /* lookup nr by name */ } else { /* lookup nr by name */
@ -161,10 +159,8 @@ register message *m_ptr; /* pointer to request message */
struct proc *pp; struct proc *pp;
struct vir_addr vsrc, vdst; struct vir_addr vsrc, vdst;
char key[8]; /* storage for process name to lookup */ char key[8]; /* storage for process name to lookup */
#if DEAD_CODE
/* GET_PROCNR functionality will be moved to the Process Manager! */ /* GET_PROCNR functionality will be moved to the Process Manager! */
kprintf("GET_PROCNR (by name) from %d\n", m_ptr->m_source); kprintf("GET_PROCNR (by name) from %d\n", m_ptr->m_source);
#endif
proc_nr = m_ptr->m_source; /* only caller can request copy */ proc_nr = m_ptr->m_source; /* only caller can request copy */
if (m_ptr->I_KEY_LEN > sizeof(key)) return(EINVAL); if (m_ptr->I_KEY_LEN > sizeof(key)) return(EINVAL);
vsrc.proc_nr = proc_nr; vsrc.segment = D; vsrc.offset = (vir_bytes) m_ptr->I_KEY_PTR; vsrc.proc_nr = proc_nr; vsrc.segment = D; vsrc.offset = (vir_bytes) m_ptr->I_KEY_PTR;

View File

@ -133,7 +133,7 @@ PUBLIC void main()
source= mq->mq_mess.m_source; source= mq->mq_mess.m_source;
if (source == FS_PROC_NR) { if (source == FS_PROC_NR) {
sr_rec(mq); sr_rec(mq);
} else if (source == HARDWARE) /* a notification! */ } else if (mq->mq_mess.m_type & NOTIFICATION )
{ {
if (mq->mq_mess.m_type == SYN_ALARM) { if (mq->mq_mess.m_type == SYN_ALARM) {
clck_tick(&mq->mq_mess); clck_tick(&mq->mq_mess);

View File

@ -325,18 +325,7 @@ PRIVATE void kenv_dmp()
printf("- bootdev_size: %5u\n", kinfo.bootdev_size); printf("- bootdev_size: %5u\n", kinfo.bootdev_size);
printf("- params_base: %5u\n", kinfo.params_base); printf("- params_base: %5u\n", kinfo.params_base);
printf("- params_size: %5u\n", kinfo.params_size); printf("- params_size: %5u\n", kinfo.params_size);
printf("- notify_blocked:%8u\n", kinfo.notify_blocked); printf("- notify_pending:%8u\n", kinfo.nr_ntf_pending);
printf("- notify_ok: %8u\n", kinfo.notify_ok);
printf("- notify_held: %8u\n", kinfo.notify_held);
printf("- notify_switch: %8u\n", kinfo.notify_switching);
printf("- notify_reenter:%8u\n", kinfo.notify_reenter);
printf("- notify_taskcall:%7u\n", kinfo.notify_taskcall);
printf("- notify_unhold: %8u\n", kinfo.notify_unhold);
printf("- hard_int: %8u\n", kinfo.notify_int);
printf("- hard_stop: %8u\n", kinfo.notify_stop);
printf("- sync_alarm: %8u\n", kinfo.notify_alarm);
printf("- ksig_pending: %8u\n", kinfo.notify_sig);
printf("- new_kmess: %8u\n", kinfo.notify_kmess);
printf("- nr_procs: %3u\n", kinfo.nr_procs); printf("- nr_procs: %3u\n", kinfo.nr_procs);
printf("- nr_tasks: %3u\n", kinfo.nr_tasks); printf("- nr_tasks: %3u\n", kinfo.nr_tasks);
printf("- version: %.6s\n", kinfo.version); printf("- version: %.6s\n", kinfo.version);

View File

@ -299,6 +299,7 @@ phys_bytes tot_bytes; /* total memory to allocate, including gap */
phys_clicks new_base; phys_clicks new_base;
static char zero[1024]; /* used to zero bss */ static char zero[1024]; /* used to zero bss */
phys_bytes bytes, base, count, bss_offset; phys_bytes bytes, base, count, bss_offset;
int s;
/* No need to allocate text if it can be shared. */ /* No need to allocate text if it can be shared. */
if (sh_mp != NULL) text_bytes = 0; if (sh_mp != NULL) text_bytes = 0;
@ -373,9 +374,9 @@ phys_bytes tot_bytes; /* total memory to allocate, including gap */
while (bytes > 0) { while (bytes > 0) {
count = MIN(bytes, (phys_bytes) sizeof(zero)); count = MIN(bytes, (phys_bytes) sizeof(zero));
if (sys_physcopy(PM_PROC_NR, D, (phys_bytes) zero, if ((s=sys_physcopy(PM_PROC_NR, D, (phys_bytes) zero,
NONE, PHYS_SEG, base, count) != OK) { NONE, PHYS_SEG, base, count)) != OK) {
panic("new_mem can't zero", NO_NUM); panic("new_mem can't zero", s);
} }
base += count; base += count;
bytes -= count; bytes -= count;