
Now that clock_t is an unsigned value, we can also allow the system uptime to wrap. Essentially, instead of using (a <= b) to see if time a occurs no later than time b, we use (b - a <= CLOCK_MAX / 2). The latter value does not exist, so instead we add TMRDIFF_MAX for that purpose. We must therefore also avoid using values like 0 and LONG_MAX as special values for absolute times. This patch extends the libtimers interface so that it no longer uses 0 to indicate "no timeout". Similarly, TMR_NEVER is now used as special value only when otherwise a relative time difference would be used. A minix_timer structure is now considered in use when it has a watchdog function set, rather than when the absolute expiry time is not TMR_NEVER. A few new macros in <minix/timers.h> help with timer comparison and obtaining properties from a minix_timer structure. This patch also eliminates the union of timer arguments, instead using the only union element that is only used (the integer). This prevents potential problems with e.g. live update. The watchdog function prototype is changed to pass in the argument value rather than a pointer to the timer structure, since obtaining the argument value was the only current use of the timer structure anyway. The result is a somewhat friendlier timers API. The VFS select code required a few more invasive changes to restrict the timer value to the new maximum, effectively matching the timer code in PM. As a side effect, select(2) has been changed to reject invalid timeout values. That required a change to the test set, which relied on the previous, erroneous behavior. Finally, while we're rewriting significant chunks of the timer code anyway, also covert it to KNF and add a few more explanatory comments. Change-Id: Id43165c3fbb140b32b90be2cca7f68dd646ea72e
21 lines
786 B
C
21 lines
786 B
C
/* Constants used by the Process Manager. */
|
|
|
|
#define NR_PIDS 30000 /* process ids range from 0 to NR_PIDS-1.
|
|
* (magic constant: some old applications use
|
|
* a 'short' instead of pid_t.)
|
|
*/
|
|
|
|
#define NO_PID 0 /* pid value indicating no process */
|
|
#define INIT_PID 1 /* INIT's process id number */
|
|
|
|
#define NO_TRACER 0 /* process is not being traced */
|
|
|
|
#define NO_EVENTSUB ((char)-1) /* no current process event subscriber */
|
|
|
|
#define MAX_SECS ( (clock_t) (TMRDIFF_MAX/system_hz) )
|
|
/* max.secs for setitimer() ((2^31-1)/HZ) */
|
|
#define NR_ITIMERS 3 /* number of supported interval timers */
|
|
|
|
#define SEND_PRIORITY 1 /* send current priority queue to scheduler */
|
|
#define SEND_TIME_SLICE 2 /* send current time slice to scheduler */
|