Luna/kernel/src/thread/Thread.cpp

21 lines
308 B
C++
Raw Normal View History

#include "thread/Thread.h"
#include <luna/Alloc.h>
2022-12-17 09:50:49 +00:00
#include <luna/Atomic.h>
2022-12-17 09:50:49 +00:00
static Atomic<u64> g_next_id;
2022-12-19 11:43:23 +00:00
LinkedList<Thread> g_threads;
2022-12-17 09:50:49 +00:00
void Thread::init()
{
g_next_id = 1;
}
Result<Thread*> new_thread()
{
Thread* thread = TRY(make<Thread>());
thread->id = g_next_id++;
return thread;
}