LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
scheduler.h
Go to the documentation of this file.
1#ifndef _SCHEDULER_H_INCLUDED
2#define _SCHEDULER_H_INCLUDED
3
4#include <stdint.h>
5#include <vm.h>
6#include <cpu.h>
7
12
19
20extern volatile pid_t scheduler_current_process;
21
22#include <mutex.h>
23#include <condvar.h>
24
31
32void init_scheduler(void);
33void start_task(struct vm_table* context, ptr_t entry, ptr_t data_start, ptr_t data_end, const char* name);
34
35void schedule_next(cpu_state** cpu, struct vm_table** context);
36bool schedule_next_if_needed(cpu_state** cpu, struct vm_table** context);
38
39bool scheduler_handle_pf(ptr_t fault_address, uint64_t error_code);
41
42void scheduler_wait_for(pid_t pid, enum wait_reason reason, union wait_data data);
43void scheduler_waitable_done(enum wait_reason reason, union wait_data data, size_t max_amount);
44
46ptr_t scheduler_map_hardware(ptr_t hw, size_t len);
47
48#endif
uint64_t ptr_t
Definition arch.h:17
unsigned long uint64_t
Definition arch.h:14
int64_t pid_t
Definition arch.h:21
uint64_t condvar_t
Definition condvar.h:6
Definition cpu.h:7
char name[256]
Zero terminated string with the name of the file.
Definition loader.h:1
uint64_t mutex_t
Definition mutex.h:6
void scheduler_process_save(cpu_state *cpu)
Definition scheduler.c:155
void scheduler_wait_for(pid_t pid, enum wait_reason reason, union wait_data data)
Definition scheduler.c:353
void start_task(struct vm_table *context, ptr_t entry, ptr_t data_start, ptr_t data_end, const char *name)
Definition scheduler.c:136
void scheduler_kill_current(enum kill_reason kill_reason)
void scheduler_waitable_done(enum wait_reason reason, union wait_data data, size_t max_amount)
Definition scheduler.c:363
condvar_t condvar
Definition scheduler.h:27
mutex_t mutex
Definition scheduler.h:26
void init_scheduler(void)
Definition scheduler.c:87
void schedule_next(cpu_state **cpu, struct vm_table **context)
Definition scheduler.c:181
bool schedule_next_if_needed(cpu_state **cpu, struct vm_table **context)
Definition scheduler.c:221
uint64_t timestamp_ns_since_boot
Definition scheduler.h:29
bool scheduler_handle_pf(ptr_t fault_address, uint64_t error_code)
Definition scheduler.c:334
uint64_t message_queue
Definition scheduler.h:28
ptr_t scheduler_map_hardware(ptr_t hw, size_t len)
Map a given memory area in the currently running userspace process at a random location.
Definition scheduler.c:605
kill_reason
Definition scheduler.h:8
@ kill_reason_abort
Definition scheduler.h:10
@ kill_reason_segv
Definition scheduler.h:9
volatile pid_t scheduler_current_process
Definition scheduler.c:50
wait_reason
Definition scheduler.h:13
@ wait_reason_message
Definition scheduler.h:16
@ wait_reason_time
Definition scheduler.h:17
@ wait_reason_condvar
Definition scheduler.h:15
@ wait_reason_mutex
Definition scheduler.h:14
static void pid_t * pid
Definition syscalls.h:34
static void * entry
Definition syscalls.h:34
static void ** data_end
Definition syscalls.h:82
A paging table, when this is a PML4 it may also be called context.
Definition vm.c:42