From 427a5fbaef0ea29fa0668668b7570f0e81d230a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Wed, 13 Aug 2014 09:33:25 +0200 Subject: [PATCH] core: let valid PIDs start with 1 --- core/include/kernel_types.h | 2 +- core/include/sched.h | 4 ++-- core/sched.c | 4 ++-- cpu/x86/x86_hwtimer.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/include/kernel_types.h b/core/include/kernel_types.h index af5f03927..955df27ba 100644 --- a/core/include/kernel_types.h +++ b/core/include/kernel_types.h @@ -15,7 +15,7 @@ /** * Canonical identifier for an invalid PID. */ -#define KERNEL_PID_UNDEF -1 +#define KERNEL_PID_UNDEF 0 /** * The first valid PID (inclusive). diff --git a/core/include/sched.h b/core/include/sched.h index 5346262e0..822a3dc16 100644 --- a/core/include/sched.h +++ b/core/include/sched.h @@ -133,7 +133,7 @@ extern volatile unsigned int sched_context_switch_request; /** * Thread table */ -extern volatile tcb_t *sched_threads[MAXTHREADS]; +extern volatile tcb_t *sched_threads[KERNEL_PID_LAST + 1]; /** * Currently active thread @@ -169,7 +169,7 @@ typedef struct { /** * Thread statistics table */ -extern schedstat sched_pidlist[MAXTHREADS]; +extern schedstat sched_pidlist[KERNEL_PID_LAST + 1]; /** * @brief Register a callback that will be called on every scheduler run diff --git a/core/sched.c b/core/sched.c index 05fcf962e..a8299d7c7 100644 --- a/core/sched.c +++ b/core/sched.c @@ -40,7 +40,7 @@ volatile int sched_num_threads = 0; volatile unsigned int sched_context_switch_request; -volatile tcb_t *sched_threads[MAXTHREADS]; +volatile tcb_t *sched_threads[KERNEL_PID_LAST + 1]; volatile tcb_t *sched_active_thread; volatile kernel_pid_t sched_active_pid = KERNEL_PID_UNDEF; @@ -50,7 +50,7 @@ static uint32_t runqueue_bitcache = 0; #if SCHEDSTATISTICS static void (*sched_cb) (uint32_t timestamp, uint32_t value) = NULL; -schedstat sched_pidlist[MAXTHREADS]; +schedstat sched_pidlist[KERNEL_PID_LAST + 1]; #endif void sched_run(void) diff --git a/cpu/x86/x86_hwtimer.c b/cpu/x86/x86_hwtimer.c index b222d200c..9484e1a62 100644 --- a/cpu/x86/x86_hwtimer.c +++ b/cpu/x86/x86_hwtimer.c @@ -91,7 +91,7 @@ static void flip_periodic_interrupt_called(uint8_t reg_c) static void measure_nop_nop_nops_per_tick(void) { x86_rtc_set_periodic_callback(flip_periodic_interrupt_called); - x86_rtc_set_periodic(TICK_HZ_REG_A, 0, 0, true); + x86_rtc_set_periodic(TICK_HZ_REG_A, 0, KERNEL_PID_FIRST, true); for (unsigned i = 0; i < NNN_TICK_ITERATIONS; ++i) { periodic_interrupt_called = false; @@ -132,7 +132,7 @@ static void update_cb(uint8_t reg_c) static void init_bases(void) { x86_rtc_set_periodic_callback(update_cb); - x86_rtc_set_periodic(RTC_REG_A_HZ_2, 0, 0, true); + x86_rtc_set_periodic(RTC_REG_A_HZ_2, 0, KERNEL_PID_FIRST, true); eINT(); periodic_interrupt_called = false;