summaryrefslogtreecommitdiff
path: root/kc/core/task.h
blob: 5d9f39f77d965d8468df08aa891aec1e4828b6f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include <stdint.h>

enum kc_thread_status
{
	AVAILABLE,
	CREATED,
    READY,
    RUNNING,
    SLEEPING,
    BLOCKED,
	WAITING,
    TERMINATED
};

union kc_thread_result
{
	uint64_t scalar;
	void *pointer;
};

struct kc_thread
{
	void *kernel_stack_head;
	void *kernel_stack_pointer;
	uint64_t time_elapsed;
	union kc_thread_result result;
	enum kc_thread_status status;
	struct kc_thread *next;
	union
	{
		uint64_t sleep_expiration;
		struct kc_thread *wait_target;
	};
};

void task_init(void);

void kct_terminate(union kc_thread_result result);
union kc_thread_result kct_wait(struct kc_thread *target);