Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1#ifndef __PROCC__THREAD_H__
2#define __PROCC__THREAD_H__
4#include "autoconf.h"
5#include <register.h>
6#include <spinlock.h>
8#ifdef __cplusplus
9extern "C" {
10#endif
11
14enum {
15 THREAD_USER = (1 << 0),
16 THREAD_KERNEL = ~(1 << 0),
19};
20
21enum {
27};
28
29typedef struct thread thread_t;
30struct thread {
31 // --- Cache line 1 (scheduler hot path) ---
37 uint64_t last_run_time; // 8B profiling
40 uint8_t _pad1[64 - 29]; // align ke 64B (cache line 1 penuh)
41
42 // --- Cache line 2–4 (context, jarang diakses) ---
45 cpu_register_t reg; // 128–160B
46} __attribute__((aligned(64)));
47
53
59
60#define THREAD_MAKE_ID(id, gen) ((uint64_t) (gen) << 32 | ((uint64_t) (id) + 1))
61#define THREAD_GET_ID(thread_id) ((uint32_t) ((thread_id) & 0xFFFFFFFFULL) - 1)
62#define THREAD_GET_GEN(thread_id) ((uint32_t) ((thread_id) >> 32))
63
66void vxThreadExit();
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif // __PROCC__THREAD_H__
void vxThreadExit()
Definition thread.c:70
@ THREAD_PREEMPT_ENABLE
Definition thread.h:17
@ THREAD_USER
Definition thread.h:15
@ THREAD_PREEMPT_DISABLE
Definition thread.h:18
@ THREAD_KERNEL
Definition thread.h:16
thread_id vxCreateThread(const uintptr_t entry, uint16_t core_affinity, uint8_t priority, uint16_t flags)
uint8_t priority
Definition thread.h:4
struct thread thread_t
Definition thread.h:29
uint16_t flags
Definition thread.h:5
@ THREAD_STATE_READY
Definition thread.h:23
@ THREAD_STATE_TERMINATED
Definition thread.h:26
@ THREAD_STATE_RUNNING
Definition thread.h:24
@ THREAD_STATE_CREATE
Definition thread.h:22
@ THREAD_STATE_HAL
Definition thread.h:25
typedef __attribute__
Definition msi.c:47
uint64_t thread_id
Definition thread.h:12
uint16_t core_affinity
Definition thread.h:2
struct thread_bucket thread_bucket_t
spinlock_t lock
Definition thread.h:56
thread_slot_t slot[VOXIA_MAX_NUMBER_THREAD]
Definition thread.h:55
uint32_t top_free
Definition thread.h:57
thread_t * thread
Definition thread.h:49
uint32_t gen
Definition thread.h:50
boolean_t used
Definition thread.h:51
uint8_t _pad1[64 - 29]
Definition thread.h:40
boolean_t has_update_run_time
Definition thread.h:39
uint16_t core_affinity
Definition thread.h:33
uint64_t last_run_time
Definition thread.h:37
uint16_t flags
Definition thread.h:36
uint64_t stack
Definition thread.h:44
cpu_register_t reg
Definition thread.h:45
uint8_t priority
Definition thread.h:35
thread_id id
Definition thread.h:32
uint32_t uuid
Definition thread.h:38
uint8_t state
Definition thread.h:34
uintptr_t entry_addr
Definition thread.h:43
unsigned short uint16_t
Definition type.h:13
unsigned int uint32_t
Definition type.h:19
uint8_t boolean_t
Definition type.h:89
unsigned long uintptr_t
Definition type.h:73
unsigned long uint64_t
Definition type.h:25
unsigned char uint8_t
Definition type.h:7