Replaced flagalrm() timers with another technique to check for timeouts.
This allowed removing the p_flagarlm timer from the kernel's process table. Furthermore, I merged p_syncalrm and p_signalrm into p_alarm_timer to save even more space. Note that processes can no longer have both a signal and synchronous alarm timer outstanding as of now.
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include <ibm/ports.h> /* port addresses and magic numbers */
|
||||
#include <ibm/bios.h> /* BIOS addresses, sizes and magic numbers */
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
|
||||
/* To translate an address in kernel space to a physical address. This is
|
||||
* the same as umap_local(proc_ptr, D, vir, sizeof(*vir)), but less costly.
|
||||
*/
|
||||
@@ -27,6 +25,9 @@
|
||||
/* How long should the process names be in the kernel? */
|
||||
#define P_NAME_LEN 8
|
||||
|
||||
/* How many bytes should the circular buffer for kernel diagnostics. */
|
||||
#define KMESS_BUF_SIZE 256
|
||||
|
||||
/* How many bytes for (port,value)-pairs vector to copy in. */
|
||||
#define VDEVIO_BUF_SIZE 128
|
||||
|
||||
@@ -48,6 +49,9 @@
|
||||
#define SET_BIT(map,bit) ( MAP_CHUNK(map,bit) |= (1 << CHUNK_OFFSET(bit) )
|
||||
#define UNSET_BIT(map,bit) ( MAP_CHUNK(map,bit) &= ~(1 << CHUNK_OFFSET(bit) )
|
||||
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
|
||||
/* Program stack words and masks. */
|
||||
#define INIT_PSW 0x0200 /* initial psw */
|
||||
#define INIT_TASK_PSW 0x1200 /* initial psw for tasks (with IOPL 1) */
|
||||
@@ -67,7 +71,6 @@
|
||||
*/
|
||||
#define NR_MEMS 8 /* number of chunks of memory */
|
||||
|
||||
|
||||
#endif /* (CHIP == INTEL) */
|
||||
|
||||
#if (CHIP == M68000)
|
||||
|
||||
@@ -45,19 +45,16 @@ struct proc {
|
||||
clock_t p_user_time; /* user time in ticks */
|
||||
clock_t p_sys_time; /* sys time in ticks */
|
||||
|
||||
timer_t p_signalrm; /* signal alarm timer */
|
||||
timer_t p_flagalrm; /* flag alarm timer */
|
||||
timer_t p_syncalrm; /* synchronous alarm timer */
|
||||
|
||||
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_q_link; /* link to next proc wishing to send */
|
||||
message *p_messbuf; /* pointer to message buffer */
|
||||
message *p_messbuf; /* pointer to passed message buffer */
|
||||
proc_nr_t p_getfrom; /* from whom does process want to receive? */
|
||||
proc_nr_t p_sendto; /* to whom does process want to send? */
|
||||
|
||||
sigset_t p_pending; /* bit map for pending signals */
|
||||
timer_t p_alarm_timer; /* timer shared by different alarm types */
|
||||
sigset_t p_pending; /* bit map for pending kernel signals */
|
||||
unsigned p_pendcount; /* count of pending and unfinished signals */
|
||||
|
||||
char p_name[P_NAME_LEN]; /* name of the process, including \0 */
|
||||
|
||||
@@ -114,9 +114,7 @@ PRIVATE void initialize(void)
|
||||
|
||||
/* Initialize all alarm timers for all processes. */
|
||||
for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) {
|
||||
tmr_inittimer(&(rp->p_signalrm));
|
||||
tmr_inittimer(&(rp->p_syncalrm));
|
||||
tmr_inittimer(&(rp->p_flagalrm));
|
||||
tmr_inittimer(&(rp->p_alarm_timer));
|
||||
}
|
||||
|
||||
/* Initialize the call vector to a safe default handler. Some system calls
|
||||
@@ -146,7 +144,6 @@ PRIVATE void initialize(void)
|
||||
map(SYS_TIMES, do_times); /* get uptime and process times */
|
||||
map(SYS_SIGNALRM, do_signalrm); /* causes an alarm signal */
|
||||
map(SYS_SYNCALRM, do_syncalrm); /* send a notification message */
|
||||
map(SYS_FLAGALRM, do_flagalrm); /* set a timeout flag to 1 */
|
||||
|
||||
/* Device I/O. */
|
||||
map(SYS_IRQCTL, do_irqctl); /* interrupt control operations */
|
||||
@@ -192,9 +189,7 @@ int proc_nr; /* slot of process to clean up */
|
||||
rc = proc_addr(proc_nr);
|
||||
|
||||
/* Turn off any alarm timers at the clock. */
|
||||
reset_timer(&rc->p_signalrm);
|
||||
reset_timer(&rc->p_flagalrm);
|
||||
reset_timer(&rc->p_syncalrm);
|
||||
reset_timer(&rc->p_alarm_timer);
|
||||
|
||||
/* Make sure the exiting process is no longer scheduled. */
|
||||
if (rc->p_flags == 0) lock_unready(rc);
|
||||
|
||||
@@ -39,22 +39,19 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
|
||||
/* The system call implemented in this file:
|
||||
* m_type: SYS_SIGNALRM, SYS_SYNCALRM, SYS_FLAGALRM
|
||||
* m_type: SYS_SIGNALRM, SYS_SYNCALRM
|
||||
*
|
||||
* The parameters for this system call are:
|
||||
* m2_i1: ALRM_PROC_NR (set alarm for this process)
|
||||
* m2_l1: ALRM_EXP_TIME (alarm's expiration time)
|
||||
* m2_i2: ALRM_ABS_TIME (expiration time is absolute?)
|
||||
* m2_l1: ALRM_SEC_LEFT (return seconds left of previous)
|
||||
* m2_p1: ALRM_FLAG_PTR (virtual addr of alarm flag)
|
||||
*
|
||||
* Changes:
|
||||
* Aug 25, 2004 fully rewritten to unite all alarms (Jorrit N. Herder)
|
||||
* May 02, 2004 added new timeout flag alarm (Jorrit N. Herder)
|
||||
* Aug 25, 2004 fully rewritten to clean up code (Jorrit N. Herder)
|
||||
*/
|
||||
|
||||
FORWARD _PROTOTYPE( void cause_syncalrm, (timer_t *tp) );
|
||||
FORWARD _PROTOTYPE( void cause_flagalrm, (timer_t *tp) );
|
||||
FORWARD _PROTOTYPE( void cause_signalrm, (timer_t *tp) );
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -64,7 +61,7 @@ PUBLIC int do_setalarm(m_ptr)
|
||||
message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* A process requests an alarm, or wants to cancel its alarm. This function
|
||||
* is shared used for all of SYS_SIGNALRM, SYS_SYNCALRM, and SYS_FLAGALRM.
|
||||
* is shared used for both the SYS_SIGNALRM and SYS_SYNCALRM.
|
||||
*/
|
||||
int proc_nr; /* which process wants the alarm */
|
||||
long exp_time; /* expiration time for this alarm */
|
||||
@@ -80,26 +77,12 @@ message *m_ptr; /* pointer to request message */
|
||||
use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */
|
||||
|
||||
/* Get the timer structure and set the parameters for this alarm. */
|
||||
tp = &(proc_addr(proc_nr)->p_alarm_timer);
|
||||
tmr_arg(tp)->ta_int = proc_nr;
|
||||
switch (m_ptr->m_type) {
|
||||
case SYS_SYNCALRM: /* notify with SYN_ALARM message */
|
||||
tp = &(proc_addr(proc_nr)->p_syncalrm);
|
||||
tmr_arg(tp)->ta_int = proc_nr;
|
||||
tp->tmr_func = cause_syncalrm;
|
||||
break;
|
||||
case SYS_SIGNALRM: /* send process a SIGALRM signal */
|
||||
tp = &(proc_addr(proc_nr)->p_signalrm);
|
||||
tmr_arg(tp)->ta_int = proc_nr;
|
||||
tp->tmr_func = cause_signalrm;
|
||||
break;
|
||||
case SYS_FLAGALRM: /* set caller's timeout flag to 1 */
|
||||
tp = &(proc_addr(proc_nr)->p_flagalrm);
|
||||
tmr_arg(tp)->ta_long =
|
||||
numap_local(proc_nr,(vir_bytes) m_ptr->ALRM_FLAG_PTR,sizeof(int));
|
||||
if (! tmr_arg(tp)->ta_long) return(EFAULT);
|
||||
tp->tmr_func = cause_flagalrm;
|
||||
break;
|
||||
default: /* invalid alarm type */
|
||||
return(EINVAL);
|
||||
case SYS_SYNCALRM: tp->tmr_func = cause_syncalrm; break;
|
||||
case SYS_SIGNALRM: tp->tmr_func = cause_signalrm; break;
|
||||
default: return(EINVAL); /* invalid alarm type */
|
||||
}
|
||||
|
||||
/* Return the ticks left on the previous alarm. */
|
||||
@@ -134,21 +117,6 @@ timer_t *tp;
|
||||
cause_sig(tmr_arg(tp)->ta_int, SIGALRM);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* cause_flagalrm *
|
||||
*===========================================================================*/
|
||||
PRIVATE void cause_flagalrm(tp)
|
||||
timer_t *tp;
|
||||
{
|
||||
/* Routine called if a timer goes off for a process that requested a timeout
|
||||
* flag to be set when the alarm expires. The timer argument 'ta_long' gives
|
||||
* the physical address of the timeout flag. No validity check was done when
|
||||
* setting the alarm, so check for 0 here.
|
||||
*/
|
||||
int timeout = 1;
|
||||
phys_bytes timeout_flag = (phys_bytes) tmr_arg(tp)->ta_long;
|
||||
phys_copy(vir2phys(&timeout), tmr_arg(tp)->ta_long, sizeof(int));
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* cause_syncalrm *
|
||||
|
||||
@@ -45,6 +45,14 @@ struct notification {
|
||||
struct notification* n_next; /* pointer to next notification */
|
||||
};
|
||||
|
||||
/* The kernel outputs diagnostic messages in a circular buffer. */
|
||||
struct kmessages {
|
||||
int km_next; /* next index to write */
|
||||
int km_size; /* current size in buffer */
|
||||
char km_buf[KMESS_BUF_SIZE]; /* buffer for messages */
|
||||
};
|
||||
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
typedef unsigned reg_t; /* machine register */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user