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
9typedef struct _hashmap hashmap_t;
10
11extern hashmap_t thread_table;
12
13should_inline bool thread_is_valid(const thread_t *thread)
14{
15 return thread && thread->magic == THREAD_MAGIC_THRD;
16}
17
18thread_t *thread_allocate(process_t *owner, thread_mode tflags);
19void thread_destroy(thread_t *thread);
20
21thread_t *thread_new(process_t *owner, thread_mode mode, const char *name, size_t stack_size, void *stack);
22thread_t *thread_complete_init(thread_t *thread);
23thread_t *thread_get(tid_t id);
24bool 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