Replacing timer_t by netbsd's timer_t
* Renamed struct timer to struct minix_timer * Renamed timer_t to minix_timer_t * Ensured all the code uses the minix_timer_t typedef * Removed ifdef around _BSD_TIMER_T * Removed include/timers.h and merged it into include/minix/timers.h * Resolved prototype conflict by renaming kernel's (re)set_timer to (re)set_kernel_timer. Change-Id: I56f0f30dfed96e1a0575d92492294cf9a06468a5
This commit is contained in:
parent
214c4e152b
commit
9fab85c2de
67 changed files with 256 additions and 278 deletions
|
@ -26,7 +26,7 @@
|
|||
#include <configfile.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
#include "config.h"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <configfile.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "config.h"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <configfile.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <err.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
|
|
|
@ -1487,7 +1487,7 @@
|
|||
./usr/include/term.h minix-sys
|
||||
./usr/include/termios.h minix-sys
|
||||
./usr/include/time.h minix-sys
|
||||
./usr/include/timers.h minix-sys
|
||||
./usr/include/timers.h minix-sys obsolete
|
||||
./usr/include/tools.h minix-sys obsolete
|
||||
./usr/include/ttyent.h minix-sys
|
||||
./usr/include/tzfile.h minix-sys
|
||||
|
|
|
@ -170,7 +170,7 @@ static struct port_state {
|
|||
struct device part[DEV_PER_DRIVE]; /* partition bases and sizes */
|
||||
struct device subpart[SUB_PER_DRIVE]; /* same for subpartitions */
|
||||
|
||||
timer_t timer; /* port-specific timeout timer */
|
||||
minix_timer_t timer; /* port-specific timeout timer */
|
||||
int left; /* number of tries left before giving up */
|
||||
/* (only used for signature probing) */
|
||||
|
||||
|
@ -178,7 +178,7 @@ static struct port_state {
|
|||
u32_t pend_mask; /* commands not yet complete */
|
||||
struct {
|
||||
thread_id_t tid;/* ID of the worker thread */
|
||||
timer_t timer; /* timer associated with each request */
|
||||
minix_timer_t timer; /* timer associated with each request */
|
||||
int result; /* success/failure result of the commands */
|
||||
} cmd_info[NR_CMDS];
|
||||
} port_state[NR_PORTS];
|
||||
|
@ -232,7 +232,7 @@ static void port_set_cmd(struct port_state *ps, int cmd, cmd_fis_t *fis,
|
|||
u8_t packet[ATAPI_PACKET_SIZE], prd_t *prdt, int nr_prds, int write);
|
||||
static void port_issue(struct port_state *ps, int cmd, clock_t timeout);
|
||||
static int port_exec(struct port_state *ps, int cmd, clock_t timeout);
|
||||
static void port_timeout(struct timer *tp);
|
||||
static void port_timeout(minix_timer_t *tp);
|
||||
static void port_disconnect(struct port_state *ps);
|
||||
|
||||
static char *ahci_portname(struct port_state *ps);
|
||||
|
@ -1712,7 +1712,7 @@ static void port_intr(struct port_state *ps)
|
|||
/*===========================================================================*
|
||||
* port_timeout *
|
||||
*===========================================================================*/
|
||||
static void port_timeout(struct timer *tp)
|
||||
static void port_timeout(minix_timer_t *tp)
|
||||
{
|
||||
/* A timeout has occurred on this port. Figure out what the timeout is
|
||||
* for, and take appropriate action.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <machine/pci.h>
|
||||
#include <minix/ds.h>
|
||||
#include <minix/vm.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <sys/mman.h>
|
||||
#include "assert.h"
|
||||
#include "e1000.h"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "floppy.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <machine/diskparm.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/syslib.h>
|
||||
|
@ -212,7 +212,7 @@ static struct floppy { /* main drive struct, one entry per drive */
|
|||
char fl_calibration; /* CALIBRATED or UNCALIBRATED */
|
||||
u8_t fl_density; /* NO_DENS = ?, 0 = 360K; 1 = 360K/1.2M; etc.*/
|
||||
u8_t fl_class; /* bitmap for possible densities */
|
||||
timer_t fl_tmr_stop; /* timer to stop motor */
|
||||
minix_timer_t fl_tmr_stop; /* timer to stop motor */
|
||||
struct device fl_geom; /* Geometry of the drive */
|
||||
struct device fl_part[NR_PARTITIONS]; /* partition's base & size */
|
||||
} floppy[NR_DRIVES];
|
||||
|
@ -236,11 +236,11 @@ static u8_t f_results[MAX_RESULTS];/* the controller can give lots of output */
|
|||
* Besides the 'f_tmr_timeout' timer below, the floppy structure for each
|
||||
* floppy disk drive contains a 'fl_tmr_stop' timer.
|
||||
*/
|
||||
static timer_t f_tmr_timeout; /* timer for various timeouts */
|
||||
static minix_timer_t f_tmr_timeout; /* timer for various timeouts */
|
||||
static u32_t system_hz; /* system clock frequency */
|
||||
static void f_expire_tmrs(clock_t stamp);
|
||||
static void stop_motor(timer_t *tp);
|
||||
static void f_timeout(timer_t *tp);
|
||||
static void stop_motor(minix_timer_t *tp);
|
||||
static void f_timeout(minix_timer_t *tp);
|
||||
|
||||
static struct device *f_prepare(devminor_t device);
|
||||
static struct device *f_part(devminor_t minor);
|
||||
|
@ -785,7 +785,7 @@ static void start_motor(void)
|
|||
/*===========================================================================*
|
||||
* stop_motor *
|
||||
*===========================================================================*/
|
||||
static void stop_motor(timer_t *tp)
|
||||
static void stop_motor(minix_timer_t *tp)
|
||||
{
|
||||
/* This routine is called from an alarm timer after several seconds have
|
||||
* elapsed with no floppy disk activity. It turns the drive motor off.
|
||||
|
@ -1199,7 +1199,7 @@ static int f_intr_wait(void)
|
|||
/*===========================================================================*
|
||||
* f_timeout *
|
||||
*===========================================================================*/
|
||||
static void f_timeout(timer_t *UNUSED(tp))
|
||||
static void f_timeout(minix_timer_t *UNUSED(tp))
|
||||
{
|
||||
/* This routine is called when a timer expires. Usually to tell that a
|
||||
* motor has spun up, but also to forge an interrupt when it takes too long
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <minix/ds.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#define debug 0
|
||||
#define RAND_UPDATE /**/
|
||||
|
@ -141,7 +141,7 @@ static int fxp_instance;
|
|||
|
||||
static fxp_t *fxp_state;
|
||||
|
||||
static timer_t fxp_watchdog;
|
||||
static minix_timer_t fxp_watchdog;
|
||||
|
||||
static u32_t system_hz;
|
||||
|
||||
|
@ -170,7 +170,7 @@ static void fxp_restart_ru(fxp_t *fp);
|
|||
static void fxp_getstat_s(message *mp);
|
||||
static void fxp_handler(fxp_t *fp);
|
||||
static void fxp_check_ints(fxp_t *fp);
|
||||
static void fxp_watchdog_f(timer_t *tp);
|
||||
static void fxp_watchdog_f(minix_timer_t *tp);
|
||||
static int fxp_link_changed(fxp_t *fp);
|
||||
static void fxp_report_link(fxp_t *fp);
|
||||
static void reply(fxp_t *fp);
|
||||
|
@ -1627,7 +1627,7 @@ static void fxp_check_ints(fxp_t *fp)
|
|||
* fxp_watchdog_f *
|
||||
*===========================================================================*/
|
||||
static void fxp_watchdog_f(tp)
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
fxp_t *fp;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <minix/syslib.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <machine/pci.h>
|
||||
#include <minix/ds.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
@ -149,7 +149,7 @@ static void or_getstat_s(message * mp);
|
|||
static void print_linkstatus(t_or * orp, u16_t status);
|
||||
static int or_get_recvd_packet(t_or *orp, u16_t rxfid, u8_t *databuf);
|
||||
static void or_reset(void);
|
||||
static void or_watchdog_f(timer_t *tp);
|
||||
static void or_watchdog_f(minix_timer_t *tp);
|
||||
static void setup_wepkey(t_or *orp, char *wepkey0);
|
||||
static void do_hard_int(void);
|
||||
static void check_int_events(void);
|
||||
|
@ -1092,7 +1092,7 @@ next:
|
|||
* Will be called regularly to see whether the driver has crashed. If that *
|
||||
* condition is detected, reset the driver and card *
|
||||
*****************************************************************************/
|
||||
static void or_watchdog_f(timer_t *tp)
|
||||
static void or_watchdog_f(minix_timer_t *tp)
|
||||
{
|
||||
t_or *orp;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ static void rtl8139_dump(message *m);
|
|||
static void dump_phy(re_t *rep);
|
||||
#endif
|
||||
static int rl_handler(re_t *rep);
|
||||
static void rl_watchdog_f(timer_t *tp);
|
||||
static void rl_watchdog_f(minix_timer_t *tp);
|
||||
static void tell_dev(vir_bytes start, size_t size, int pci_bus, int
|
||||
pci_dev, int pci_func);
|
||||
|
||||
|
@ -1969,7 +1969,7 @@ static int rl_handler(re_t *rep)
|
|||
* rl_watchdog_f *
|
||||
*===========================================================================*/
|
||||
static void rl_watchdog_f(tp)
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
re_t *rep;
|
||||
/* Use a synchronous alarm instead of a watchdog timer. */
|
||||
|
|
|
@ -18,7 +18,7 @@ Created: Aug 2003 by Philip Homburg <philip@cs.vu.nl>
|
|||
#include <minix/type.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/endpoint.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <net/hton.h>
|
||||
#include <net/gen/ether.h>
|
||||
#include <net/gen/eth_io.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <minix/type.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/endpoint.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <net/hton.h>
|
||||
#include <net/gen/ether.h>
|
||||
#include <net/gen/eth_io.h>
|
||||
|
@ -223,7 +223,7 @@ static void check_int_events(void);
|
|||
static void do_hard_int(void);
|
||||
static void dump_phy(const re_t *rep);
|
||||
static void rl_handler(re_t *rep);
|
||||
static void rl_watchdog_f(timer_t *tp);
|
||||
static void rl_watchdog_f(minix_timer_t *tp);
|
||||
|
||||
/*
|
||||
* The message used in the main loop is made global, so that rl_watchdog_f()
|
||||
|
@ -1888,7 +1888,7 @@ static void rl_handler(re_t *rep)
|
|||
* rl_watchdog_f *
|
||||
*===========================================================================*/
|
||||
static void rl_watchdog_f(tp)
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
re_t *rep;
|
||||
/* Use a synchronous alarm instead of a watchdog timer. */
|
||||
|
|
|
@ -123,7 +123,7 @@ static void flush(console_t *cons);
|
|||
static void parse_escape(console_t *cons, int c);
|
||||
static void scroll_screen(console_t *cons, int dir);
|
||||
static void set_6845(int reg, unsigned val);
|
||||
static void stop_beep(timer_t *tmrp);
|
||||
static void stop_beep(minix_timer_t *tmrp);
|
||||
static void cons_org0(void);
|
||||
static void disable_console(void);
|
||||
static void reenable_console(void);
|
||||
|
@ -789,7 +789,7 @@ static void beep()
|
|||
* This routine works by turning on the bits 0 and 1 in port B of the 8255
|
||||
* chip that drive the speaker.
|
||||
*/
|
||||
static timer_t tmr_stop_beep;
|
||||
static minix_timer_t tmr_stop_beep;
|
||||
pvb_pair_t char_out[3];
|
||||
u32_t port_b_val;
|
||||
|
||||
|
@ -885,7 +885,7 @@ clock_t dur;
|
|||
* This routine works by turning on the bits 0 and 1 in port B of the 8255
|
||||
* chip that drive the speaker.
|
||||
*/
|
||||
static timer_t tmr_stop_beep;
|
||||
static minix_timer_t tmr_stop_beep;
|
||||
pvb_pair_t char_out[3];
|
||||
u32_t port_b_val;
|
||||
|
||||
|
@ -914,7 +914,7 @@ clock_t dur;
|
|||
/*===========================================================================*
|
||||
* stop_beep *
|
||||
*===========================================================================*/
|
||||
static void stop_beep(timer_t *UNUSED(tmrp))
|
||||
static void stop_beep(minix_timer_t *UNUSED(tmrp))
|
||||
{
|
||||
/* Turn off the beeper by turning off bits 0 and 1 in PORT_B. */
|
||||
u32_t port_b_val;
|
||||
|
|
|
@ -151,7 +151,7 @@ static int kbd_watchdog_set= 0;
|
|||
static int kbd_alive= 1;
|
||||
static long sticky_alt_mode = 0;
|
||||
static long debug_fkeys = 1;
|
||||
static timer_t tmr_kbd_wd;
|
||||
static minix_timer_t tmr_kbd_wd;
|
||||
|
||||
static void kbc_cmd0(int cmd);
|
||||
static void kbc_cmd1(int cmd, int data);
|
||||
|
@ -166,7 +166,7 @@ static void set_leds(void);
|
|||
static void show_key_mappings(void);
|
||||
static int kb_read(struct tty *tp, int try);
|
||||
static unsigned map_key(int scode);
|
||||
static void kbd_watchdog(timer_t *tmrp);
|
||||
static void kbd_watchdog(minix_timer_t *tmrp);
|
||||
|
||||
static int kbd_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static int kbd_close(devminor_t minor);
|
||||
|
@ -1323,7 +1323,7 @@ int *isauxp;
|
|||
/*===========================================================================*
|
||||
* kbd_watchdog *
|
||||
*===========================================================================*/
|
||||
static void kbd_watchdog(timer_t *UNUSED(tmrp))
|
||||
static void kbd_watchdog(minix_timer_t *UNUSED(tmrp))
|
||||
{
|
||||
|
||||
kbd_watchdog_set= 0;
|
||||
|
|
|
@ -63,7 +63,7 @@ unsigned long rs_irq_set = 0;
|
|||
|
||||
struct kmessages kmess;
|
||||
|
||||
static void tty_timed_out(timer_t *tp);
|
||||
static void tty_timed_out(minix_timer_t *tp);
|
||||
static void settimer(tty_t *tty_ptr, int enable);
|
||||
static void in_transfer(tty_t *tp);
|
||||
static int tty_echo(tty_t *tp, int ch);
|
||||
|
@ -1608,7 +1608,7 @@ static void tty_init()
|
|||
/*===========================================================================*
|
||||
* tty_timed_out *
|
||||
*===========================================================================*/
|
||||
static void tty_timed_out(timer_t *tp)
|
||||
static void tty_timed_out(minix_timer_t *tp)
|
||||
{
|
||||
/* This timer has expired. Set the events flag, to force processing. */
|
||||
tty_t *tty_ptr;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* tty.h - Terminals */
|
||||
|
||||
#include <minix/chardriver.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#undef lock
|
||||
#undef unlock
|
||||
|
@ -42,7 +42,7 @@ typedef struct tty {
|
|||
devfun_t tty_devread; /* routine to read from low level buffers */
|
||||
devfun_t tty_icancel; /* cancel any device input */
|
||||
int tty_min; /* minimum requested #chars in input queue */
|
||||
timer_t tty_tmr; /* the timer for this tty */
|
||||
minix_timer_t tty_tmr; /* the timer for this tty */
|
||||
|
||||
/* Output section. */
|
||||
devfun_t tty_devwrite; /* routine to start actual device output */
|
||||
|
|
|
@ -39,7 +39,7 @@ INCS+= ieeefp.h
|
|||
|
||||
.if defined(__MINIX)
|
||||
# MINIX Specific headers.
|
||||
INCS+= env.h fetch.h lib.h libutil.h timers.h varargs.h
|
||||
INCS+= env.h fetch.h lib.h libutil.h varargs.h
|
||||
.endif
|
||||
|
||||
|
||||
|
|
|
@ -1,15 +1,117 @@
|
|||
/* This library provides generic watchdog timer management functionality.
|
||||
* The functions operate on a timer queue provided by the caller. Note that
|
||||
* the timers must use absolute time to allow sorting. The library provides:
|
||||
*
|
||||
* tmrs_settimer: (re)set a new watchdog timer in the timers queue
|
||||
* tmrs_clrtimer: remove a timer from both the timers queue
|
||||
* tmrs_exptimers: check for expired timers and run watchdog functions
|
||||
*
|
||||
* Author:
|
||||
* Jorrit N. Herder <jnherder@cs.vu.nl>
|
||||
* Adapted from tmr_settimer and tmr_clrtimer in src/kernel/clock.c.
|
||||
* Last modified: September 30, 2004.
|
||||
*/
|
||||
#ifndef _MINIX_TIMERS_H
|
||||
#define _MINIX_TIMERS_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <minix/u64.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
||||
struct minix_timer;
|
||||
typedef void (*tmr_func_t)(struct minix_timer *tp);
|
||||
typedef union { int ta_int; long ta_long; void *ta_ptr; } tmr_arg_t;
|
||||
|
||||
/* A minix_timer_t variable must be declare for each distinct timer to be used.
|
||||
* The timers watchdog function and expiration time are automatically set
|
||||
* by the library function tmrs_settimer, but its argument is not.
|
||||
*/
|
||||
typedef struct minix_timer
|
||||
{
|
||||
struct minix_timer *tmr_next; /* next in a timer chain */
|
||||
clock_t tmr_exp_time; /* expiration time */
|
||||
tmr_func_t tmr_func; /* function to call when expired */
|
||||
tmr_arg_t tmr_arg; /* random argument */
|
||||
} minix_timer_t;
|
||||
|
||||
/* Used when the timer is not active. */
|
||||
#define TMR_NEVER ((clock_t) -1 < 0) ? ((clock_t) LONG_MAX) : ((clock_t) -1)
|
||||
#undef TMR_NEVER
|
||||
#define TMR_NEVER ((clock_t) LONG_MAX)
|
||||
|
||||
/* These definitions can be used to set or get data from a timer variable. */
|
||||
#define tmr_arg(tp) (&(tp)->tmr_arg)
|
||||
#define tmr_exp_time(tp) (&(tp)->tmr_exp_time)
|
||||
|
||||
/* Timers should be initialized once before they are being used. Be careful
|
||||
* not to reinitialize a timer that is in a list of timers, or the chain
|
||||
* will be broken.
|
||||
*/
|
||||
#define tmr_inittimer(tp) (void)((tp)->tmr_exp_time = TMR_NEVER, \
|
||||
(tp)->tmr_next = NULL)
|
||||
|
||||
/* The following generic timer management functions are available. They
|
||||
* can be used to operate on the lists of timers. Adding a timer to a list
|
||||
* automatically takes care of removing it.
|
||||
*/
|
||||
clock_t tmrs_clrtimer(minix_timer_t **tmrs, minix_timer_t *tp, clock_t *new_head);
|
||||
void tmrs_exptimers(minix_timer_t **tmrs, clock_t now, clock_t *new_head);
|
||||
clock_t tmrs_settimer(minix_timer_t **tmrs, minix_timer_t *tp, clock_t exp_time,
|
||||
tmr_func_t watchdog, clock_t *new_head);
|
||||
|
||||
#define PRINT_STATS(cum_spenttime, cum_instances) { \
|
||||
if(ex64hi(cum_spenttime)) { util_stacktrace(); printf(" ( ??? %lu %lu)\n", \
|
||||
ex64hi(cum_spenttime), ex64lo(cum_spenttime)); } \
|
||||
printf("%s:%d,%lu,%lu\n", \
|
||||
__FILE__, __LINE__, cum_instances, \
|
||||
ex64lo(cum_spenttime)); \
|
||||
}
|
||||
|
||||
#define RESET_STATS(starttime, cum_instances, cum_spenttime, cum_starttime) { \
|
||||
cum_instances = 0; \
|
||||
cum_starttime = starttime; \
|
||||
cum_spenttime = make64(0,0); \
|
||||
}
|
||||
|
||||
#define TIME_BLOCK_VAR(timed_code_block, time_interval) do { \
|
||||
static u64_t _cum_spenttime, _cum_starttime; \
|
||||
static int _cum_instances; \
|
||||
u64_t _next_cum_spent, _starttime, _endtime, _dt, _cum_dt; \
|
||||
u32_t _dt_micros; \
|
||||
read_tsc_64(&_starttime); \
|
||||
do { timed_code_block } while(0); \
|
||||
read_tsc_64(&_endtime); \
|
||||
_dt = sub64(_endtime, _starttime); \
|
||||
if(_cum_instances == 0) { \
|
||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||
} \
|
||||
_next_cum_spent = add64(_cum_spenttime, _dt); \
|
||||
if(ex64hi(_next_cum_spent)) { \
|
||||
PRINT_STATS(_cum_spenttime, _cum_instances); \
|
||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||
} \
|
||||
_cum_spenttime = add64(_cum_spenttime, _dt); \
|
||||
_cum_instances++; \
|
||||
_cum_dt = sub64(_endtime, _cum_starttime); \
|
||||
if(cmp64(_cum_dt, make64(0, 120)) > 0) { \
|
||||
PRINT_STATS(_cum_spenttime, _cum_instances); \
|
||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TIME_BLOCK(timed_code_block) TIME_BLOCK_VAR(timed_code_block, 100)
|
||||
#define TIME_BLOCK_T(timed_code_block, t) TIME_BLOCK_VAR(timed_code_block, t)
|
||||
|
||||
/* Timers abstraction for system processes. This would be in minix/sysutil.h
|
||||
* if it weren't for naming conflicts.
|
||||
*/
|
||||
|
||||
#include <timers.h>
|
||||
|
||||
void init_timer(timer_t *tp);
|
||||
void set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg);
|
||||
void cancel_timer(timer_t *tp);
|
||||
void init_timer(minix_timer_t *tp);
|
||||
void set_timer(minix_timer_t *tp, int ticks, tmr_func_t watchdog, int arg);
|
||||
void cancel_timer(minix_timer_t *tp);
|
||||
void expire_timers(clock_t now);
|
||||
|
||||
#endif /* _MINIX_TIMERS_H */
|
||||
|
|
|
@ -65,12 +65,10 @@ typedef _BSD_CLOCKID_T_ clockid_t;
|
|||
#undef _BSD_CLOCKID_T_
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
#ifdef _BSD_TIMER_T_
|
||||
typedef _BSD_TIMER_T_ timer_t;
|
||||
#undef _BSD_TIMER_T_
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
#ifdef __minix
|
||||
#define CLOCKS_PER_SEC 60
|
||||
|
|
110
include/timers.h
110
include/timers.h
|
@ -1,110 +0,0 @@
|
|||
/* This library provides generic watchdog timer management functionality.
|
||||
* The functions operate on a timer queue provided by the caller. Note that
|
||||
* the timers must use absolute time to allow sorting. The library provides:
|
||||
*
|
||||
* tmrs_settimer: (re)set a new watchdog timer in the timers queue
|
||||
* tmrs_clrtimer: remove a timer from both the timers queue
|
||||
* tmrs_exptimers: check for expired timers and run watchdog functions
|
||||
*
|
||||
* Author:
|
||||
* Jorrit N. Herder <jnherder@cs.vu.nl>
|
||||
* Adapted from tmr_settimer and tmr_clrtimer in src/kernel/clock.c.
|
||||
* Last modified: September 30, 2004.
|
||||
*/
|
||||
|
||||
#ifndef _TIMERS_H
|
||||
#define _TIMERS_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <minix/u64.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
||||
struct timer;
|
||||
typedef void (*tmr_func_t)(struct timer *tp);
|
||||
typedef union { int ta_int; long ta_long; void *ta_ptr; } tmr_arg_t;
|
||||
|
||||
/* A timer_t variable must be declare for each distinct timer to be used.
|
||||
* The timers watchdog function and expiration time are automatically set
|
||||
* by the library function tmrs_settimer, but its argument is not.
|
||||
*/
|
||||
typedef struct timer
|
||||
{
|
||||
struct timer *tmr_next; /* next in a timer chain */
|
||||
clock_t tmr_exp_time; /* expiration time */
|
||||
tmr_func_t tmr_func; /* function to call when expired */
|
||||
tmr_arg_t tmr_arg; /* random argument */
|
||||
} timer_t;
|
||||
|
||||
/* Used when the timer is not active. */
|
||||
#define TMR_NEVER ((clock_t) -1 < 0) ? ((clock_t) LONG_MAX) : ((clock_t) -1)
|
||||
#undef TMR_NEVER
|
||||
#define TMR_NEVER ((clock_t) LONG_MAX)
|
||||
|
||||
/* These definitions can be used to set or get data from a timer variable. */
|
||||
#define tmr_arg(tp) (&(tp)->tmr_arg)
|
||||
#define tmr_exp_time(tp) (&(tp)->tmr_exp_time)
|
||||
|
||||
/* Timers should be initialized once before they are being used. Be careful
|
||||
* not to reinitialize a timer that is in a list of timers, or the chain
|
||||
* will be broken.
|
||||
*/
|
||||
#define tmr_inittimer(tp) (void)((tp)->tmr_exp_time = TMR_NEVER, \
|
||||
(tp)->tmr_next = NULL)
|
||||
|
||||
/* The following generic timer management functions are available. They
|
||||
* can be used to operate on the lists of timers. Adding a timer to a list
|
||||
* automatically takes care of removing it.
|
||||
*/
|
||||
clock_t tmrs_clrtimer(timer_t **tmrs, timer_t *tp, clock_t *new_head);
|
||||
void tmrs_exptimers(timer_t **tmrs, clock_t now, clock_t *new_head);
|
||||
clock_t tmrs_settimer(timer_t **tmrs, timer_t *tp, clock_t exp_time,
|
||||
tmr_func_t watchdog, clock_t *new_head);
|
||||
|
||||
#define PRINT_STATS(cum_spenttime, cum_instances) { \
|
||||
if(ex64hi(cum_spenttime)) { util_stacktrace(); printf(" ( ??? %lu %lu)\n", \
|
||||
ex64hi(cum_spenttime), ex64lo(cum_spenttime)); } \
|
||||
printf("%s:%d,%lu,%lu\n", \
|
||||
__FILE__, __LINE__, cum_instances, \
|
||||
ex64lo(cum_spenttime)); \
|
||||
}
|
||||
|
||||
#define RESET_STATS(starttime, cum_instances, cum_spenttime, cum_starttime) { \
|
||||
cum_instances = 0; \
|
||||
cum_starttime = starttime; \
|
||||
cum_spenttime = make64(0,0); \
|
||||
}
|
||||
|
||||
#define TIME_BLOCK_VAR(timed_code_block, time_interval) do { \
|
||||
static u64_t _cum_spenttime, _cum_starttime; \
|
||||
static int _cum_instances; \
|
||||
u64_t _next_cum_spent, _starttime, _endtime, _dt, _cum_dt; \
|
||||
u32_t _dt_micros; \
|
||||
read_tsc_64(&_starttime); \
|
||||
do { timed_code_block } while(0); \
|
||||
read_tsc_64(&_endtime); \
|
||||
_dt = sub64(_endtime, _starttime); \
|
||||
if(_cum_instances == 0) { \
|
||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||
} \
|
||||
_next_cum_spent = _cum_spenttime + _dt; \
|
||||
if(ex64hi(_next_cum_spent)) { \
|
||||
PRINT_STATS(_cum_spenttime, _cum_instances); \
|
||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||
} \
|
||||
_cum_spenttime += _dt; \
|
||||
_cum_instances++; \
|
||||
_cum_dt = sub64(_endtime, _cum_starttime); \
|
||||
if(cmp64(_cum_dt, make64(0, 120)) > 0) { \
|
||||
PRINT_STATS(_cum_spenttime, _cum_instances); \
|
||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TIME_BLOCK(timed_code_block) TIME_BLOCK_VAR(timed_code_block, 100)
|
||||
#define TIME_BLOCK_T(timed_code_block, t) TIME_BLOCK_VAR(timed_code_block, t)
|
||||
|
||||
#endif /* _TIMERS_H */
|
||||
|
|
@ -412,7 +412,7 @@ kinfo_t *pre_init(int argc, char **argv)
|
|||
* longer used and the "real" implementations are visible
|
||||
*/
|
||||
int send_sig(endpoint_t proc_nr, int sig_nr) { return 0; }
|
||||
void minix_shutdown(timer_t *t) { arch_shutdown(RBT_PANIC); }
|
||||
void minix_shutdown(minix_timer_t *t) { arch_shutdown(RBT_PANIC); }
|
||||
void busy_delay_ms(int x) { }
|
||||
int raise(int n) { panic("raise(%d)\n", n); }
|
||||
int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size,
|
||||
|
|
|
@ -246,6 +246,6 @@ kinfo_t *pre_init(u32_t magic, u32_t ebx)
|
|||
}
|
||||
|
||||
int send_sig(endpoint_t proc_nr, int sig_nr) { return 0; }
|
||||
void minix_shutdown(timer_t *t) { arch_shutdown(RBT_PANIC); }
|
||||
void minix_shutdown(minix_timer_t *t) { arch_shutdown(RBT_PANIC); }
|
||||
void busy_delay_ms(int x) { }
|
||||
int raise(int sig) { panic("raise(%d)\n", sig); }
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
*
|
||||
* In addition to the main clock_task() entry point, which starts the main
|
||||
* loop, there are several other minor entry points:
|
||||
* clock_stop: called just before MINIX shutdown
|
||||
* get_realtime: get wall time since boot in clock ticks
|
||||
* set_realtime: set wall time since boot in clock ticks
|
||||
* set_adjtime_delta: set the number of ticks to adjust realtime
|
||||
* get_monotonic: get monotonic time since boot in clock ticks
|
||||
* set_timer: set a watchdog timer (+)
|
||||
* reset_timer: reset a watchdog timer (+)
|
||||
* read_clock: read the counter of channel 0 of the 8253A timer
|
||||
* clock_stop: called just before MINIX shutdown
|
||||
* get_realtime: get wall time since boot in clock ticks
|
||||
* set_realtime: set wall time since boot in clock ticks
|
||||
* set_adjtime_delta: set the number of ticks to adjust realtime
|
||||
* get_monotonic: get monotonic time since boot in clock ticks
|
||||
* set_kernel_timer: set a watchdog timer (+)
|
||||
* reset_kernel_timer: reset a watchdog timer (+)
|
||||
* read_clock: read the counter of channel 0 of the 8253A timer
|
||||
*
|
||||
* (+) The CLOCK task keeps tracks of watchdog timers for the entire kernel.
|
||||
* It is crucial that watchdog functions not block, or the CLOCK task may
|
||||
|
@ -46,14 +46,14 @@
|
|||
*/
|
||||
static void load_update(void);
|
||||
|
||||
/* The CLOCK's timers queue. The functions in <timers.h> operate on this.
|
||||
/* The CLOCK's timers queue. The functions in <minix/timers.h> operate on this.
|
||||
* Each system process possesses a single synchronous alarm timer. If other
|
||||
* kernel parts want to use additional timers, they must declare their own
|
||||
* persistent (static) timer structure, which can be passed to the clock
|
||||
* via (re)set_timer().
|
||||
* via (re)set_kernel_timer().
|
||||
* When a timer expires its watchdog function is run by the CLOCK task.
|
||||
*/
|
||||
static timer_t *clock_timers; /* queue of CLOCK timers */
|
||||
static minix_timer_t *clock_timers; /* queue of CLOCK timers */
|
||||
static clock_t next_timeout; /* monotonic time that next timer expires */
|
||||
|
||||
/* The time is incremented by the interrupt handler on each clock tick.
|
||||
|
@ -211,10 +211,10 @@ clock_t get_monotonic(void)
|
|||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* set_timer *
|
||||
* set_kernel_timer *
|
||||
*===========================================================================*/
|
||||
void set_timer(tp, exp_time, watchdog)
|
||||
struct timer *tp; /* pointer to timer structure */
|
||||
void set_kernel_timer(tp, exp_time, watchdog)
|
||||
minix_timer_t *tp; /* pointer to timer structure */
|
||||
clock_t exp_time; /* expiration monotonic time */
|
||||
tmr_func_t watchdog; /* watchdog to be called */
|
||||
{
|
||||
|
@ -226,10 +226,10 @@ tmr_func_t watchdog; /* watchdog to be called */
|
|||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* reset_timer *
|
||||
* reset_kernel_timer *
|
||||
*===========================================================================*/
|
||||
void reset_timer(tp)
|
||||
struct timer *tp; /* pointer to timer structure */
|
||||
void reset_kernel_timer(tp)
|
||||
minix_timer_t *tp; /* pointer to timer structure */
|
||||
{
|
||||
/* The timer pointed to by 'tp' is no longer needed. Remove it from both the
|
||||
* active and expired lists. Always update the next timeout time by setting
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <minix/type.h> /* MINIX specific types, e.g. message */
|
||||
#include <minix/ipc.h> /* MINIX run-time system */
|
||||
#include <minix/sysutil.h> /* MINIX utility library functions */
|
||||
#include <timers.h> /* watchdog timer management */
|
||||
#include <minix/timers.h> /* watchdog timer management */
|
||||
#include <errno.h> /* return codes and error numbers */
|
||||
#include <sys/param.h>
|
||||
#include <minix/param.h>
|
||||
|
|
|
@ -340,7 +340,7 @@ static void announce(void)
|
|||
void prepare_shutdown(const int how)
|
||||
{
|
||||
/* This function prepares to shutdown MINIX. */
|
||||
static timer_t shutdown_timer;
|
||||
static minix_timer_t shutdown_timer;
|
||||
|
||||
/* Continue after 1 second, to give processes a chance to get scheduled to
|
||||
* do shutdown work. Set a watchog timer to call shutdown(). The timer
|
||||
|
@ -348,13 +348,13 @@ void prepare_shutdown(const int how)
|
|||
*/
|
||||
printf("MINIX will now be shut down ...\n");
|
||||
tmr_arg(&shutdown_timer)->ta_int = how;
|
||||
set_timer(&shutdown_timer, get_monotonic() + system_hz, minix_shutdown);
|
||||
set_kernel_timer(&shutdown_timer, get_monotonic() + system_hz, minix_shutdown);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* shutdown *
|
||||
*===========================================================================*/
|
||||
void minix_shutdown(timer_t *tp)
|
||||
void minix_shutdown(minix_timer_t *tp)
|
||||
{
|
||||
/* This function is called from prepare_shutdown or stop_sequence to bring
|
||||
* down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
|
||||
|
|
|
@ -42,7 +42,7 @@ struct priv {
|
|||
irq_id_t s_int_pending; /* pending hardware interrupts */
|
||||
sigset_t s_sig_pending; /* pending signals */
|
||||
|
||||
timer_t s_alarm_timer; /* synchronous alarm timer */
|
||||
minix_timer_t s_alarm_timer; /* synchronous alarm timer */
|
||||
reg_t *s_stack_guard; /* stack guard word for kernel tasks */
|
||||
|
||||
int s_nr_io_range; /* allowed I/O ports */
|
||||
|
|
|
@ -11,15 +11,14 @@
|
|||
|
||||
/* Struct declarations. */
|
||||
struct proc;
|
||||
struct timer;
|
||||
|
||||
/* clock.c */
|
||||
clock_t get_realtime(void);
|
||||
void set_realtime(clock_t);
|
||||
void set_adjtime_delta(int32_t);
|
||||
clock_t get_monotonic(void);
|
||||
void set_timer(struct timer *tp, clock_t t, tmr_func_t f);
|
||||
void reset_timer(struct timer *tp);
|
||||
void set_kernel_timer(minix_timer_t *tp, clock_t t, tmr_func_t f);
|
||||
void reset_kernel_timer(minix_timer_t *tp);
|
||||
void ser_dump_proc(void);
|
||||
|
||||
void cycles_accounting_init(void);
|
||||
|
@ -45,7 +44,7 @@ void fpu_sigcontext(struct proc *, struct sigframe *fr, struct
|
|||
#endif
|
||||
void kmain(kinfo_t *cbi);
|
||||
void prepare_shutdown(int how);
|
||||
__dead void minix_shutdown(struct timer *tp);
|
||||
__dead void minix_shutdown(minix_timer_t *tp);
|
||||
void bsp_finish_booting(void);
|
||||
|
||||
/* proc.c */
|
||||
|
|
|
@ -48,7 +48,7 @@ int do_clear(struct proc * caller, message * m_ptr)
|
|||
clear_endpoint(rc);
|
||||
|
||||
/* Turn off any alarm timers at the clock. */
|
||||
reset_timer(&priv(rc)->s_alarm_timer);
|
||||
reset_kernel_timer(&priv(rc)->s_alarm_timer);
|
||||
|
||||
/* Make sure that the exiting process is no longer scheduled,
|
||||
* and mark slot as FREE. Also mark saved fpu contents as not significant.
|
||||
|
|
|
@ -113,7 +113,7 @@ int do_privctl(struct proc * caller, message * m_ptr)
|
|||
priv(rp)->s_notify_pending.chunk[i] = 0; /* - notifications */
|
||||
priv(rp)->s_int_pending = 0; /* - interrupts */
|
||||
(void) sigemptyset(&priv(rp)->s_sig_pending); /* - signals */
|
||||
reset_timer(&priv(rp)->s_alarm_timer); /* - alarm */
|
||||
reset_kernel_timer(&priv(rp)->s_alarm_timer); /* - alarm */
|
||||
priv(rp)->s_asyntab= -1; /* - asynsends */
|
||||
priv(rp)->s_asynsize= 0;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#if USE_SETALARM
|
||||
|
||||
static void cause_alarm(timer_t *tp);
|
||||
static void cause_alarm(minix_timer_t *tp);
|
||||
|
||||
/*===========================================================================*
|
||||
* do_setalarm *
|
||||
|
@ -24,7 +24,7 @@ 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 */
|
||||
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. */
|
||||
|
@ -47,10 +47,10 @@ int do_setalarm(struct proc * caller, message * m_ptr)
|
|||
|
||||
/* Finally, (re)set the timer depending on the expiration time. */
|
||||
if (exp_time == 0) {
|
||||
reset_timer(tp);
|
||||
reset_kernel_timer(tp);
|
||||
} else {
|
||||
tp->tmr_exp_time = (use_abs_time) ? exp_time : exp_time + get_monotonic();
|
||||
set_timer(tp, tp->tmr_exp_time, tp->tmr_func);
|
||||
set_kernel_timer(tp, tp->tmr_exp_time, tp->tmr_func);
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int do_setalarm(struct proc * caller, message * m_ptr)
|
|||
/*===========================================================================*
|
||||
* cause_alarm *
|
||||
*===========================================================================*/
|
||||
static void cause_alarm(timer_t *tp)
|
||||
static void cause_alarm(minix_timer_t *tp)
|
||||
{
|
||||
/* Routine called if a timer goes off and the process requested a synchronous
|
||||
* alarm. The process number is stored in timer argument 'ta_int'. Notify that
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "syslib.h"
|
||||
#include <assert.h>
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#include "kernel/config.h"
|
||||
#include "kernel/const.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "sysutil.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
/*===========================================================================*
|
||||
* tickdelay *
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
*/
|
||||
|
||||
#include "syslib.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <minix/sysutil.h>
|
||||
|
||||
static timer_t *timers = NULL;
|
||||
static minix_timer_t *timers = NULL;
|
||||
static int expiring = 0;
|
||||
|
||||
/*===========================================================================*
|
||||
* init_timer *
|
||||
*===========================================================================*/
|
||||
void init_timer(timer_t *tp)
|
||||
void init_timer(minix_timer_t *tp)
|
||||
{
|
||||
tmr_inittimer(tp);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ void init_timer(timer_t *tp)
|
|||
/*===========================================================================*
|
||||
* set_timer *
|
||||
*===========================================================================*/
|
||||
void set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
|
||||
void set_timer(minix_timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
|
||||
{
|
||||
int r;
|
||||
clock_t now, prev_time = 0, next_time;
|
||||
|
@ -51,7 +51,7 @@ void set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
|
|||
/*===========================================================================*
|
||||
* cancel_timer *
|
||||
*===========================================================================*/
|
||||
void cancel_timer(timer_t *tp)
|
||||
void cancel_timer(minix_timer_t *tp)
|
||||
{
|
||||
clock_t next_time, prev_time;
|
||||
prev_time = tmrs_clrtimer(&timers, tp, &next_time);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This library provides generic watchdog timer management functionality.
|
||||
* See the comments in <timers.h> for details.
|
||||
* See the comments in <minix/timers.h> for details.
|
||||
*/
|
||||
|
||||
#include <timers.h> /* definitions and function prototypes */
|
||||
#include <minix/timers.h> /* definitions and function prototypes */
|
||||
#include <sys/null.h>
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
* tmrs_clrtimer *
|
||||
*===========================================================================*/
|
||||
clock_t tmrs_clrtimer(tmrs, tp, next_time)
|
||||
timer_t **tmrs; /* pointer to timers queue */
|
||||
timer_t *tp; /* timer to be removed */
|
||||
minix_timer_t **tmrs; /* pointer to timers queue */
|
||||
minix_timer_t *tp; /* timer to be removed */
|
||||
clock_t *next_time;
|
||||
{
|
||||
/* Deactivate a timer and remove it from the timers queue.
|
||||
*/
|
||||
timer_t **atp;
|
||||
minix_timer_t **atp;
|
||||
clock_t prev_time;
|
||||
|
||||
if(*tmrs)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* tmrs_exptimers *
|
||||
*===========================================================================*/
|
||||
void tmrs_exptimers(tmrs, now, new_head)
|
||||
timer_t **tmrs; /* pointer to timers queue */
|
||||
minix_timer_t **tmrs; /* pointer to timers queue */
|
||||
clock_t now; /* current time */
|
||||
clock_t *new_head;
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ clock_t *new_head;
|
|||
* Run the watchdog functions for all expired timers and deactivate them.
|
||||
* The caller is responsible for scheduling a new alarm if needed.
|
||||
*/
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
|
||||
while ((tp = *tmrs) != NULL && tp->tmr_exp_time <= now) {
|
||||
*tmrs = tp->tmr_next;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* tmrs_settimer *
|
||||
*===========================================================================*/
|
||||
clock_t tmrs_settimer(tmrs, tp, exp_time, watchdog, new_head)
|
||||
timer_t **tmrs; /* pointer to timers queue */
|
||||
timer_t *tp; /* the timer to be added */
|
||||
minix_timer_t **tmrs; /* pointer to timers queue */
|
||||
minix_timer_t *tp; /* the timer to be added */
|
||||
clock_t exp_time; /* its expiration time */
|
||||
tmr_func_t watchdog; /* watchdog function to be run */
|
||||
clock_t *new_head; /* new earliest timer, if non NULL */
|
||||
|
@ -15,7 +15,7 @@ clock_t *new_head; /* new earliest timer, if non NULL */
|
|||
* in the list of active timers with the first to expire in front.
|
||||
* The caller responsible for scheduling a new alarm for the timer if needed.
|
||||
*/
|
||||
timer_t **atp;
|
||||
minix_timer_t **atp;
|
||||
clock_t old_head = 0;
|
||||
|
||||
if(*tmrs)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <lib.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/type.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <lib.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/type.h>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <lib.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/type.h>
|
||||
|
|
|
@ -16,10 +16,10 @@ int clck_call_expire;
|
|||
|
||||
static clock_t curr_time;
|
||||
static clock_t prev_time;
|
||||
static timer_t *timer_chain;
|
||||
static minix_timer_t *timer_chain;
|
||||
static time_t next_timeout;
|
||||
|
||||
static void clck_fast_release(timer_t *timer);
|
||||
static void clck_fast_release(minix_timer_t *timer);
|
||||
static void set_timer(void);
|
||||
|
||||
void clck_init()
|
||||
|
@ -66,12 +66,12 @@ void reset_time()
|
|||
}
|
||||
|
||||
void clck_timer(timer, timeout, func, fd)
|
||||
timer_t *timer;
|
||||
minix_timer_t *timer;
|
||||
time_t timeout;
|
||||
timer_func_t func;
|
||||
int fd;
|
||||
{
|
||||
timer_t *timer_index;
|
||||
minix_timer_t *timer_index;
|
||||
|
||||
if (timer->tim_active)
|
||||
clck_fast_release(timer);
|
||||
|
@ -111,9 +111,9 @@ message *mess;
|
|||
}
|
||||
|
||||
static void clck_fast_release (timer)
|
||||
timer_t *timer;
|
||||
minix_timer_t *timer;
|
||||
{
|
||||
timer_t *timer_index;
|
||||
minix_timer_t *timer_index;
|
||||
|
||||
if (!timer->tim_active)
|
||||
return;
|
||||
|
@ -158,7 +158,7 @@ static void set_timer()
|
|||
}
|
||||
|
||||
void clck_untimer (timer)
|
||||
timer_t *timer;
|
||||
minix_timer_t *timer;
|
||||
{
|
||||
clck_fast_release (timer);
|
||||
set_timer();
|
||||
|
@ -167,7 +167,7 @@ timer_t *timer;
|
|||
void clck_expire_timers()
|
||||
{
|
||||
time_t now;
|
||||
timer_t *timer_index;
|
||||
minix_timer_t *timer_index;
|
||||
|
||||
clck_call_expire= 0;
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ typedef struct arp_port
|
|||
|
||||
struct arp_req
|
||||
{
|
||||
timer_t ar_timer;
|
||||
minix_timer_t ar_timer;
|
||||
int ar_entry;
|
||||
int ar_req_count;
|
||||
} ap_req[AP_REQ_NR];
|
||||
|
@ -139,7 +139,7 @@ static acc_t *arp_getdata ARGS(( int fd, size_t offset,
|
|||
static int arp_putdata ARGS(( int fd, size_t offset,
|
||||
acc_t *data, int for_ioctl ));
|
||||
static void arp_main ARGS(( arp_port_t *arp_port ));
|
||||
static void arp_timeout ARGS(( int ref, timer_t *timer ));
|
||||
static void arp_timeout ARGS(( int ref, minix_timer_t *timer ));
|
||||
static void setup_write ARGS(( arp_port_t *arp_port ));
|
||||
static void setup_read ARGS(( arp_port_t *arp_port ));
|
||||
static void do_reclist ARGS(( event_t *ev, ev_arg_t ev_arg ));
|
||||
|
@ -1193,7 +1193,7 @@ put_userdata_t put_userdata;
|
|||
|
||||
static void arp_timeout (ref, timer)
|
||||
int ref;
|
||||
timer_t *timer;
|
||||
minix_timer_t *timer;
|
||||
{
|
||||
int i, port, reqind, acind;
|
||||
arp_port_t *arp_port;
|
||||
|
|
|
@ -7,18 +7,18 @@ Copyright 1995 Philip Homburg
|
|||
#ifndef CLOCK_H
|
||||
#define CLOCK_H
|
||||
|
||||
struct timer;
|
||||
struct minix_timer;
|
||||
|
||||
typedef void (*timer_func_t) ARGS(( int fd, struct timer *timer ));
|
||||
typedef void (*timer_func_t) ARGS(( int fd, struct minix_timer *timer ));
|
||||
|
||||
typedef struct timer
|
||||
typedef struct minix_timer
|
||||
{
|
||||
struct timer *tim_next;
|
||||
struct minix_timer *tim_next;
|
||||
timer_func_t tim_func;
|
||||
int tim_ref;
|
||||
time_t tim_time;
|
||||
int tim_active;
|
||||
} timer_t;
|
||||
} minix_timer_t;
|
||||
|
||||
extern int clck_call_expire; /* Call clck_expire_timer from the mainloop */
|
||||
|
||||
|
@ -27,9 +27,9 @@ void set_time ARGS(( clock_t time ));
|
|||
time_t get_time ARGS(( void ));
|
||||
void reset_time ARGS(( void ));
|
||||
/* set a timer to go off at the time specified by timeout */
|
||||
void clck_timer ARGS(( struct timer *timer, time_t timeout, timer_func_t func,
|
||||
void clck_timer ARGS(( minix_timer_t *timer, time_t timeout, timer_func_t func,
|
||||
int fd ));
|
||||
void clck_untimer ARGS(( struct timer *timer ));
|
||||
void clck_untimer ARGS(( minix_timer_t *timer ));
|
||||
void clck_expire_timers ARGS(( void ));
|
||||
|
||||
#endif /* CLOCK_H */
|
||||
|
|
|
@ -160,7 +160,7 @@ typedef struct tcp_conn
|
|||
u16_t tc_mtu; /* discovered PMTU */
|
||||
clock_t tc_mtutim; /* Last time MTU/TCF_PMTU flag was changed */
|
||||
|
||||
struct timer tc_transmit_timer;
|
||||
minix_timer_t tc_transmit_timer;
|
||||
u32_t tc_transmit_seq;
|
||||
clock_t tc_0wnd_to;
|
||||
clock_t tc_stt; /* time of first send after last ack */
|
||||
|
|
|
@ -20,7 +20,7 @@ Copyright 1995 Philip Homburg
|
|||
THIS_FILE
|
||||
|
||||
static acc_t *make_pack ARGS(( tcp_conn_t *tcp_conn ));
|
||||
static void tcp_send_timeout ARGS(( int conn, struct timer *timer ));
|
||||
static void tcp_send_timeout ARGS(( int conn, minix_timer_t *timer ));
|
||||
static void do_snd_event ARGS(( event_t *ev, ev_arg_t arg ));
|
||||
|
||||
void tcp_conn_write (tcp_conn, enq)
|
||||
|
@ -812,7 +812,7 @@ tcp_send_timeout
|
|||
|
||||
static void tcp_send_timeout(conn, timer)
|
||||
int conn;
|
||||
struct timer *timer;
|
||||
minix_timer_t *timer;
|
||||
{
|
||||
tcp_conn_t *tcp_conn;
|
||||
u16_t mss, mss2;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* Debugging dump procedures for the kernel. */
|
||||
|
||||
#include "inc.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <assert.h>
|
||||
#include <machine/interrupt.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "inc.h"
|
||||
#include "../pm/mproc.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <minix/config.h>
|
||||
#include <minix/type.h>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "inc.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <minix/rs.h>
|
||||
#include "kernel/priv.h"
|
||||
#include "../rs/const.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "inc.h"
|
||||
#include <sys/mman.h>
|
||||
#include <minix/vm.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
#define LINES 24
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <unistd.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <sys/svrctl.h>
|
||||
#include <minix/ds.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
endpoint_t lwip_ep;
|
||||
|
||||
static timer_t tcp_ftmr, tcp_stmr, arp_tmr;
|
||||
static minix_timer_t tcp_ftmr, tcp_stmr, arp_tmr;
|
||||
static int arp_ticks, tcp_fticks, tcp_sticks;
|
||||
|
||||
static struct netif * netif_lo;
|
||||
|
@ -38,19 +38,19 @@ static void sys_init(void)
|
|||
{
|
||||
}
|
||||
|
||||
static void arp_watchdog(__unused timer_t *tp)
|
||||
static void arp_watchdog(__unused minix_timer_t *tp)
|
||||
{
|
||||
etharp_tmr();
|
||||
set_timer(&arp_tmr, arp_ticks, arp_watchdog, 0);
|
||||
}
|
||||
|
||||
static void tcp_fwatchdog(__unused timer_t *tp)
|
||||
static void tcp_fwatchdog(__unused minix_timer_t *tp)
|
||||
{
|
||||
tcp_fasttmr();
|
||||
set_timer(&tcp_ftmr, tcp_fticks, tcp_fwatchdog, 0);
|
||||
}
|
||||
|
||||
static void tcp_swatchdog(__unused timer_t *tp)
|
||||
static void tcp_swatchdog(__unused minix_timer_t *tp)
|
||||
{
|
||||
tcp_slowtmr();
|
||||
set_timer(&tcp_ftmr, tcp_sticks, tcp_swatchdog, 0);
|
||||
|
|
|
@ -26,7 +26,7 @@ static void getset_vtimer(struct mproc *mp, int nwhich, struct
|
|||
itimerval *value, struct itimerval *ovalue);
|
||||
static void get_realtimer(struct mproc *mp, struct itimerval *value);
|
||||
static void set_realtimer(struct mproc *mp, struct itimerval *value);
|
||||
static void cause_sigalrm(struct timer *tp);
|
||||
static void cause_sigalrm(minix_timer_t *tp);
|
||||
|
||||
/*===========================================================================*
|
||||
* ticks_from_timeval *
|
||||
|
@ -345,7 +345,7 @@ clock_t ticks; /* how many ticks delay before the signal */
|
|||
* cause_sigalrm *
|
||||
*===========================================================================*/
|
||||
static void cause_sigalrm(tp)
|
||||
struct timer *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
int proc_nr_n;
|
||||
register struct mproc *rmp;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* of corresponding slots referring to the same process in all three.
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
@ -50,7 +50,7 @@ EXTERN struct mproc {
|
|||
char mp_padding[60]; /* align structure with new libc */
|
||||
#endif
|
||||
vir_bytes mp_sigreturn; /* address of C library __sigreturn function */
|
||||
struct timer mp_timer; /* watchdog timer for alarm(2), setitimer(2) */
|
||||
minix_timer_t mp_timer; /* watchdog timer for alarm(2), setitimer(2) */
|
||||
clock_t mp_interval[NR_ITIMERS]; /* setitimer(2) repetition intervals */
|
||||
|
||||
unsigned mp_flags; /* flag bits */
|
||||
|
|
|
@ -5,7 +5,7 @@ struct stat;
|
|||
struct mem_map;
|
||||
struct memory;
|
||||
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
/* alarm.c */
|
||||
int do_alarm(void);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "mproc.h"
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "param.h"
|
||||
|
||||
#include <minix/config.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <string.h>
|
||||
#include <machine/archtypes.h>
|
||||
#include "kernel/const.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <lib.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <minix/callnr.h>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <minix/priv.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h> /* For priv.h */
|
||||
#include <minix/timers.h> /* For priv.h */
|
||||
#include "kernel/priv.h"
|
||||
#include "kernel/ipc.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* Function prototypes. */
|
||||
|
||||
struct schedproc;
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
/* main.c */
|
||||
int main(void);
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
#include <machine/archtypes.h>
|
||||
#include "kernel/proc.h" /* for queue constants */
|
||||
|
||||
static timer_t sched_timer;
|
||||
static minix_timer_t sched_timer;
|
||||
static unsigned balance_timeout;
|
||||
|
||||
#define BALANCE_TIMEOUT 5 /* how often to balance queues in seconds */
|
||||
|
||||
static int schedule_process(struct schedproc * rmp, unsigned flags);
|
||||
static void balance_queues(struct timer *tp);
|
||||
static void balance_queues(minix_timer_t *tp);
|
||||
|
||||
#define SCHEDULE_CHANGE_PRIO 0x1
|
||||
#define SCHEDULE_CHANGE_QUANTUM 0x2
|
||||
|
@ -348,7 +348,7 @@ void init_scheduling(void)
|
|||
* quantum. This function will find all proccesses that have been bumped down,
|
||||
* and pulls them back up. This default policy will soon be changed.
|
||||
*/
|
||||
static void balance_queues(struct timer *tp)
|
||||
static void balance_queues(minix_timer_t *tp)
|
||||
{
|
||||
struct schedproc *rmp;
|
||||
int proc_nr;
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
|
||||
/* Function prototypes. */
|
||||
|
||||
#include "timers.h"
|
||||
#include "request.h"
|
||||
#include "tll.h"
|
||||
#include "threads.h"
|
||||
#include <minix/rs.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#include "request.h"
|
||||
#include "threads.h"
|
||||
#include "tll.h"
|
||||
|
||||
/* Structs used in prototypes must be declared as such first. */
|
||||
struct filp;
|
||||
|
@ -357,7 +358,7 @@ void select_callback(struct filp *, int ops);
|
|||
void select_forget(void);
|
||||
void select_reply1(endpoint_t driver_e, int minor, int status);
|
||||
void select_reply2(endpoint_t driver_e, int minor, int status);
|
||||
void select_timeout_check(timer_t *);
|
||||
void select_timeout_check(minix_timer_t *);
|
||||
void select_unsuspend_by_endpt(endpoint_t proc);
|
||||
|
||||
/* worker.c */
|
||||
|
|
|
@ -45,7 +45,7 @@ static struct selectentry {
|
|||
char block;
|
||||
char starting;
|
||||
clock_t expiry;
|
||||
timer_t timer; /* if expiry > 0 */
|
||||
minix_timer_t timer; /* if expiry > 0 */
|
||||
} selecttab[MAXSELECTS];
|
||||
|
||||
static int copy_fdsets(struct selectentry *se, int nfds, int direction);
|
||||
|
@ -704,7 +704,7 @@ void select_forget(void)
|
|||
/*===========================================================================*
|
||||
* select_timeout_check *
|
||||
*===========================================================================*/
|
||||
void select_timeout_check(timer_t *timer)
|
||||
void select_timeout_check(minix_timer_t *timer)
|
||||
{
|
||||
/* An alarm has gone off for one of the select queries. This function MUST NOT
|
||||
* block its calling thread.
|
||||
|
|
|
@ -10,7 +10,7 @@ struct phys_region;
|
|||
#include <minix/endpoint.h>
|
||||
#include <minix/safecopies.h>
|
||||
#include <minix/vm.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pt.h"
|
||||
|
|
|
@ -55,10 +55,7 @@
|
|||
#define _BSD_SSIZE_T_ int /* byte count or error */
|
||||
#define _BSD_TIME_T_ int /* time() */
|
||||
#define _BSD_CLOCKID_T_ int /* clockid_t */
|
||||
#if !defined(__minix)
|
||||
/* Conflict with minix timer_t struct. */
|
||||
#define _BSD_TIMER_T_ int /* timer_t */
|
||||
#endif /* !defined(__minix) */
|
||||
#define _BSD_SUSECONDS_T_ int /* suseconds_t */
|
||||
#define _BSD_USECONDS_T_ unsigned int /* useconds_t */
|
||||
#define _BSD_WCHAR_T_ int /* wchar_t */
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
* @(#)ansi.h 8.2 (Berkeley) 1/4/94
|
||||
*/
|
||||
|
||||
/* These types are Minix specific. */
|
||||
|
||||
#ifndef _I386_ANSI_H_
|
||||
#define _I386_ANSI_H_
|
||||
|
@ -55,10 +54,7 @@
|
|||
#define _BSD_SSIZE_T_ int /* byte count or error */
|
||||
#define _BSD_TIME_T_ int /* time() */
|
||||
#define _BSD_CLOCKID_T_ int /* clockid_t */
|
||||
#if !defined(__minix)
|
||||
/* Conflict with minix timer_t struct. */
|
||||
#define _BSD_TIMER_T_ int /* timer_t */
|
||||
#endif /* !defined(__minix) */
|
||||
#define _BSD_SUSECONDS_T_ int /* suseconds_t */
|
||||
#define _BSD_USECONDS_T_ unsigned int /* useconds_t */
|
||||
#define _BSD_WCHAR_T_ int /* wchar_t */
|
||||
|
|
|
@ -281,10 +281,8 @@ int getitimer(int, struct itimerval *) __RENAME(__getitimer50);
|
|||
int gettimeofday(struct timeval * __restrict, void *__restrict);
|
||||
int setitimer(int, const struct itimerval * __restrict,
|
||||
struct itimerval * __restrict) __RENAME(__setitimer50);
|
||||
#endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
int utimes(const char *, const struct timeval [2]) __RENAME(__utimes50);
|
||||
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
#endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
|
||||
#if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H)
|
||||
int adjtime(const struct timeval *, struct timeval *) __RENAME(__adjtime50);
|
||||
|
|
|
@ -324,13 +324,10 @@ typedef _BSD_CLOCKID_T_ clockid_t;
|
|||
#undef _BSD_CLOCKID_T_
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
/* LSC: timer_t is defined as a struct on minix. */
|
||||
#ifdef _BSD_TIMER_T_
|
||||
typedef _BSD_TIMER_T_ timer_t;
|
||||
#undef _BSD_TIMER_T_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SUSECONDS_T_
|
||||
typedef _BSD_SUSECONDS_T_ suseconds_t;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <curses.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <termcap.h>
|
||||
|
|
Loading…
Reference in a new issue