2023-03-10 10:32:50 +00:00
|
|
|
// This file is part of noxos and licensed under the MIT open source license
|
2023-02-18 21:10:27 +00:00
|
|
|
|
|
|
|
#ifndef NOX_THREAD_H
|
|
|
|
#define NOX_THREAD_H
|
|
|
|
|
|
|
|
#include "utils/stdtypes.h"
|
|
|
|
#include "platform/cpu.h"
|
2023-03-03 19:23:19 +00:00
|
|
|
#include "proc/process.h"
|
2023-02-18 21:10:27 +00:00
|
|
|
|
2023-02-19 08:13:17 +00:00
|
|
|
typedef struct thread_T thread_T;
|
|
|
|
struct thread_T{
|
2023-03-07 18:22:46 +00:00
|
|
|
cpu_state_T* state;
|
|
|
|
uint64_t cpu_time;
|
|
|
|
void* stack;
|
|
|
|
uint32_t stack_size;
|
|
|
|
process_T* process;
|
2023-02-18 21:10:27 +00:00
|
|
|
|
2023-02-19 08:13:17 +00:00
|
|
|
// Scheduling data
|
2023-03-07 18:22:46 +00:00
|
|
|
thread_T* global_prev;
|
|
|
|
thread_T* global_next;
|
2023-03-03 19:23:19 +00:00
|
|
|
|
2023-03-07 18:22:46 +00:00
|
|
|
thread_T* local_prev;
|
|
|
|
thread_T* local_next;
|
2023-03-08 00:01:12 +00:00
|
|
|
uint32_t local_id;
|
2023-02-18 23:05:45 +00:00
|
|
|
};
|
|
|
|
|
2023-02-19 08:13:17 +00:00
|
|
|
|
2023-03-03 19:23:19 +00:00
|
|
|
thread_T* thread_spawn (pid_t process, void* function);
|
|
|
|
thread_T* thread_spawn_from_state (pid_t process, cpu_state_T* state);
|
2023-02-19 08:13:17 +00:00
|
|
|
void thread_start (thread_T* thread);
|
|
|
|
void thread_pause (thread_T* thread);
|
|
|
|
void thread_kill (thread_T* thread);
|
2023-02-18 23:05:45 +00:00
|
|
|
|
2023-02-18 21:10:27 +00:00
|
|
|
#endif //NOX_THREAD_H
|