summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-28 08:26:19 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-28 08:26:19 +0200
commitc142fe6fda7d09e929c9706b444cdc13ed5e72f3 (patch)
treef42890096937271233da33d9c201043fb9960634 /Kernel/Sources
parente32c206fe1d17eb96339b280c7f061e7201bd15b (diff)
IMP: Feature Pack #1
- Process scheduler. - System calls. - ACPI support. - Driver kit. - Filesystem support. - Program loader. - newstd/herror APIs. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources')
-rw-r--r--Kernel/Sources/KernelHeap.cxx1
-rw-r--r--Kernel/Sources/ProcessScheduler.cxx13
-rw-r--r--Kernel/Sources/Semaphore.cxx19
3 files changed, 25 insertions, 8 deletions
diff --git a/Kernel/Sources/KernelHeap.cxx b/Kernel/Sources/KernelHeap.cxx
index c3e8e86b..875e00fb 100644
--- a/Kernel/Sources/KernelHeap.cxx
+++ b/Kernel/Sources/KernelHeap.cxx
@@ -185,6 +185,7 @@ namespace NewOS
{
virtualAddress->fCRC32 =
ke_calculate_crc32((Char*)virtualAddress->fTargetPtr, virtualAddress->fTargetPtrSize);
+
return true;
}
}
diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx
index 315dc07a..ca9a3435 100644
--- a/Kernel/Sources/ProcessScheduler.cxx
+++ b/Kernel/Sources/ProcessScheduler.cxx
@@ -27,13 +27,19 @@ namespace NewOS
/// @brief Exit Code global
/***********************************************************************************/
- STATIC Int32 kLastExitCode = 0U;
+ STATIC Int32 cLastExitCode = 0U;
/// @brief Gets the latest exit code.
/// @note Not thread-safe.
+ /// @return Int32 the last exit code.
+ const Int32& ProcessHeader::GetExitCode() noexcept
+ {
+ return fLastExitCode;
+ }
+
const Int32& rt_get_exit_code() noexcept
{
- return kLastExitCode;
+ return cLastExitCode;
}
/***********************************************************************************/
@@ -164,7 +170,8 @@ namespace NewOS
ProcessScheduler::The().Leak().TheCurrent().Leak().ProcessId)
ke_stop(RUNTIME_CHECK_PROCESS);
- kLastExitCode = exit_code;
+ fLastExitCode = exit_code;
+ cLastExitCode = exit_code;
//! Delete image if not done already.
if (this->Image)
diff --git a/Kernel/Sources/Semaphore.cxx b/Kernel/Sources/Semaphore.cxx
index d52cf447..45fccbca 100644
--- a/Kernel/Sources/Semaphore.cxx
+++ b/Kernel/Sources/Semaphore.cxx
@@ -6,7 +6,6 @@
#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/Semaphore.hpp>
-#include <KernelKit/Timer.hpp>
namespace NewOS
{
@@ -33,21 +32,31 @@ namespace NewOS
return fLockingProcess;
}
- bool Semaphore::LockOrWait(ProcessHeader* process, const Int64& seconds)
+ bool Semaphore::LockOrWait(ProcessHeader* process, HardwareTimerInterface* timer)
{
if (process == nullptr)
return false;
- HardwareTimer timer(Seconds(seconds));
- timer.Wait();
+ if (timer == nullptr)
+ return false;
+
+ this->Lock(process);
+
+ timer->Wait();
return this->Lock(process);
}
- void Semaphore::Sync() noexcept
+ /// @brief Wait with process, either wait for process being invalid, or not being run.
+ Void Semaphore::WaitForProcess() noexcept
{
while (fLockingProcess)
{
+ if (fLockingProcess->GetStatus() != ProcessStatus::kRunning)
+ {
+ this->Unlock();
+ break;
+ }
}
}
} // namespace NewOS