summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Sources
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-09-09 16:49:28 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-09-09 16:49:28 +0200
commit6dbc74799f465eec249e2d8f01a472d0dd3b33c8 (patch)
tree53ef934c936537424e1b8d2469cf12fd421234e3 /dev/ZKA/Sources
parent6274e822da7790961dc8f587cd83645f06e79245 (diff)
FIX: Scheduler improvements, MM improvements, worked on a tiny bmp allocator for pages.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ZKA/Sources')
-rw-r--r--dev/ZKA/Sources/HardwareThreadScheduler.cxx21
-rw-r--r--dev/ZKA/Sources/Pmm.cxx2
-rw-r--r--dev/ZKA/Sources/UserProcessScheduler.cxx21
3 files changed, 27 insertions, 17 deletions
diff --git a/dev/ZKA/Sources/HardwareThreadScheduler.cxx b/dev/ZKA/Sources/HardwareThreadScheduler.cxx
index e5947357..22a69b9b 100644
--- a/dev/ZKA/Sources/HardwareThreadScheduler.cxx
+++ b/dev/ZKA/Sources/HardwareThreadScheduler.cxx
@@ -43,6 +43,14 @@ namespace Kernel
//! @brief is the thread busy?
Bool HardwareThread::IsBusy() noexcept
{
+ STATIC Int64 busy_timer = 0U;
+
+ if (busy_timer > this->fPTime)
+ {
+ busy_timer = 0U;
+ fBusy = No;
+ }
+
return fBusy;
}
@@ -95,16 +103,17 @@ namespace Kernel
if (!this->IsWakeup())
return No;
- fStack = frame;
-
if (this->IsBusy())
- return false;
+ return No;
- kcout << "Registering process bank...\r";
+ fStack = frame;
+
+ kcout << "Trying to register progress...\r";
- this->Busy(true);
Bool ret = mp_register_process(image, stack_ptr, fStack);
- this->Busy(false);
+
+ if (ret)
+ this->Busy(true);
return ret;
}
diff --git a/dev/ZKA/Sources/Pmm.cxx b/dev/ZKA/Sources/Pmm.cxx
index 58335a2b..394b634c 100644
--- a/dev/ZKA/Sources/Pmm.cxx
+++ b/dev/ZKA/Sources/Pmm.cxx
@@ -31,7 +31,7 @@ namespace Kernel
/// @param readWrite is it r/w?
Ref<PTEWrapper> Pmm::RequestPage(Boolean user, Boolean readWrite)
{
- PTEWrapper pt = fPageMgr.Leak().Request(user, readWrite, false, kPTESize);
+ PTEWrapper pt = fPageMgr.Leak().Request(user, readWrite, false, kPageSize);
if (pt.fPresent)
{
diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx
index 721bd02f..00f314d1 100644
--- a/dev/ZKA/Sources/UserProcessScheduler.cxx
+++ b/dev/ZKA/Sources/UserProcessScheduler.cxx
@@ -348,11 +348,6 @@ namespace Kernel
continue;
}
}
- else
- {
- // otherwise increment the P-time.
- --process.PTime;
- }
}
kcout << "Scheduled Process Count: " << number(process_index) << endl;
@@ -390,15 +385,17 @@ namespace Kernel
/// @retval false cannot be schedulded.
bool UserProcessHelper::CanBeScheduled(const UserProcess& process)
{
- kcout << "Checking Status...\r";
+ kcout << "Checking process status...\r";
if (process.Status == ProcessStatusKind::kFrozen ||
process.Status == ProcessStatusKind::kDead)
return No;
- kcout << "Checking PTime...\r";
+ if (!process.Image &&
+ process.Kind == UserProcess::kExeKind)
+ return No;
- return process.PTime <= 0;
+ return Yes;
}
/**
@@ -450,11 +447,15 @@ namespace Kernel
PID prev_pid = UserProcessHelper::TheCurrentPID();
UserProcessHelper::TheCurrentPID() = new_pid;
- bool ret = HardwareThreadScheduler::The()[index].Leak()->Switch(image_ptr, stack, frame_ptr);
+ auto prev_ptime = HardwareThreadScheduler::The()[index].Leak()->fPTime;
+ HardwareThreadScheduler::The()[index].Leak()->fPTime = UserProcessScheduler::The().CurrentTeam().AsArray()[new_pid].ProcessId;
+ Bool ret = HardwareThreadScheduler::The()[index].Leak()->Switch(image_ptr, stack, frame_ptr);
if (!ret)
{
- UserProcessHelper::TheCurrentPID() = prev_pid;
+ HardwareThreadScheduler::The()[index].Leak()->fPTime = prev_ptime;
+ UserProcessHelper::TheCurrentPID() = prev_pid;
+
continue;
}
}