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 #include "rpc.h"
11 
12 #ifndef TASKING_H
13 
17 typedef enum thread_state {
25 
26 #endif
27 
28 struct Thread;
29 
33 typedef struct Process {
34  char priv;
35  pid_t pid;
36  pid_t next_tid;
39  struct Thread* first_thread;
40 } Process;
41 
45 typedef struct Thread {
46  void* kernel_esp;
48  void* address_space;
49  pid_t tid;
51  int errno;
59  void* rpc_ret_buf;
60 } Thread;
61 
62 extern Thread* current_thread;
63 
73 void tasking_create_task(void* eip,void* address_space,char kmode,void* param1,void* param2,char isThread);
77 void tasking_init();
87 pid_t tasking_get_PID();
92 pid_t tasking_get_TID();
105 pid_t tasking_new_thread(void* start,pid_t pid,void* param);
106 
113 void tasking_exit(int code);
118 void tasking_block(thread_state newstate);
124 void tasking_unblock(pid_t pid,pid_t tid);
128 void tasking_yield();
134 void* tasking_get_address_space(pid_t pid);
135 
141 void tasking_set_rpc_calling_thread(pid_t pid,pid_t tid);
142 
149 pid_t tasking_get_rpc_calling_thread(pid_t* tid);
154 void tasking_set_rpc_ret_buf(void* buf);
155 
161 
165 void tasking_thread_exit();
166 
172 char tasking_check_proc_exists(pid_t pid);
173 
174 #endif
current_thread
Thread * current_thread
Currently running thread.
Definition: tasking.c:23
Process::num_threads
int num_threads
The number of threads in this process.
Definition: tasking.h:37
Thread::prev_thread_in_process
struct Thread * prev_thread_in_process
The previous thread in the process.
Definition: tasking.h:53
THREAD_WAITING_FOR_RPC_INIT
@ THREAD_WAITING_FOR_RPC_INIT
The state of a thread waiting for a process to fully initilaize it's RPC functions.
Definition: tasking.h:23
tasking_get_rpc_calling_thread
pid_t tasking_get_rpc_calling_thread(pid_t *tid)
Definition: tasking.c:366
Thread::rpc_ret_buf
void * rpc_ret_buf
The return buffer of the RPC call that the thread made.
Definition: tasking.h:59
tasking_get_address_space
void * tasking_get_address_space(pid_t pid)
Definition: tasking.c:356
tasking_check_proc_exists
char tasking_check_proc_exists(pid_t pid)
Definition: tasking.c:386
Thread::rpc_calling_pid
pid_t rpc_calling_pid
The PID of the thread that called this RPC (only used for RPC handler threads)
Definition: tasking.h:57
Thread::state
thread_state state
The state of this thread. (running,ready to run,blocked,etc.)
Definition: tasking.h:50
tasking_get_errno_address
int * tasking_get_errno_address()
Definition: tasking.c:143
tasking_yield
void tasking_yield()
Definition: tasking.c:214
Process::num_threads_blocked
int num_threads_blocked
The number of blocked threads in this process.
Definition: tasking.h:38
thread_state
thread_state
Definition: tasking.h:17
tasking_new_thread
pid_t tasking_new_thread(void *start, pid_t pid, void *param)
Definition: tasking.c:147
THREAD_WAITING_FOR_RPC
@ THREAD_WAITING_FOR_RPC
The state of a thread waiting for an RPC call to return.
Definition: tasking.h:22
THREAD_BLOCKED
@ THREAD_BLOCKED
The state of a generically blocked thread.
Definition: tasking.h:21
THREAD_RUNNING
@ THREAD_RUNNING
The state of a running thread.
Definition: tasking.h:18
Thread::next_thread_in_process
struct Thread * next_thread_in_process
The next thread in the process.
Definition: tasking.h:52
tasking_get_TID
pid_t tasking_get_TID()
Definition: tasking.c:139
rpc.h
Thread::process
Process * process
The thread's process.
Definition: tasking.h:56
Process::next_tid
pid_t next_tid
The TID that the next created thread will use.
Definition: tasking.h:36
tasking_thread_exit
void tasking_thread_exit()
Definition: tasking.c:382
tasking_is_privleged
char tasking_is_privleged()
Definition: tasking.c:131
Thread::tid
pid_t tid
The TID of this thread.
Definition: tasking.h:49
tasking_unblock
void tasking_unblock(pid_t pid, pid_t tid)
Definition: tasking.c:306
tasking_set_rpc_calling_thread
void tasking_set_rpc_calling_thread(pid_t pid, pid_t tid)
Definition: tasking.c:360
tasking_get_PID
pid_t tasking_get_PID()
Definition: tasking.c:135
tasking_exit
void tasking_exit(int code)
Definition: tasking.c:321
Thread
Definition: tasking.h:45
Thread::rpc_calling_tid
pid_t rpc_calling_tid
The TID of the thread that called this RPC (only used for RPC handler threads)
Definition: tasking.h:58
THREAD_EXITED
@ THREAD_EXITED
The state of an exited thread.
Definition: tasking.h:20
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:34
Thread::kernel_esp
void * kernel_esp
The thread's kernel stack.
Definition: tasking.h:46
Process::first_thread
struct Thread * first_thread
A pointer to the head of the linked list of threads for this process.
Definition: tasking.h:39
tasking_create_task
void tasking_create_task(void *eip, void *address_space, char kmode, void *param1, void *param2, char isThread)
Definition: tasking.c:90
tasking_block
void tasking_block(thread_state newstate)
Definition: tasking.c:244
Process::pid
pid_t pid
The PID of this process.
Definition: tasking.h:35
Process
Definition: tasking.h:33
tasking_get_rpc_ret_buf
void * tasking_get_rpc_ret_buf()
Definition: tasking.c:378
tasking_set_rpc_ret_buf
void tasking_set_rpc_ret_buf(void *buf)
Definition: tasking.c:371
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:54
Thread::errno
int errno
The errno value for this thread.
Definition: tasking.h:51
tasking_init
void tasking_init()
Definition: tasking.c:123
Thread::kernel_esp_top
void * kernel_esp_top
The top of the thread's kernel stack.
Definition: tasking.h:47
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:55
Thread::address_space
void * address_space
The address space of this thread. (it is in here and not in the process to simplify the task switch a...
Definition: tasking.h:48
THREAD_READY
@ THREAD_READY
The state of a ready to run thread.
Definition: tasking.h:19