Thread: Make g_next_id atomic
This commit is contained in:
parent
14461c6fe8
commit
6e5d2b5335
@ -49,6 +49,7 @@ Result<void> init()
|
|||||||
kinfoln("Used memory: %s", to_dynamic_unit(MemoryManager::used()).release_value().chars());
|
kinfoln("Used memory: %s", to_dynamic_unit(MemoryManager::used()).release_value().chars());
|
||||||
kinfoln("Reserved memory: %s", to_dynamic_unit(MemoryManager::reserved()).release_value().chars());
|
kinfoln("Reserved memory: %s", to_dynamic_unit(MemoryManager::reserved()).release_value().chars());
|
||||||
|
|
||||||
|
Thread::init();
|
||||||
Scheduler::init();
|
Scheduler::init();
|
||||||
|
|
||||||
TRY(Scheduler::new_kernel_thread(async_thread));
|
TRY(Scheduler::new_kernel_thread(async_thread));
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
#include "thread/Thread.h"
|
#include "thread/Thread.h"
|
||||||
#include <luna/Alloc.h>
|
#include <luna/Alloc.h>
|
||||||
|
#include <luna/Atomic.h>
|
||||||
|
|
||||||
static u64 g_next_id = 1;
|
static Atomic<u64> g_next_id;
|
||||||
|
|
||||||
DoublyLinkedList<Thread> g_threads;
|
DoublyLinkedList<Thread> g_threads;
|
||||||
|
|
||||||
|
void Thread::init()
|
||||||
|
{
|
||||||
|
g_next_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
Result<Thread*> new_thread()
|
Result<Thread*> new_thread()
|
||||||
{
|
{
|
||||||
Thread* thread = TRY(make<Thread>());
|
Thread* thread = TRY(make<Thread>());
|
||||||
|
@ -47,6 +47,8 @@ struct Thread : public DoublyLinkedListNode<Thread>
|
|||||||
|
|
||||||
void set_sp(u64 sp);
|
void set_sp(u64 sp);
|
||||||
u64 sp();
|
u64 sp();
|
||||||
|
|
||||||
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
void switch_context(Thread* old_thread, Thread* new_thread, Registers* regs);
|
void switch_context(Thread* old_thread, Thread* new_thread, Registers* regs);
|
||||||
|
Loading…
Reference in New Issue
Block a user