Browse Source

core: let valid PIDs start with 1

dev/timer
René Kijewski 9 years ago
parent
commit
427a5fbaef
  1. 2
      core/include/kernel_types.h
  2. 4
      core/include/sched.h
  3. 4
      core/sched.c
  4. 4
      cpu/x86/x86_hwtimer.c

2
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).

4
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

4
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)

4
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;

Loading…
Cancel
Save