os-k/kaleid/include/kernel/kernsched.h

116 lines
3.0 KiB
C
Raw Normal View History

2019-01-14 14:31:49 +01:00
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Scheduler header //
//----------------------------------------------------------------------------//
//------------------------------------------//
// Dependencies //
//------------------------------------------//
#ifndef _KALKERN_BASE_H
#include "kernbase.h"
#endif
#ifndef _KALLIST_H
#include <common/kallist.h>
#endif
//------------------------------------------//
// Start of header //
//------------------------------------------//
#ifndef _KALKERN_SCHED_H
#define _KALKERN_SCHED_H
//------------------------------------------//
// Preprocessor //
//------------------------------------------//
2019-01-19 22:36:38 +01:00
//
// Debug stuff
//
2019-01-14 14:31:49 +01:00
#define printdbg printf
//
// States for a process
//
#define STATE_RUNNING 0
#define STATE_RUNNABLE 1
#define STATE_BLOCKED 2
//
// Time in ticks a process should be run
//
#define DEF_PROC_TSLICE 5 // 20 ticks
#define TCR_PROC_TSLICE 20000 // 20000 ticks (time critical)
//------------------------------------------//
// List heads //
//------------------------------------------//
DECLARE_PER_CPU(IdlePrioProcs, ListHead_t *);
DECLARE_PER_CPU(ReglPrioProcs, ListHead_t *);
DECLARE_PER_CPU(ServPrioProcs, ListHead_t *);
DECLARE_PER_CPU(TimeCritProcs, ListHead_t *);
2019-01-19 22:36:38 +01:00
extern const char *PrioClassesNames[];
2019-01-14 14:31:49 +01:00
//------------------------------------------//
// Data types //
//------------------------------------------//
//
// A process
//
2019-01-19 22:36:38 +01:00
typedef struct sProcess_t {
2019-01-14 14:31:49 +01:00
// Identifier
int pid;
// Current priority class
int prioClass;
// Default priority class (without boosts)
int defPrioClass;
// Current priority level
int prioLevel;
// Default priority level
int defPrioLevel;
// Current state
int procState;
// Remaining time running
ulong timeSlice;
// Default time-slice
ulong defTimeSlice;
// Scheduler internals
ListNode_t *schedNode;
} Process_t;
2019-01-19 22:36:38 +01:00
//------------------------------------------//
// Functions //
//------------------------------------------//
void SchedInit(void);
void SchedFini(void);
void SchedThisProc(Process_t *);
void SchedOnTick(void);
2019-01-14 14:31:49 +01:00
//------------------------------------------//
// End of header //
//------------------------------------------//
#endif