summaryrefslogtreecommitdiffhomepage
path: root/Kernel
diff options
context:
space:
mode:
authorAmlal <amlal@zka.com>2024-07-20 08:43:16 +0200
committerAmlal <amlal@zka.com>2024-07-20 08:43:16 +0200
commit650fee520f526d9cd5ffa75735bd94d5140dd247 (patch)
tree5967c57a2e754c0f46bccfba40a915a680dcaa10 /Kernel
parent81b284cacb03b34ae259c485ac874b02c8ecba69 (diff)
[IMP] See below.
- Revoke OTA flag for now inside bootloader (newosldr #4) - Rework Comm as SCI (System Call Interface) (newoskrnl #3) - Rework and fix some parts of the scheduler (newoskrnl #2) - Return from thread when region is zero (newosldr #1) - Separate allocation functions and c++ runtime from each other. (DDK #5) - Rename kHartStandard to kStandard (newoskrnl #6) Signed-off-by: Amlal <amlal@zka.com>
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx10
-rw-r--r--Kernel/KernelKit/ProcessHeap.hxx2
-rw-r--r--Kernel/KernelKit/ProcessScheduler.hxx24
-rw-r--r--Kernel/KernelKit/RLE.hxx3
-rw-r--r--Kernel/Sources/ProcessScheduler.cxx20
-rw-r--r--Kernel/Sources/SMPManager.cxx14
6 files changed, 46 insertions, 27 deletions
diff --git a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
index 327ee665..29c0f3c7 100644
--- a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
+++ b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cxx
@@ -14,7 +14,7 @@ EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp)
{
Kernel::kcout
<< "newoskrnl: General Protection Fault, caused by "
- << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetName();
+ << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetProcessName();
Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
}
@@ -25,7 +25,7 @@ EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp)
{
Kernel::kcout
<< "newoskrnl: Segmentation Fault, caused by "
- << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetName();
+ << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetProcessName();
Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
}
@@ -36,7 +36,7 @@ EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp)
{
Kernel::kcout
<< "newoskrnl: Math error, caused by "
- << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetName();
+ << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetProcessName();
Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
}
@@ -47,7 +47,7 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp)
{
Kernel::kcout
<< "newoskrnl: Execution error, caused by "
- << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetName();
+ << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetProcessName();
Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
}
@@ -58,7 +58,7 @@ EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp)
{
Kernel::kcout
<< "newoskrnl: Invalid interrupt, caused by "
- << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetName();
+ << Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetProcessName();
Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
}
diff --git a/Kernel/KernelKit/ProcessHeap.hxx b/Kernel/KernelKit/ProcessHeap.hxx
index 677aa835..d2ec4035 100644
--- a/Kernel/KernelKit/ProcessHeap.hxx
+++ b/Kernel/KernelKit/ProcessHeap.hxx
@@ -15,7 +15,7 @@
/// @version 5/11/23
/// @file ProcessHeap.hxx
-/// @brief memory heap for user processes.
+/// @brief Heap for user processes.
#define kUserHeapMaxSz (4096)
#define kUserHeapMag (0xFAF0FEF0)
diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx
index cbce2ec2..3f6e7828 100644
--- a/Kernel/KernelKit/ProcessScheduler.hxx
+++ b/Kernel/KernelKit/ProcessScheduler.hxx
@@ -13,7 +13,7 @@
#include <KernelKit/ProcessHeap.hxx>
#include <NewKit/MutableArray.hpp>
-#define kSchedMinMicroTime (AffinityKind::kHartStandard)
+#define kSchedMinMicroTime (AffinityKind::kStandard)
#define kSchedInvalidPID (-1)
#define kSchedProcessLimitPerTeam (16U)
@@ -58,7 +58,7 @@ namespace Kernel
kInvalid = 300,
kVeryHigh = 250,
kHigh = 200,
- kHartStandard = 150,
+ kStandard = 150,
kLowUsage = 100,
kVeryLowUsage = 50,
};
@@ -167,7 +167,7 @@ namespace Kernel
kKindCount,
};
- ProcessTime PTime;
+ ProcessTime PTime{0};
PID ProcessId{kSchedInvalidPID};
Int32 Kind{kAppKind};
@@ -178,25 +178,29 @@ namespace Kernel
return Status != ProcessStatus::kDead;
}
- //! @brief Crash the app, exits with code ~0.
+ ///! @brief Crashes the app, exits with code ~0.
Void Crash();
- //! @brief Exits app.
+ ///! @brief Exits the app.
Void Exit(Int32 exitCode = 0);
- //! @brief TLS Allocate
+ ///! @brief TLS allocate.
+ ///! @param sz size of new ptr.
VoidPtr New(const SizeT& sz);
- //! @brief TLS Free.
+ ///! @brief TLS free.
+ ///! @param ptr the pointer to free.
+ ///! @param sz the size of it.
Boolean Delete(VoidPtr ptr, const SizeT& sz);
- //! @brief Wakes up threads.
+ ///! @brief Wakes up threads.
Void Wake(const bool wakeup = false);
// ProcessHeader getters.
public:
- //! @brief ProcessHeader name getter, example: "C RunTime"
- const Char* GetName() noexcept;
+ ///! @brief Get the process's name
+ ///! @example 'C Runtime Library'
+ const Char* GetProcessName() noexcept;
//! @brief return local error code of process.
//! @return Int32 local error code.
diff --git a/Kernel/KernelKit/RLE.hxx b/Kernel/KernelKit/RLE.hxx
index e43d2462..9256c23b 100644
--- a/Kernel/KernelKit/RLE.hxx
+++ b/Kernel/KernelKit/RLE.hxx
@@ -9,4 +9,7 @@
#include <NewKit/Defines.hpp>
+EXTERN_C void rle_compress(void* data, long sz, void* out, long out_sz);
+EXTERN_C void rle_decompress(void* data, long sz, void* out, long out_sz);
+
#endif // !ifndef __KERNELKIT_RLE_HXX__
diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx
index a536bf52..34bc321d 100644
--- a/Kernel/Sources/ProcessScheduler.cxx
+++ b/Kernel/Sources/ProcessScheduler.cxx
@@ -138,7 +138,7 @@ namespace Kernel
}
/// @brief process name getter.
- const Char* ProcessHeader::GetName() noexcept
+ const Char* ProcessHeader::GetProcessName() noexcept
{
return this->Name;
}
@@ -273,21 +273,21 @@ namespace Kernel
{
auto unwrapped_process = *process.Leak();
- unwrapped_process.PTime = 0;
-
// set the current process.
mTeam.AsRef() = unwrapped_process;
// tell helper to find a core to schedule on.
- ProcessHelper::Switch(mTeam.AsRef().Leak().StackFrame,
- mTeam.AsRef().Leak().ProcessId);
+ ProcessHelper::Switch(unwrapped_process.StackFrame,
+ unwrapped_process.ProcessId);
+
+ unwrapped_process.PTime = static_cast<Int32>(unwrapped_process.Affinity);
- kcout << unwrapped_process.Name << ": process switched.\r";
+ kcout << unwrapped_process.Name << ": has been switched to process core.\r";
}
else
{
// otherwise increment the P-time.
- ++mTeam.AsRef().Leak().PTime;
+ --mTeam.AsRef().Leak().PTime;
}
}
@@ -336,10 +336,10 @@ namespace Kernel
if (process.Leak().GetStatus() == ProcessStatus::kStarting)
{
- if (process.Leak().PTime < static_cast<Int>(kSchedMinMicroTime))
+ if (process.Leak().PTime <= 0)
{
process.Leak().Status = ProcessStatus::kRunning;
- process.Leak().Affinity = AffinityKind::kHartStandard;
+ process.Leak().Affinity = AffinityKind::kStandard;
return true;
}
@@ -347,7 +347,7 @@ namespace Kernel
++process.Leak().PTime;
}
- return process.Leak().PTime > static_cast<Int>(kSchedMinMicroTime);
+ return process.Leak().PTime > 0;
}
/**
diff --git a/Kernel/Sources/SMPManager.cxx b/Kernel/Sources/SMPManager.cxx
index e32f8be7..f5424525 100644
--- a/Kernel/Sources/SMPManager.cxx
+++ b/Kernel/Sources/SMPManager.cxx
@@ -7,6 +7,7 @@
#include <ArchKit/ArchKit.hpp>
#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/SMPManager.hpp>
+#include <CFKit/Property.hpp>
///! BUGS: 0
@@ -16,6 +17,8 @@
namespace Kernel
{
+ STATIC Property cSMPCoreName;
+
///! A HardwareThread class takes care of it's owned hardware thread.
///! It has a stack for it's core.
@@ -120,7 +123,16 @@ namespace Kernel
//! @brief Constructor and destructor
///! @brief Default constructor.
- SMPManager::SMPManager() = default;
+ SMPManager::SMPManager()
+ {
+ StringView strCoreName(512);
+ strCoreName += "\\Properties\\Smp\\SchedulerClass";
+
+ cSMPCoreName.GetKey() = strCoreName;
+ cSMPCoreName.GetValue() = (UIntPtr)this;
+
+ kcout << "newoskrnl: initializing " << strCoreName.CData() << endl;
+ }
///! @brief Default destructor.
SMPManager::~SMPManager() = default;