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"
7#include <spinlock.h>
11enum : uint16_t {
12 THREAD_USER = (1 << 0),
14};
16enum {
23};
25typedef struct thread thread_t;
26struct thread {
29 volatile uintptr_t* page;
38 // 1 cache line
39
40 process_t* process;
46 // 1 cache line
47
48 uintptr_t kernel_rsp; /* RSP saat switch keluar */
53
54 cpu_register_t reg;
55} __attribute__((aligned(64)));
56
57typedef struct {
59 uint32_t gen;
62
63typedef struct thread_bucket {
64 thread_slot_t slot[VOXIA_MAX_NUMBER_THREAD];
65 spinlock_t lock;
68
69#define THREAD_MAKE_ID(id, gen) ((uint64_t)(gen) << 32 | ((uint64_t)(id) + 1))
70#define THREAD_GET_ID(tid) ((uint32_t)((tid) & 0xFFFFFFFFULL) - 1)
71#define THREAD_GET_GEN(tid) ((uint32_t)((tid) >> 32))
72
76void vxThreadExit(void);
77
78#endif /* __PROCC__THREAD_H__ */
boolean_t used
Definition ehci.hpp:6
void vxThreadExit()
Definition thread.c:70
@ THREAD_PREEMPT_ENABLE
Definition thread.h:17
@ THREAD_USER
Definition thread.h:15
thread_id id
Definition thread.h:1
uint8_t priority
Definition thread.h:4
struct thread thread_t
Definition thread.h:29
uint64_t stack
Definition thread.h:13
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
@ THREAD_STATE_BLOCKED
Definition thread.h:20
thread_t * create_thread(volatile uintptr_t *page, uintptr_t entry, uintptr_t stack, uint16_t core_affinity, uint8_t priority, uint16_t flags)
Definition thread.c:41
uintptr_t page
Definition paging.c:0
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
boolean_t has_update_run_time
Definition thread.h:39
uintptr_t kernel_rsp
Definition thread.h:48
uint64_t last_run_time
Definition thread.h:37
uint16_t flags
Definition thread.h:36
process_t * process
Definition thread.h:40
uint64_t stack
Definition thread.h:44
volatile uintptr_t * page
Definition thread.h:29
cpu_register_t reg
Definition thread.h:45
uint8_t priority
Definition thread.h:35
uint64_t gs_base
Definition thread.h:44
uint8_t _pad[12]
Definition thread.h:45
uint16_t current_core_id
Definition thread.h:37
uintptr_t kernel_stack_base
Definition thread.h:49
bool in_kernel_sleep
Definition thread.h:51
uint32_t uuid
Definition thread.h:38
uintptr_t kernel_stack_top
Definition thread.h:50
uint8_t state
Definition thread.h:34
bool wake_pending
Definition thread.h:52
uintptr_t entry_addr
Definition thread.h:43
uint32_t * clear_child_tid
Definition thread.h:41
uint64_t fs_base
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