Kernel: Properly initialize and shutdown all modules.
This commit is contained in:
parent
57aaaf92db
commit
c7dc799e19
|
@ -14,11 +14,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
unsigned int Object::next_object_id = 0;
|
||||
|
||||
SharedPtr<Thread> g_main_thread = nullptr;
|
||||
unsigned int Object::next_object_id;
|
||||
SharedPtr<Thread> g_main_thread;
|
||||
HandleTable g_handle_table;
|
||||
u64 g_program_id = 0;
|
||||
u64 g_program_id;
|
||||
|
||||
void WaitObject::AddWaitingThread(SharedPtr<Thread> thread) {
|
||||
auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
|
||||
|
@ -138,6 +137,10 @@ void HandleTable::Clear() {
|
|||
void Init() {
|
||||
Kernel::ThreadingInit();
|
||||
Kernel::TimersInit();
|
||||
|
||||
Object::next_object_id = 0;
|
||||
g_program_id = 0;
|
||||
g_main_thread = nullptr;
|
||||
}
|
||||
|
||||
/// Shutdown the kernel
|
||||
|
|
|
@ -95,12 +95,13 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
static unsigned int next_object_id;
|
||||
|
||||
private:
|
||||
friend void intrusive_ptr_add_ref(Object*);
|
||||
friend void intrusive_ptr_release(Object*);
|
||||
|
||||
static unsigned int next_object_id;
|
||||
|
||||
unsigned int ref_count = 0;
|
||||
unsigned int object_id = next_object_id++;
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
namespace Kernel {
|
||||
|
||||
/// Event type for the thread wake up event
|
||||
static int ThreadWakeupEventType = -1;
|
||||
static int ThreadWakeupEventType;
|
||||
|
||||
bool Thread::ShouldWait() {
|
||||
return status != THREADSTATUS_DEAD;
|
||||
|
@ -42,7 +42,7 @@ static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST+1> ready_queue;
|
|||
static Thread* current_thread;
|
||||
|
||||
// The first available thread id at startup
|
||||
static u32 next_thread_id = 1;
|
||||
static u32 next_thread_id;
|
||||
|
||||
/**
|
||||
* Creates a new thread ID
|
||||
|
@ -497,6 +497,12 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
|
|||
void ThreadingInit() {
|
||||
ThreadWakeupEventType = CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback);
|
||||
|
||||
current_thread = nullptr;
|
||||
next_thread_id = 1;
|
||||
|
||||
thread_list.clear();
|
||||
ready_queue.clear();
|
||||
|
||||
// Setup the idle thread
|
||||
SetupIdleThread();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Kernel {
|
||||
|
||||
/// The event type of the generic timer callback event
|
||||
static int timer_callback_event_type = -1;
|
||||
static int timer_callback_event_type;
|
||||
// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing
|
||||
// us to simply use a pool index or similar.
|
||||
static Kernel::HandleTable timer_callback_handle_table;
|
||||
|
@ -89,6 +89,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) {
|
|||
}
|
||||
|
||||
void TimersInit() {
|
||||
timer_callback_handle_table.Clear();
|
||||
timer_callback_event_type = CoreTiming::RegisterEvent("TimerCallback", TimerCallback);
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue