#include <arch/paging.h>
#include <arch/i386.h>
Go to the source code of this file.
Data Structures | |||||||||||||
| struct | task | ||||||||||||
| The task structure. More... | |||||||||||||
| struct | tss | ||||||||||||
| TSS without I/O bit map. More... | |||||||||||||
| struct | tss_IO | ||||||||||||
| TSS with I/O bit map. More... | |||||||||||||
Defines | |||||||||||||
| #define | STACK_SIZE 0x8000 | ||||||||||||
| Stack size in byte for every kernel-mode task. | |||||||||||||
| #define | TASK_STACK_START 0xC0000000 | ||||||||||||
| The address where the user-privilege task stack is placed. | |||||||||||||
| #define | TASK_HEAP_START 0x40000000 | ||||||||||||
| The start of the heap for a user-mode task. | |||||||||||||
| #define | TASK_HEAP_DEFAULT_SIZE 0x40000000 | ||||||||||||
| The size of the heap for a user-mode task. | |||||||||||||
| #define | READY 1 | ||||||||||||
| The task is ready for the CPU. | |||||||||||||
| #define | WAIT 2 | ||||||||||||
| The task is waiting for I/O. | |||||||||||||
| #define | ZOMBIE 3 | ||||||||||||
| The task is dying. | |||||||||||||
| #define | KTHREAD_T 0x00 | ||||||||||||
| A kernel thread type. | |||||||||||||
| #define | PROCESS_T 0x01 | ||||||||||||
| A task type. | |||||||||||||
| #define | KERNEL_PRIVILEGE 0 | ||||||||||||
| Max privilege (kernel). | |||||||||||||
| #define | USER_PRIVILEGE 3 | ||||||||||||
| Min privilege (user). | |||||||||||||
| #define | MYSELF ( get_curr_task() ) | ||||||||||||
| Macro equivalent to get_curr_task() routine. | |||||||||||||
| #define | _exit(n) auto_kill(n) | ||||||||||||
| Macro equivalent to auto_kill() (...for now). | |||||||||||||
Typedefs | |||||||||||||
| typedef tss | tss_t | ||||||||||||
| TSS without I/O bit map. | |||||||||||||
| typedef tss_IO | tss_IO_t | ||||||||||||
| TSS with I/O bit map. | |||||||||||||
| typedef task | task_t | ||||||||||||
| The task structure. | |||||||||||||
Functions | |||||||||||||
| __inline__ void | idle () | ||||||||||||
| Halt the CPU until an interrupt occurs. | |||||||||||||
| __inline__ void | jmp_to_tss (word tss_sel) | ||||||||||||
Perform a context switch between two tasks.
| |||||||||||||
| void | dispatcher () | ||||||||||||
| The dispatcher. | |||||||||||||
| void | init_multitasking () | ||||||||||||
| Initialize the multitasking management. | |||||||||||||
| int | get_pid () | ||||||||||||
Return the current task pid if there is a curr_task.
| |||||||||||||
| char * | get_pname () | ||||||||||||
Return the current task name if there is a curr_task.
| |||||||||||||
| task_t * | get_curr_task () | ||||||||||||
Get the current task.
| |||||||||||||
| void | do_idle () | ||||||||||||
| Simply do nothing... | |||||||||||||
| task_t * | create_kthread (void *address, char *pname) | ||||||||||||
Create a new kernel thread.
| |||||||||||||
| task_t * | create_process (void *address, void *buffer, size_t size, char *pname, int privilege) | ||||||||||||
Create a new process.
| |||||||||||||
| task_t * | new_task (char *filename, int argc, char **argv, int privilege) | ||||||||||||
Execute a file creating a new task.
| |||||||||||||
| void | auto_kill (int n) | ||||||||||||
Kill the current running task.
| |||||||||||||
| bool | kill (pid_t pid) | ||||||||||||
Kill a task by the pid.
| |||||||||||||
| pid_t | waitpid (pid_t pid, int *status, int options) | ||||||||||||
Wait for the exit of a child.
| |||||||||||||
| void | sleep_task (task_t *p) | ||||||||||||
Sleep a process if it is awake.
| |||||||||||||
| void | wakeup_task (task_t *p) | ||||||||||||
Wakeup a process if it is sleeping.
| |||||||||||||
| void | sched_enter_critical_region () | ||||||||||||
Disable the scheduling of the other tasks.
| |||||||||||||
| void | sched_leave_critical_region () | ||||||||||||
| Re-enable scheduling for the other tasks. | |||||||||||||
| bool | is_sched_enabled () | ||||||||||||
| Return if the scheduling is enabled or not. | |||||||||||||
| void | ps () | ||||||||||||
| Print the state of every process from the ready, wait and zombie queues. | |||||||||||||
Definition in file task.h.
|
|
Macro equivalent to auto_kill() (...for now).
|
|
|
Max privilege (kernel).
|
|
|
A kernel thread type.
|
|
|
Macro equivalent to get_curr_task() routine.
|
|
|
A task type.
|
|
|
The task is ready for the CPU.
|
|
|
Stack size in byte for every kernel-mode task.
|
|
|
The size of the heap for a user-mode task.
|
|
|
The start of the heap for a user-mode task.
|
|
|
The address where the user-privilege task stack is placed.
|
|
|
Min privilege (user).
|
|
|
The task is waiting for I/O.
|
|
|
The task is dying.
|
|
|
The task structure.
|
|
|
TSS with I/O bit map.
|
|
|
TSS without I/O bit map.
|
|
|
Halt the CPU until an interrupt occurs.
Definition at line 109 of file task.h.
00110 {
00111 __asm__ __volatile__ ("hlt");
00112 }
|
|
|
Perform a context switch between two tasks.
This is an asm routine to jump to a TSS (TSS-based multitasking) Definition at line 121 of file task.h.
00122 {
00123 static struct {
00124 unsigned eip : 32; // 32 bit
00125 unsigned cs : 16; // 16 bit
00126 } __attribute__ ((packed)) tss_link = {0, 0};
00127
00128 // Set the TSS link //
00129 tss_link.cs = tss_sel;
00130
00131 // Jump to the task //
00132 __asm__ __volatile__ ("ljmp *(%0)" : : "m" (tss_link));
00133 }
|
1.2.18