Kernel: Remove system.h and make the uptime global a qword.

This commit is contained in:
Andreas Kling 2019-04-14 01:29:14 +02:00
parent c09c114d77
commit 29d0412a06
Notes: sideshowbarker 2024-07-19 14:43:46 +09:00
8 changed files with 13 additions and 27 deletions

View file

@ -1,7 +1,6 @@
#include "ProcFS.h"
#include "Process.h"
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include "system.h"
#include <Kernel/VM/MemoryManager.h>
#include "StdLib.h"
#include "i386.h"

View file

@ -3,7 +3,6 @@
#include "kmalloc.h"
#include "StdLib.h"
#include "i386.h"
#include "system.h"
#include <Kernel/FileSystem/FileDescriptor.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Devices/NullDevice.h>
@ -1190,9 +1189,9 @@ int Process::sys$usleep(useconds_t usec)
return 0;
current->sleep(usec / 1000);
if (current->m_wakeup_time > system.uptime) {
if (current->m_wakeup_time > g_uptime) {
ASSERT(current->m_was_interrupted_while_blocked);
dword ticks_left_until_original_wakeup_time = current->m_wakeup_time - system.uptime;
dword ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
return ticks_left_until_original_wakeup_time / TICKS_PER_SECOND;
}
return 0;
@ -1203,9 +1202,9 @@ int Process::sys$sleep(unsigned seconds)
if (!seconds)
return 0;
current->sleep(seconds * TICKS_PER_SECOND);
if (current->m_wakeup_time > system.uptime) {
if (current->m_wakeup_time > g_uptime) {
ASSERT(current->m_was_interrupted_while_blocked);
dword ticks_left_until_original_wakeup_time = current->m_wakeup_time - system.uptime;
dword ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
return ticks_left_until_original_wakeup_time / TICKS_PER_SECOND;
}
return 0;

View file

@ -1,6 +1,5 @@
#include "Scheduler.h"
#include "Process.h"
#include "system.h"
#include "RTC.h"
#include "i8253.h"
#include <AK/TemporaryChange.h>
@ -27,6 +26,7 @@ Thread* current;
Thread* g_last_fpu_thread;
Thread* g_finalizer;
static Process* s_colonel_process;
qword g_uptime;
struct TaskRedirectionData {
word selector;
@ -65,7 +65,7 @@ bool Scheduler::pick_next()
auto& process = thread.process();
if (thread.state() == Thread::BlockedSleep) {
if (thread.wakeup_time() <= system.uptime)
if (thread.wakeup_time() <= g_uptime)
thread.unblock();
return IterationDecision::Continue;
}
@ -391,7 +391,7 @@ void Scheduler::timer_tick(RegisterDump& regs)
if (!current)
return;
system.uptime++;
++g_uptime;
if (current->tick())
return;

View file

@ -1,6 +1,7 @@
#pragma once
#include <AK/Assertions.h>
#include <AK/Types.h>
class Process;
class Thread;
@ -9,6 +10,7 @@ struct RegisterDump;
extern Thread* current;
extern Thread* g_last_fpu_thread;
extern Thread* g_finalizer;
extern qword g_uptime;
class Scheduler {
public:

View file

@ -1,6 +1,5 @@
#include <Kernel/Thread.h>
#include <Kernel/Scheduler.h>
#include <Kernel/system.h>
#include <Kernel/Process.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibC/signal_numbers.h>
@ -125,7 +124,7 @@ void Thread::block(Thread::State new_state)
void Thread::sleep(dword ticks)
{
ASSERT(state() == Thread::Running);
current->set_wakeup_time(system.uptime + ticks);
current->set_wakeup_time(g_uptime + ticks);
current->block(Thread::BlockedSleep);
}

View file

@ -89,8 +89,8 @@ public:
void block(Thread::State);
void unblock();
void set_wakeup_time(dword t) { m_wakeup_time = t; }
dword wakeup_time() const { return m_wakeup_time; }
void set_wakeup_time(qword t) { m_wakeup_time = t; }
qword wakeup_time() const { return m_wakeup_time; }
void snooze_until(Alarm&);
KResult wait_for_connect(Socket&);
@ -144,7 +144,7 @@ private:
dword m_ticks_left { 0 };
dword m_stack_top0 { 0 };
dword m_stack_top3 { 0 };
dword m_wakeup_time { 0 };
qword m_wakeup_time { 0 };
dword m_times_scheduled { 0 };
dword m_pending_signals { 0 };
dword m_signal_mask { 0 };

View file

@ -4,7 +4,6 @@
#include "i8253.h"
#include <Kernel/Devices/KeyboardDevice.h>
#include "Process.h"
#include "system.h"
#include "PIC.h"
#include <Kernel/Devices/IDEDiskDevice.h>
#include "KSyms.h"
@ -37,8 +36,6 @@
//#define SPAWN_MULTIPLE_SHELLS
//#define STRESS_TEST_SPAWNING
system_t system;
VirtualConsole* tty0;
VirtualConsole* tty1;
VirtualConsole* tty2;

View file

@ -1,10 +0,0 @@
#pragma once
#include <AK/Types.h>
struct system_t
{
time_t uptime;
};
extern system_t system;