#ifndef __thread_h
#define __thread_h
#include <system/kmalloc.h>
#include <utility/queue.h>
#include <utility/handler.h>
#include <cpu.h>
#include <scheduler.h>
__BEGIN_SYS
class Thread
{
friend class Scheduler<Thread>;
protected:
template <typename T, int workaround = 0>
class Priority_Updater{ public: static void update(Thread * prev, Thread * next){} };
template <int workaround>
class Priority_Updater<Scheduling_Criteria::LLF, workaround>{
public:
static void update(Thread * prev, Thread * next){
((Scheduling_Criteria::Priority)(prev->link()->rank())).update(prev->computation_start());
next->reset_computation_start();
((Scheduling_Criteria::Priority)(next->link()->rank())).reset();
}
};
...
Timer::Tick computation_start() {return _computation_start;}
void reset_computation_start()
...
static void dispatch(Thread * prev, Thread * next, bool charge = true) {
if(charge)
if(active_scheduler)
Thread::Priority_Updater<Traits<Thread>::Criterion>::update(prev, next);
...
...
protected:
Timer::Tick _computation_start;
...