MyOS Kernel
tasking.h
Go to the documentation of this file.
1 
5 #ifndef KERN_TASKING_H
6 #define KERN_TASKING_H
7 
8 #include <stdint.h>
9 #include <sys/types.h>
10 
11 #ifndef TASKING_H
12 
16 typedef enum thread_state {
22 
23 #endif
24 
25 struct Thread;
26 
30 typedef struct Process {
31  char priv;
32  pid_t pid;
33  pid_t next_tid;
36  struct Thread* first_thread;
37 } Process;
38 
42 typedef struct Thread {
43  void* kernel_esp;
45  void* cr3;
46  pid_t tid;
48  int errno;
54 } Thread;
55 
56 extern Thread* current_thread;
57 
69 void tasking_create_task(void* eip,void* cr3,char kmode,char param1_exists,void* param1_arg,char param2_exists,void* param2_arg,char isThread);
73 void tasking_init();
83 pid_t tasking_get_PID();
97 pid_t tasking_new_thread(void* start,pid_t pid,char param_exists,void* param_arg);
98 
105 void tasking_exit(int code);
110 void tasking_block(thread_state newstate);
116 void tasking_unblock(pid_t pid,pid_t tid);
120 void tasking_yield();
121 
122 #endif
current_thread
Thread * current_thread
Currently running thread.
Definition: tasking.c:22
Process::num_threads
int num_threads
The number of threads in this process.
Definition: tasking.h:34
Thread::prev_thread_in_process
struct Thread * prev_thread_in_process
The previous thread in the process.
Definition: tasking.h:50
Thread::state
thread_state state
The state of this thread. (running,ready to run,blocked,etc.)
Definition: tasking.h:47
tasking_get_errno_address
int * tasking_get_errno_address()
Definition: tasking.c:157
tasking_yield
void tasking_yield()
Definition: tasking.c:228
Process::num_threads_blocked
int num_threads_blocked
The number of blocked threads in this process.
Definition: tasking.h:35
thread_state
thread_state
Definition: tasking.h:16
THREAD_BLOCKED
@ THREAD_BLOCKED
The state of a generically blocked thread.
Definition: tasking.h:20
THREAD_RUNNING
@ THREAD_RUNNING
The state of a running thread.
Definition: tasking.h:17
Thread::next_thread_in_process
struct Thread * next_thread_in_process
The next thread in the process.
Definition: tasking.h:49
Thread::process
Process * process
The thread's process.
Definition: tasking.h:53
Process::next_tid
pid_t next_tid
The TID that the next created thread will use.
Definition: tasking.h:33
tasking_is_privleged
char tasking_is_privleged()
Definition: tasking.c:149
Thread::tid
pid_t tid
The TID of this thread.
Definition: tasking.h:46
tasking_unblock
void tasking_unblock(pid_t pid, pid_t tid)
Definition: tasking.c:285
tasking_create_task
void tasking_create_task(void *eip, void *cr3, char kmode, char param1_exists, void *param1_arg, char param2_exists, void *param2_arg, char isThread)
Definition: tasking.c:62
tasking_get_PID
pid_t tasking_get_PID()
Definition: tasking.c:153
tasking_exit
void tasking_exit(int code)
Definition: tasking.c:322
Thread
Definition: tasking.h:42
THREAD_EXITED
@ THREAD_EXITED
The state of an exited thread.
Definition: tasking.h:19
Process::priv
char priv
Whether the process is privileged (can execute syscalls to acesss all of memory/has acess to IO ports...
Definition: tasking.h:31
Thread::kernel_esp
void * kernel_esp
The thread's kernel stack.
Definition: tasking.h:43
Process::first_thread
struct Thread * first_thread
A pointer to the head of the linked list of threads for this process.
Definition: tasking.h:36
tasking_block
void tasking_block(thread_state newstate)
Definition: tasking.c:255
Process::pid
pid_t pid
The PID of this process.
Definition: tasking.h:32
Process
Definition: tasking.h:30
tasking_new_thread
pid_t tasking_new_thread(void *start, pid_t pid, char param_exists, void *param_arg)
Definition: tasking.c:161
Thread::next_ready_to_run
struct Thread * next_ready_to_run
If the thread is in the ready to run list, this is the next ready to run thread. (potentially in a di...
Definition: tasking.h:51
Thread::errno
int errno
The errno value for this thread.
Definition: tasking.h:48
tasking_init
void tasking_init()
Definition: tasking.c:145
Thread::kernel_esp_top
void * kernel_esp_top
The top of the thread's kernel stack.
Definition: tasking.h:44
Thread::prev_ready_to_run
struct Thread * prev_ready_to_run
If the thread is in the ready to run list, this is the previous ready to run thread....
Definition: tasking.h:52
THREAD_READY
@ THREAD_READY
The state of a ready to run thread.
Definition: tasking.h:18
Thread::cr3
void * cr3
The address space of this thread. (it is in here and not in the process to simplify the task switch a...
Definition: tasking.h:45