diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-06 12:52:02 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-06 12:52:02 +0200 |
| commit | 39d95f7fb429c5c6b71cd7c1e985cadaf4ab7b83 (patch) | |
| tree | 33e5832930b82adadfec61ad2e509e79995b7cf1 /dev/ZKA/Sources | |
| parent | 1404bdfdbf767a7c8e445766af4c27fe17f7c205 (diff) | |
[ IMP ] Fixed Scheduler and Team object, also fixed other things.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ZKA/Sources')
| -rw-r--r-- | dev/ZKA/Sources/CodeMgr.cxx | 4 | ||||
| -rw-r--r-- | dev/ZKA/Sources/FS/NeFS.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/PEFCodeMgr.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/UserProcessScheduler.cxx | 22 |
4 files changed, 19 insertions, 11 deletions
diff --git a/dev/ZKA/Sources/CodeMgr.cxx b/dev/ZKA/Sources/CodeMgr.cxx index 49968e73..ae4cb00b 100644 --- a/dev/ZKA/Sources/CodeMgr.cxx +++ b/dev/ZKA/Sources/CodeMgr.cxx @@ -14,7 +14,7 @@ namespace Kernel /// @note This sets up a new stack, anything on the main function that calls the Kernel will not be accessible. /// @param main the start of the process. /// @return if the process was started or not. - bool sched_execute_thread(MainKind main, const Char* process_name) noexcept + Bool sched_execute_thread(MainKind main, const Char* process_name) noexcept { if (!main) return No; @@ -27,6 +27,6 @@ namespace Kernel rt_copy_memory((VoidPtr)process_name, proc.Name, rt_string_len(process_name)); - return UserProcessScheduler::The().Add(proc) != 0; + return UserProcessScheduler::The().Add(proc) > 0; } } // namespace Kernel diff --git a/dev/ZKA/Sources/FS/NeFS.cxx b/dev/ZKA/Sources/FS/NeFS.cxx index 549a0217..1a9b89f7 100644 --- a/dev/ZKA/Sources/FS/NeFS.cxx +++ b/dev/ZKA/Sources/FS/NeFS.cxx @@ -724,7 +724,7 @@ bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool i _Output NFS_CATALOG_STRUCT* NeFSParser::FindCatalog(_Input const Char* catalogName, Lba& out_lba) { - kcout << "start finding catalog...\r"; + kcout << "Start finding catalog...\r"; NFS_ROOT_PARTITION_BLOCK fs_buf{0}; auto drive = sMountpointInterface.A(); diff --git a/dev/ZKA/Sources/PEFCodeMgr.cxx b/dev/ZKA/Sources/PEFCodeMgr.cxx index feafc35c..23dfae31 100644 --- a/dev/ZKA/Sources/PEFCodeMgr.cxx +++ b/dev/ZKA/Sources/PEFCodeMgr.cxx @@ -221,7 +221,7 @@ namespace Kernel proc.StackSize = mib_cast(cDefaultStackSizeMib); } - return UserProcessScheduler::The().Add(proc); + return UserProcessScheduler::The().Add(proc) > 0; } } // namespace Utils diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx index f480bccc..c68104b9 100644 --- a/dev/ZKA/Sources/UserProcessScheduler.cxx +++ b/dev/ZKA/Sources/UserProcessScheduler.cxx @@ -54,7 +54,7 @@ namespace Kernel Void UserProcess::Crash() { - if (this->Name == 0) + if (*this->Name == 0) return; kcout << this->Name << ": crashed, ID = " << number(kErrorProcessFault) << endl; @@ -202,10 +202,10 @@ namespace Kernel cLastExitCode = exit_code; //! Delete image if not done already. - if (this->Image) + if (this->Image && mm_is_valid_heap(this->Image)) mm_delete_ke_heap(this->Image); - if (this->StackFrame) + if (this->StackFrame && mm_is_valid_heap(this->StackFrame)) mm_delete_ke_heap((VoidPtr)this->StackFrame); this->Image = nullptr; @@ -225,6 +225,8 @@ namespace Kernel if (this->StackReserve) delete[] this->StackReserve; + this->ProcessId = 0; + if (this->ProcessId > 0) UserProcessScheduler::The().Remove(this->ProcessId); } @@ -271,11 +273,14 @@ namespace Kernel return -kErrorProcessFault; } - process.Status = ProcessStatusKind::kStarting; - process.ProcessId = mTeam.mProcessAmount; + if (mTeam.mProcessAmount > kSchedProcessLimitPerTeam) + mTeam.mProcessAmount = 0UL; ++mTeam.mProcessAmount; + process.ProcessId = mTeam.mProcessAmount; + process.Status = ProcessStatusKind::kStarting; + mTeam.AsArray()[process.ProcessId] = process; return process.ProcessId; @@ -414,10 +419,13 @@ namespace Kernel * \param new_pid the process's PID. */ - bool UserProcessHelper::Switch(VoidPtr image_ptr, UInt8* stack, HAL::StackFramePtr frame_ptr, const PID& new_pid) + Bool UserProcessHelper::Switch(VoidPtr image_ptr, UInt8* stack, HAL::StackFramePtr frame_ptr, const PID& new_pid) { if (!stack || !frame_ptr || !image_ptr || new_pid < 0) - return false; + return No; + + while (Yes) + ; for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Count(); ++index) { |
