From 40b1d58077256e9ec8715e800019608a1e8cab5f Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Tue, 29 Sep 2009 20:13:41 +0000 Subject: [PATCH] Mostly a revert of r5306. com.h defines MAX_NR_TASKS value which replaces NR_TASKS in the endpoint macros. MAX_NR_TASKS defines the maximal number of kernel tasks. It is unlikely that we will ever need this many tasks as the goal is not to have such a difference in the future. For now it makes possible to remove the limiting NR_TASKS from the endpoint code. --- include/minix/com.h | 7 +++---- include/minix/endpoint.h | 13 ++++++------- test/test39.c | 5 +++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/minix/com.h b/include/minix/com.h index 33c860980..b4d24d8f2 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -9,10 +9,8 @@ #define ANY 0x7ace /* used to indicate 'any process' */ #define NONE 0x6ace /* used to indicate 'no process at all' */ #define SELF 0x8ace /* used to indicate 'own process' */ -/* check if the magic process numbers are valid process table slot numbers */ -#if (ANY < NR_PROCS) -#error "Magic process number in the process table range" -#endif +#define _MAX_MAGIC_PROC (SELF) /* used by + to determine generation size */ /*===========================================================================* * Process numbers of processes in the system image * @@ -33,6 +31,7 @@ #define HARDWARE KERNEL /* for hardware interrupt handlers */ /* Number of tasks. Note that NR_PROCS is defined in . */ +#define MAX_NR_TASKS 1023 #define NR_TASKS 4 /* User-space processes, that is, device drivers, servers, and INIT. */ diff --git a/include/minix/endpoint.h b/include/minix/endpoint.h index a646d1657..54dc7b9d6 100644 --- a/include/minix/endpoint.h +++ b/include/minix/endpoint.h @@ -16,14 +16,13 @@ * the generation size is big enough to start the next generation * above the highest magic number. */ -#define _ENDPOINT_GENERATION_BITS 16 -#define _ENDPOINT_PNUM_BITS 16 -#define _ENDPOINT_MAX_GENERATION ((1 << _ENDPOINT_GENERATION_BITS)-1) -#define _ENDPOINT_MAX_PNUM ((1 << _ENDPOINT_PNUM_BITS) - 1) +#define _ENDPOINT_GENERATION_SIZE (MAX_NR_TASKS+_MAX_MAGIC_PROC+1) +#define _ENDPOINT_MAX_GENERATION (INT_MAX/_ENDPOINT_GENERATION_SIZE-1) /* Generation + Process slot number <-> endpoint. */ -#define _ENDPOINT(g, p) ((endpoint_t)(((g) << _ENDPOINT_PNUM_BITS) | (p))) -#define _ENDPOINT_G(e) ((u16_t)((e) >> _ENDPOINT_PNUM_BITS)) -#define _ENDPOINT_P(e) ((i16_t)((e) & _ENDPOINT_MAX_PNUM)) +#define _ENDPOINT(g, p) ((endpoint_t)((g) * _ENDPOINT_GENERATION_SIZE + (p))) +#define _ENDPOINT_G(e) (((e)+MAX_NR_TASKS) / _ENDPOINT_GENERATION_SIZE) +#define _ENDPOINT_P(e) \ + ((((e)+MAX_NR_TASKS) % _ENDPOINT_GENERATION_SIZE) - MAX_NR_TASKS) #endif diff --git a/test/test39.c b/test/test39.c index cd99ff7cb..928776153 100644 --- a/test/test39.c +++ b/test/test39.c @@ -10,8 +10,9 @@ int main(int argc, char *argv[]) printf("Test 39 "); for(g = 0; g <= _ENDPOINT_MAX_GENERATION; g++) { - for(p = -NR_TASKS; p < _NR_PROCS; p++) { - int e, mg, mp; + for(p = -MAX_NR_TASKS; p < _NR_PROCS; p++) { + endpoint_t e; + int mg, mp; e = _ENDPOINT(g, p); mg = _ENDPOINT_G(e); mp = _ENDPOINT_P(e); -- 2.44.0