blob: 9bfce1d675d4e5d8252f736d7ce953840296cb22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* ========================================
Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
======================================== */
#pragma once
/// @file KernelTaskScheduler.h
/// @brief Kernel Task Scheduler header file.
/// @author Amlal El Mahrouss (amlal@nekernel.org)
#include <ArchKit/ArchKit.h>
#include <KernelKit/CoreProcessScheduler.h>
#include <KernelKit/LockDelegate.h>
namespace Kernel {
class KernelTaskHelper;
typedef ProcessID KID;
/// @brief Equivalent of USER_PROCESS, but for kernel tasks.
/// @author Amlal
class KERNEL_TASK final {
public:
Char Name[kSchedNameLen] = {"KERNEL_TASK"};
ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemKernel};
HAL::StackFramePtr StackFrame{nullptr};
UInt8* StackReserve{nullptr};
SizeT StackSize{kSchedMaxStackSz};
ProcessImage Image{};
/// @brief a KID is a Kernel ID, it is used to find a task running within
/// the kernel.
KID Kid{0};
};
/// @brief Equivalent of UserProcessHelper, but for kernel tasks.
/// @author Amlal
class KernelTaskHelper final {
public:
STATIC Bool Add(HAL::StackFramePtr frame_ptr, ProcessID new_kid);
STATIC Bool Remove(const KID kid);
STATIC Bool CanBeScheduled(const KERNEL_TASK& process);
STATIC ErrorOr<KID> TheCurrentKID();
STATIC SizeT StartScheduling();
};
} // namespace Kernel
|