1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/include/ke/sched.h

81 lines
3.2 KiB
C
Raw Normal View History

2019-01-21 15:00:04 +01:00
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
2019-02-16 23:36:33 +01:00
// Desc: Scheduler-related functions //
2019-01-21 15:00:04 +01:00
// //
2019-02-16 23:36:33 +01:00
// //
// Copyright © 2018-2020 The OS/K Team //
2019-02-16 23:36:33 +01:00
// //
// This file is part of OS/K. //
// //
// OS/K is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// any later version. //
// //
// OS/K is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
2019-01-21 15:00:04 +01:00
//----------------------------------------------------------------------------//
2019-05-13 23:22:27 +02:00
#ifndef _KERNEL_H
#include <kernel.h>
2019-01-21 15:00:04 +01:00
#endif
#ifndef _KALKERN_SCHED_H
#define _KALKERN_SCHED_H
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
2019-01-21 15:00:04 +01:00
2019-02-16 23:36:33 +01:00
//
// Value of the preemption count indicating that preemption is activated
//
enum { PREEMPT_ON = 0 };
2019-01-21 15:00:04 +01:00
// Time in ticks a process should be run
2019-02-16 23:36:33 +01:00
enum
{
2019-03-25 17:33:51 +01:00
DEF_PROC_TSLICE = 3, // 20 ticks
2019-02-16 23:36:33 +01:00
TCR_PROC_TSLICE = 20000 // 20000 ticks (time critical)
};
// Priority classes
enum
{
TIME_CRIT_PROC = 0,
SERV_PRIO_PROC = 1,
REGL_PRIO_PROC = 2,
IDLE_PRIO_PROC = 3,
};
// Names of the priority classes
2019-03-24 14:44:59 +01:00
extern const char *PsPrioClassesNames[];
2019-01-21 15:00:04 +01:00
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
2019-01-21 15:00:04 +01:00
2019-02-16 23:36:33 +01:00
//
// Re-scheduling and preemption
// XXX atomic operations
//
2020-02-11 11:16:24 +01:00
#define PsRequestReSched() do { ++KeCurCPU->needReSched; } while (0)
#define PsDisablePreemption() do { ++KeCurCPU->preemptCount; } while (0)
2019-04-05 10:20:10 +02:00
#define PsEnablePreemption() do { assert(KeCurCPU->preemptCount > 0); \
--KeCurCPU->preemptCount; } while(0)
2019-02-16 23:36:33 +01:00
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
2019-02-16 23:36:33 +01:00
2019-03-24 14:44:59 +01:00
void PsInitSched(void);
void PsFiniSched(void);
2019-01-21 15:00:04 +01:00
2019-03-24 14:44:59 +01:00
void PsSchedThisProc(Process_t *);
void PsSchedOnTick(void);
2019-01-21 15:00:04 +01:00
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
2019-01-21 15:00:04 +01:00
#endif