1 | // SPDX-License-Identifier: GPL-3.0-or-later |
---|---|
2 | |
3 | #pragma once |
4 | |
5 | #include <mos/tasks/task_types.h> |
6 | |
7 | #define THREAD_MAGIC_THRD MOS_FOURCC('T', 'H', 'R', 'D') |
8 | |
9 | typedef struct _hashmap hashmap_t; |
10 | |
11 | extern hashmap_t thread_table; |
12 | |
13 | should_inline bool thread_is_valid(const thread_t *thread) |
14 | { |
15 | return thread && thread->magic == THREAD_MAGIC_THRD; |
16 | } |
17 | |
18 | thread_t *thread_allocate(process_t *owner, thread_mode tflags); |
19 | void thread_destroy(thread_t *thread); |
20 | |
21 | thread_t *thread_new(process_t *owner, thread_mode mode, const char *name, size_t stack_size, void *stack); |
22 | thread_t *thread_complete_init(thread_t *thread); |
23 | thread_t *thread_get(tid_t id); |
24 | bool thread_wait_for_tid(tid_t tid); |
25 | |
26 | [[noreturn]] void thread_exit(thread_t *t); |
27 | [[noreturn]] void thread_exit_locked(thread_t *t); |
28 |