LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
scheduler.h File Reference

(29312b1 fbconsole, panic: render panic after framebuffer was given to userspace - without clearing screen contents)

#include <stdint.h>
#include <vm.h>
#include <cpu.h>
#include <mutex.h>
#include <condvar.h>
+ Include dependency graph for scheduler.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  wait_data
 

Enumerations

enum  kill_reason { kill_reason_segv = 1 , kill_reason_abort = 2 }
 
enum  wait_reason { wait_reason_mutex , wait_reason_condvar , wait_reason_message , wait_reason_time }
 

Functions

void init_scheduler (void)
 
void start_task (struct vm_table *context, ptr_t entry, ptr_t data_start, ptr_t data_end, const char *name)
 
void schedule_next (cpu_state **cpu, struct vm_table **context)
 
bool schedule_next_if_needed (cpu_state **cpu, struct vm_table **context)
 
void scheduler_process_save (cpu_state *cpu)
 
bool scheduler_handle_pf (ptr_t fault_address, uint64_t error_code)
 
void scheduler_kill_current (enum kill_reason kill_reason)
 
void scheduler_wait_for (pid_t pid, enum wait_reason reason, union wait_data data)
 
void scheduler_waitable_done (enum wait_reason reason, union wait_data data, size_t max_amount)
 
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.
 

Variables

volatile pid_t scheduler_current_process
 

Data Structure Documentation

◆ wait_data

union wait_data

Definition at line 25 of file scheduler.h.

+ Collaboration diagram for wait_data:
Data Fields
condvar_t condvar
uint64_t message_queue
mutex_t mutex
uint64_t timestamp_ns_since_boot

Enumeration Type Documentation

◆ kill_reason

Enumerator
kill_reason_segv 
kill_reason_abort 

Definition at line 8 of file scheduler.h.

◆ wait_reason

Enumerator
wait_reason_mutex 
wait_reason_condvar 
wait_reason_message 
wait_reason_time 

Definition at line 13 of file scheduler.h.

Function Documentation

◆ init_scheduler()

void init_scheduler ( void  )

Definition at line 87 of file scheduler.c.

References MAX_PROCS, memset(), and processes.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ schedule_next()

void schedule_next ( cpu_state **  cpu,
struct vm_table **  context 
)

Definition at line 181 of file scheduler.c.

References process_t::context, process_t::cpu, MAX_PROCS, pid, process, process_state_runnable, process_state_running, process_state_waiting, processes, sc_handle_clock_read(), scheduler_current_process, scheduler_idle_if_needed(), process_t::state, state, and wait_reason_time.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ schedule_next_if_needed()

bool schedule_next_if_needed ( cpu_state **  cpu,
struct vm_table **  context 
)

Definition at line 221 of file scheduler.c.

References process_state_runnable, process_state_running, processes, schedule_next(), scheduler_current_process, and state.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scheduler_handle_pf()

bool scheduler_handle_pf ( ptr_t  fault_address,
uint64_t  error_code 
)

Definition at line 334 of file scheduler.c.

References ALLOCATOR_REGION_DIRECT_MAPPING, ALLOCATOR_REGION_USER_STACK, logw, memset(), mm_alloc_pages(), name, processes, scheduler_current_process, process_t::stack, region_t::start, and vm_context_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scheduler_kill_current()

void scheduler_kill_current ( enum kill_reason  kill_reason)

◆ scheduler_map_hardware()

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 at line 605 of file scheduler.c.

References region_t::end, process_t::hw, processes, scheduler_current_process, and vm_map_hardware().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scheduler_process_save()

void scheduler_process_save ( cpu_state cpu)

Definition at line 155 of file scheduler.c.

References memcpy(), process_state_running, process_state_waiting, processes, scheduler_current_process, and state.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scheduler_wait_for()

void scheduler_wait_for ( pid_t  pid,
enum wait_reason  reason,
union wait_data  data 
)

Definition at line 353 of file scheduler.c.

References pid, process_state_waiting, processes, scheduler_current_process, process_t::state, process_t::waiting_data, and process_t::waiting_for.

+ Here is the caller graph for this function:

◆ scheduler_waitable_done()

void scheduler_waitable_done ( enum wait_reason  reason,
union wait_data  data,
size_t  max_amount 
)

Definition at line 363 of file scheduler.c.

References wait_data::condvar, MAX_PROCS, wait_data::message_queue, wait_data::mutex, mutex_lock(), pid, process_state_runnable, process_state_waiting, processes, scheduler_current_process, process_t::state, wait_reason_condvar, wait_reason_message, wait_reason_mutex, wait_reason_time, process_t::waiting_data, and process_t::waiting_for.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start_task()

void start_task ( struct vm_table context,
ptr_t  entry,
ptr_t  data_start,
ptr_t  data_end,
const char *  name 
)

Definition at line 136 of file scheduler.c.

References ALLOCATOR_REGION_USER_STACK, data_end, entry, name, panic_message(), process_t::parent, pid, process, processes, setup_process(), and strncpy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ scheduler_current_process

volatile pid_t scheduler_current_process
extern

Definition at line 50 of file scheduler.c.