From: Lionel Sambuc Date: Wed, 21 May 2014 08:52:39 +0000 (+0200) Subject: Message type for SYS_SETALARM X-Git-Tag: v3.3.0~228 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/pkcs11-keygen.html?a=commitdiff_plain;h=30eae10274deb23ccd4a00702712899fcd690226;p=minix.git Message type for SYS_SETALARM Change-Id: I2c2ee24c19085cbd1e7ffba7b2db714b2561ff17 --- diff --git a/include/minix/com.h b/include/minix/com.h index 5faacbec0..f6abc64e2 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -300,11 +300,6 @@ #define DIO_PORT m2_l1 /* single port address */ #define DIO_VALUE m2_l2 /* single I/O value */ -/* Field names for SYS_SETALARM. */ -#define ALRM_EXP_TIME m2_l1 /* expire time for the alarm call */ -#define ALRM_ABS_TIME m2_i2 /* set to 1 to use absolute alarm time */ -#define ALRM_TIME_LEFT m2_l1 /* how many ticks were remaining */ - /* Field names for SYS_IRQCTL. */ #define IRQ_REQUEST m5_s1 /* what to do? */ # define IRQ_SETPOLICY 1 /* manage a slot of the IRQ table */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index dfae34d2c..d64a7dac5 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -712,6 +712,15 @@ typedef struct { } mess_lsys_krn_sys_sdevio; _ASSERT_MSG_SIZE(mess_lsys_krn_sys_sdevio); +typedef struct { + clock_t exp_time; + clock_t time_left; + int abs_time; + + uint8_t padding[44]; +} mess_lsys_krn_sys_setalarm; +_ASSERT_MSG_SIZE(mess_lsys_krn_sys_setalarm); + typedef struct { int request; int vec_size; @@ -1456,6 +1465,7 @@ typedef struct { mess_lsys_krn_schedule m_lsys_krn_schedule; mess_lsys_krn_sys_memset m_lsys_krn_sys_memset; mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio; + mess_lsys_krn_sys_setalarm m_lsys_krn_sys_setalarm; mess_lsys_krn_sys_vdevio m_lsys_krn_sys_vdevio; mess_lsys_pci_busc_get_bar m_lsys_pci_busc_get_bar; diff --git a/kernel/system/do_setalarm.c b/kernel/system/do_setalarm.c index fe065ccbc..ec1625be4 100644 --- a/kernel/system/do_setalarm.c +++ b/kernel/system/do_setalarm.c @@ -2,9 +2,9 @@ * m_type: SYS_SETALARM * * The parameters for this kernel call are: - * m2_l1: ALRM_EXP_TIME (alarm's expiration time) - * m2_i2: ALRM_ABS_TIME (expiration time is absolute?) - * m2_l1: ALRM_TIME_LEFT (return seconds left of previous) + * m_lsys_krn_sys_setalarm.exp_time (alarm's expiration time) + * m_lsys_krn_sys_setalarm.abs_time (expiration time is absolute?) + * m_lsys_krn_sys_setalarm.time_left (return seconds left of previous) */ #include "kernel/system.h" @@ -24,12 +24,12 @@ int do_setalarm(struct proc * caller, message * m_ptr) /* A process requests a synchronous alarm, or wants to cancel its alarm. */ long exp_time; /* expiration time for this alarm */ int use_abs_time; /* use absolute or relative time */ - minix_timer_t *tp; /* the process' timer structure */ + minix_timer_t *tp; /* the process' timer structure */ clock_t uptime; /* placeholder for current uptime */ /* Extract shared parameters from the request message. */ - exp_time = m_ptr->ALRM_EXP_TIME; /* alarm's expiration time */ - use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */ + exp_time = m_ptr->m_lsys_krn_sys_setalarm.exp_time; /* alarm's expiration time */ + use_abs_time = m_ptr->m_lsys_krn_sys_setalarm.abs_time; /* flag for absolute time */ if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM); /* Get the timer structure and set the parameters for this alarm. */ @@ -40,9 +40,9 @@ int do_setalarm(struct proc * caller, message * m_ptr) /* Return the ticks left on the previous alarm. */ uptime = get_monotonic(); if ((tp->tmr_exp_time != TMR_NEVER) && (uptime < tp->tmr_exp_time) ) { - m_ptr->ALRM_TIME_LEFT = (tp->tmr_exp_time - uptime); + m_ptr->m_lsys_krn_sys_setalarm.time_left = (tp->tmr_exp_time - uptime); } else { - m_ptr->ALRM_TIME_LEFT = 0; + m_ptr->m_lsys_krn_sys_setalarm.time_left = 0; } /* Finally, (re)set the timer depending on the expiration time. */ diff --git a/lib/libsys/sys_setalarm.c b/lib/libsys/sys_setalarm.c index 39d601732..935e75154 100644 --- a/lib/libsys/sys_setalarm.c +++ b/lib/libsys/sys_setalarm.c @@ -11,8 +11,7 @@ int abs_time; /* use absolute or relative expiration time */ * number can be SELF if the caller doesn't know its process number. */ message m; - m.ALRM_EXP_TIME = exp_time; /* the expiration time */ - m.ALRM_ABS_TIME = abs_time; /* time is absolute? */ + m.m_lsys_krn_sys_setalarm.exp_time = exp_time; /* the expiration time */ + m.m_lsys_krn_sys_setalarm.abs_time = abs_time; /* time is absolute? */ return _kernel_call(SYS_SETALARM, &m); } - diff --git a/lib/libsys/tickdelay.c b/lib/libsys/tickdelay.c index 1f5d50b93..4b87f2c3a 100644 --- a/lib/libsys/tickdelay.c +++ b/lib/libsys/tickdelay.c @@ -17,25 +17,24 @@ int tickdelay(clock_t ticks) if (ticks <= 0) return OK; /* check for robustness */ - m.ALRM_EXP_TIME = ticks; /* request message after ticks */ - m.ALRM_ABS_TIME = 0; /* ticks are relative to now */ + m.m_lsys_krn_sys_setalarm.exp_time = ticks; /* request message after ticks */ + m.m_lsys_krn_sys_setalarm.abs_time = 0; /* ticks are relative to now */ s = _kernel_call(SYS_SETALARM, &m); if (s != OK) return(s); sef_receive(CLOCK,&m_alarm); /* await synchronous alarm */ /* Check if we must reschedule the current alarm. */ - if (m.ALRM_TIME_LEFT > 0 && m.ALRM_TIME_LEFT != TMR_NEVER) { - m.ALRM_EXP_TIME = m.ALRM_TIME_LEFT - ticks; - if (m.ALRM_EXP_TIME <= 0) - m.ALRM_EXP_TIME = 1; + if (m.m_lsys_krn_sys_setalarm.time_left > 0 && + m.m_lsys_krn_sys_setalarm.time_left != TMR_NEVER) { + + m.m_lsys_krn_sys_setalarm.exp_time = + m.m_lsys_krn_sys_setalarm.time_left - ticks; + + if (m.m_lsys_krn_sys_setalarm.exp_time <= 0) + m.m_lsys_krn_sys_setalarm.exp_time = 1; s = _kernel_call(SYS_SETALARM, &m); } return(s); } - - - - -