2010-09-22 15:10:42 +02:00
|
|
|
/**
|
|
|
|
* @ingroup kernel
|
|
|
|
* @{
|
|
|
|
* @file
|
|
|
|
* @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SCHEDULER_H
|
|
|
|
#define _SCHEDULER_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <bitarithm.h>
|
|
|
|
#include "tcb.h"
|
|
|
|
|
|
|
|
#define MAXTHREADS 32
|
|
|
|
|
2010-10-29 17:32:03 +02:00
|
|
|
#if ARCH_32_BIT
|
2010-09-22 15:10:42 +02:00
|
|
|
#define SCHED_PRIO_LEVELS 32
|
|
|
|
#else
|
|
|
|
#define SCHED_PRIO_LEVELS 16
|
|
|
|
#endif
|
|
|
|
|
2010-10-28 11:22:57 +02:00
|
|
|
void sched_init();
|
|
|
|
void sched_run();
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
void sched_set_status(tcb *process, unsigned int status);
|
2010-11-11 09:55:08 +01:00
|
|
|
void sched_switch_if_higher(uint16_t current_prio, uint16_t other_prio, int in_isr);
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2010-10-28 11:22:57 +02:00
|
|
|
volatile unsigned int sched_context_switch_request;
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2010-10-28 11:22:57 +02:00
|
|
|
volatile tcb *sched_threads[MAXTHREADS];
|
|
|
|
volatile tcb *active_thread;
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
extern volatile int num_tasks;
|
2010-10-28 11:22:57 +02:00
|
|
|
volatile int thread_pid;
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
//#define SCHEDSTATISTICS
|
|
|
|
#if SCHEDSTATISTICS
|
|
|
|
|
|
|
|
typedef struct schedstat {
|
|
|
|
unsigned int laststart;
|
|
|
|
unsigned int schedules;
|
|
|
|
unsigned int runtime;
|
|
|
|
}schedstat;
|
|
|
|
|
|
|
|
extern schedstat pidlist[MAXTHREADS];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
#endif // _SCHEDULER_H
|