1 | // SPDX-License-Identifier: GPL-3.0-or-later |
---|---|
2 | |
3 | #pragma once |
4 | |
5 | #include <mos/hashmap.hpp> |
6 | #include <mos/tasks/task_types.hpp> |
7 | #include <mos/types.h> |
8 | |
9 | typedef struct _hashmap hashmap_t; |
10 | |
11 | extern mos::HashMap<tid_t, Thread *> thread_table; |
12 | |
13 | should_inline bool thread_is_valid(const Thread *thread) |
14 | { |
15 | if (auto ptr = thread) |
16 | return ptr->magic == THREAD_MAGIC_THRD; |
17 | else |
18 | return false; |
19 | } |
20 | |
21 | Thread *thread_allocate(Process *owner, thread_mode tflags); |
22 | void thread_destroy(Thread *thread); |
23 | |
24 | PtrResult<Thread> thread_new(Process *owner, thread_mode mode, mos::string_view name, size_t stack_size, void *stack); |
25 | Thread *thread_complete_init(Thread *thread); |
26 | Thread *thread_get(tid_t id); |
27 | bool thread_wait_for_tid(tid_t tid); |
28 | |
29 | [[noreturn]] void thread_exit(Thread *&&t); |
30 | [[noreturn]] void thread_exit_locked(Thread *&&t); |
31 |