diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-20 21:01:31 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-20 21:01:31 +0100 |
| commit | 50439432a85976605dbb18e3cd2161f888d2e17d (patch) | |
| tree | 12a30d88888f407e84634badef430d321cd1f4c6 /dev/ZKAKit/src/UserProcessScheduler.cc | |
| parent | 745cc52b11190689a3f42b936978a5c03a410b9a (diff) | |
IMP: AHCI-DMA: driver improvements, does complete read now (although nothing returns).
ReadMe.md: Update git ssh link.
HWTS: Refactor class.
DriveMgr: Lots of improvements inside the API.
CUSA: Refactor scheduler API too.
Diffstat (limited to 'dev/ZKAKit/src/UserProcessScheduler.cc')
| -rw-r--r-- | dev/ZKAKit/src/UserProcessScheduler.cc | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/dev/ZKAKit/src/UserProcessScheduler.cc b/dev/ZKAKit/src/UserProcessScheduler.cc index 3352085d..8694b449 100644 --- a/dev/ZKAKit/src/UserProcessScheduler.cc +++ b/dev/ZKAKit/src/UserProcessScheduler.cc @@ -32,19 +32,13 @@ namespace Kernel /// @brief Exit Code global variable. /***********************************************************************************/ - UInt32 kLastExitCode = 0U; - - /***********************************************************************************/ - /// @brief Process count global variable. - /***********************************************************************************/ - - ProcessID kProcessIDCounter = 0UL; + STATIC UInt32 kLastExitCode = 0U; /***********************************************************************************/ /// @brief User Process scheduler global and external reference of thread scheduler. /***********************************************************************************/ - UserProcessScheduler kProcessScheduler; + STATIC UserProcessScheduler kProcessScheduler; UserProcess::UserProcess(VoidPtr start_image) : Code(start_image) @@ -314,7 +308,6 @@ namespace Kernel mm_delete_heap(reinterpret_cast<VoidPtr>(this->StackReserve)); this->ProcessId = 0; - --kProcessIDCounter; } /***********************************************************************************/ @@ -323,11 +316,11 @@ namespace Kernel /// @return the process index inside the team. /***********************************************************************************/ - ProcessID UserProcessScheduler::Add(UserProcess* process) + ProcessID UserProcessScheduler::Spawn(UserProcess* process) { if (*process->Name == 0) { - Char process_name[] = "System Process"; + Char process_name[] = "Process (Unnamed)"; rt_copy_memory((VoidPtr)process_name, process->Name, rt_string_len(process_name)); } @@ -378,18 +371,16 @@ namespace Kernel kcout << "Create stack reserve for: " << process->Name << endl; - auto pid = kProcessIDCounter; + auto pid = mTeam.mProcessList.Count(); process->ProcessId = pid; process->Status = ProcessStatusKind::kRunning; process->PTime = (UIntPtr)AffinityKind::kStandard; - mTeam.AsArray().Assign(pid, *process); - - kcout << "Process Name: " << mTeam.AsArray()[pid].Name << endl; - kcout << "PID: " << number(mTeam.AsArray()[pid].ProcessId) << endl; + mTeam.mProcessList.Assign(pid, *process); - ++kProcessIDCounter; + kcout << "Process Name: " << mTeam.mProcessList[pid].Name << endl; + kcout << "PID: " << number(mTeam.mProcessList[pid].ProcessId) << endl; return pid; } @@ -539,7 +530,7 @@ namespace Kernel /***********************************************************************************/ /** - * @brief Start scheduling current AP/Hart/Core. + * @brief Start scheduling current AP. */ /***********************************************************************************/ SizeT UserProcessHelper::StartScheduling() @@ -549,6 +540,16 @@ namespace Kernel /***********************************************************************************/ /** + * @brief Initializes the scheduler. + */ + /***********************************************************************************/ + Void UserProcessHelper::InitScheduler() + { + /// TODO: code to init scheduler here. + } + + /***********************************************************************************/ + /** * \brief Does a context switch in a CPU. * \param the_stack the stackframe of the running app. * \param new_pid the process's PID. @@ -563,7 +564,7 @@ namespace Kernel if (!mm_is_valid_heap(image_ptr)) return No; - for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Count(); ++index) + for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index) { if (HardwareThreadScheduler::The()[index].Leak()->Kind() == kInvalidHart) continue; |
