Kernel: Threads cannot take arguments anymore
This commit is contained in:
@@ -17,18 +17,8 @@ namespace Kernel
|
||||
static Scheduler& get();
|
||||
|
||||
const Thread& current_thread() const;
|
||||
|
||||
template<typename... Args>
|
||||
BAN::ErrorOr<void> add_thread(const BAN::Function<void(Args...)>& func, Args... args)
|
||||
{
|
||||
uintptr_t flags;
|
||||
asm volatile("pushf; pop %0" : "=r"(flags));
|
||||
asm volatile("cli");
|
||||
TRY(m_threads.emplace_back(func, BAN::forward<Args>(args)...));
|
||||
if (flags & (1 << 9))
|
||||
asm volatile("sti");
|
||||
return {};
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> add_thread(const BAN::Function<void()>& function);
|
||||
|
||||
void reschedule();
|
||||
void set_current_thread_sleeping();
|
||||
|
||||
@@ -22,19 +22,10 @@ namespace Kernel
|
||||
};
|
||||
|
||||
public:
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpmf-conversions"
|
||||
template<typename... Args>
|
||||
Thread(const BAN::Function<void(Args...)>& func, Args... args)
|
||||
: Thread((uintptr_t)(void*)&BAN::Function<void(Args...)>::operator(), (uintptr_t)&func, ((uintptr_t)args)...)
|
||||
{
|
||||
static_assert(((BAN::is_integral_v<Args> || BAN::is_pointer_v<Args>) && ...));
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
Thread(const BAN::Function<void()>&);
|
||||
~Thread();
|
||||
|
||||
uint32_t id() const { return m_id; }
|
||||
uint32_t tid() const { return m_tid; }
|
||||
|
||||
void set_rsp(uintptr_t rsp) { m_rsp = rsp; }
|
||||
void set_rip(uintptr_t rip) { m_rip = rip; }
|
||||
@@ -43,21 +34,19 @@ namespace Kernel
|
||||
uintptr_t rip() const { return m_rip; }
|
||||
State state() const { return m_state; }
|
||||
|
||||
const uintptr_t* args() const { return m_args; }
|
||||
const BAN::Function<void()>* function() const { return &m_function; }
|
||||
|
||||
private:
|
||||
Thread(uintptr_t rip, uintptr_t func, uintptr_t arg1 = 0, uintptr_t arg2 = 0, uintptr_t arg3 = 0);
|
||||
void on_exit();
|
||||
|
||||
private:
|
||||
void* m_stack_base = nullptr;
|
||||
State m_state = State::NotStarted;
|
||||
uintptr_t m_args[4] = {};
|
||||
uintptr_t m_rip = 0;
|
||||
uintptr_t m_rsp = 0;
|
||||
const uint32_t m_id = 0;
|
||||
const uint32_t m_tid = 0;
|
||||
|
||||
alignas(max_align_t) uint8_t m_function[BAN::Function<void()>::size()] { 0 };
|
||||
BAN::Function<void()> m_function;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user