Task.
More...
|
#define | MAX_TASKS 1024 |
| maximum number of tasks
|
|
#define | _4KB 0x1000 |
| 4KB are 4096 bytes, often used for stacks
|
|
|
enum | task_state_t { TASK_STOPPED,
TASK_RUNNING
} |
| state of a task
|
|
|
static task_t * | task_get (task_pid_t pid) |
| Returns the internal task structure associated with the given PID. More...
|
|
task_pid_t | task_add (task_t *task) |
| Adds a new task to the task list and associates a PID. More...
|
|
static void | task_remove (task_pid_t pid) |
| Removes a task from the task list. More...
|
|
static task_pid_t | task_create_detailed (void *entry_point, page_directory_t *page_directory, size_t kernel_stack_len, size_t user_stack_len, elf_t *elf, size_t code_segment, size_t data_segment) |
| Creates a task. More...
|
|
task_pid_t | task_create_kernel (void *entry_point, page_directory_t *page_directory, size_t kernel_stack_len) |
| Creates a kernel task. More...
|
|
task_pid_t | task_create_user (void *entry_point, page_directory_t *page_directory, size_t kernel_stack_len, size_t user_stack_len, void *elf) |
| Creates a user task. More...
|
|
void | task_stop (task_pid_t pid) |
| Stops a task. More...
|
|
void | task_destroy (task_pid_t pid) |
| Destroys a task. More...
|
|
task_pid_t | task_get_next_task (task_pid_t pid) |
| Returns the next task from the task list. More...
|
|
task_pid_t | task_get_next_task_with_state (task_pid_t pid, task_state_t state) |
| Returns the next task from the task list with a specified state. More...
|
|
task_state_t | task_get_ticks (task_pid_t pid) |
| Returns a task's number of remaining ticks. More...
|
|
uint32_t | task_set_ticks (task_pid_t pid, uint32_t ticks) |
| Sets a task's number of remaining ticks. More...
|
|
cpu_state_t * | task_get_cpu (task_pid_t pid) |
| Returns a task's CPU state. More...
|
|
void | task_set_cpu (task_pid_t pid, cpu_state_t *cpu) |
| Sets a task's CPU state. More...
|
|
page_directory_t * | task_get_page_directory (task_pid_t pid) |
| Returns a task's page directory. More...
|
|
uint8_t | task_get_vm86 (task_pid_t pid) |
| Returns whether a task is a VM86 task. More...
|
|
void * | task_get_elf (task_pid_t pid) |
| Returns a task's ELF file. More...
|
|
void | task_dump () |
| Dumps the task list. More...
|
|
Task.
This controls multitasking. Each tasks has two associated stacks, a kernel stack for interrupt handling and a user stack that serves as user call stack. Also each task has its own page directory and therefore virtual address space.
- See also
- http://www.lowlevel.eu/wiki/Teil_6_-_Multitasking
Adds a new task to the task list and associates a PID.
- Parameters
-
- Returns
- the task's PID
Definition at line 46 of file task.c.
static task_pid_t task_create_detailed |
( |
void * |
entry_point, |
|
|
page_directory_t * |
page_directory, |
|
|
size_t |
kernel_stack_len, |
|
|
size_t |
user_stack_len, |
|
|
elf_t * |
elf, |
|
|
size_t |
code_segment, |
|
|
size_t |
data_segment |
|
) |
| |
|
static |
Creates a task.
- Parameters
-
entry_point | the virtual address where to start execution |
page_directory | a page directory for the task, if 0 a new one is created |
kernel_stack_len | number of bytes to allocate for the kernel stack |
user_stack_len | number of bytes to allocate for the user stack |
elf | an ELF file, if 0 this is not an ELF task |
code_segment | a code segment in the GDT |
data_segment | a data segment in the GDT |
- Returns
- the task's PID
Prepares a CPU state to pop off when a timer interrupt occurs. The CPU state lies at the top of the task's kernel stack.
Makes an initial CPU state, setting the registers popped off in isr_asm.S.
Tells the scheduler to run this task.
Definition at line 75 of file task.c.
Creates a kernel task.
- Parameters
-
entry_point | the virtual address where to start execution |
page_directory | a page directory for the task, if 0 a new one is created |
kernel_stack_len | number of bytes to allocate for the kernel stack |
- Returns
- the task's PID
Definition at line 128 of file task.c.
task_pid_t task_create_user |
( |
void * |
entry_point, |
|
|
page_directory_t * |
page_directory, |
|
|
size_t |
kernel_stack_len, |
|
|
size_t |
user_stack_len, |
|
|
void * |
elf |
|
) |
| |
Creates a user task.
- Parameters
-
entry_point | the virtual address where to start execution |
page_directory | a page directory for the task, if 0 a new one is created |
kernel_stack_len | number of bytes to allocate for the kernel stack |
user_stack_len | number of bytes to allocate for the user stack |
elf | an ELF file, if 0 this is not an ELF task |
- Returns
- the task's PID
Definition at line 143 of file task.c.
Destroys a task.
This requires the task to have been stopped before.
- Parameters
-
Definition at line 161 of file task.c.
Dumps the task list.
The dump is logged.
Definition at line 283 of file task.c.
Returns the internal task structure associated with the given PID.
- Parameters
-
- Returns
- the task structure
Definition at line 33 of file task.c.
Returns a task's CPU state.
- Parameters
-
- Returns
- the task's CPU state
Definition at line 240 of file task.c.
Returns a task's ELF file.
- Parameters
-
- Returns
- the task's ELF file or 0
Definition at line 276 of file task.c.
Returns the next task from the task list.
- Parameters
-
pid | the current task's PID |
- Returns
- the next task's PID
Definition at line 184 of file task.c.
Returns the next task from the task list with a specified state.
- Parameters
-
pid | the current task's PID |
state | the next task's desired state |
- Returns
- the next task's PID
Definition at line 200 of file task.c.
Returns a task's page directory.
- Parameters
-
- Returns
- the task's page directory
Definition at line 258 of file task.c.
Returns a task's number of remaining ticks.
- Parameters
-
- Returns
- the task's number of remaining ticks
Definition at line 218 of file task.c.
Returns whether a task is a VM86 task.
- Parameters
-
- Returns
- whether the task is a VM86 task
Definition at line 267 of file task.c.
Removes a task from the task list.
- Parameters
-
Definition at line 60 of file task.c.
Sets a task's CPU state.
- Parameters
-
pid | the task's PID |
cpu | the task's CPU state |
Definition at line 249 of file task.c.
uint32_t task_set_ticks |
( |
task_pid_t |
pid, |
|
|
uint32_t |
ticks |
|
) |
| |
Sets a task's number of remaining ticks.
- Parameters
-
pid | the task's PID |
ticks | the number of remaining ticks |
- Returns
- the old number of remaining ticks
Definition at line 228 of file task.c.
Stops a task.
This does not remove the task from the task list.
- Parameters
-
Definition at line 153 of file task.c.
Array of tasks.
Fixed-size array for now, may change in the future.
Definition at line 26 of file task.c.