Copyright Cristian-Stefan Lazar 324CA
This crate provides implementation for 3 schedulers:
- Round Robin
- Round Robin with priorities
- Completely Fair Scheduler (CFS)
- highest_pid
- minimum_remaining_timeslice
- ready_processes
- remaining_time
- running_process
- sleep_time
- stopped_process
- timeslice
- waiting_processes
Struct scheduler::schedulers::round_robin::RoundRobinScheduler
Expand description
Data structure that implements a round robin scheduler.
Fields§
running_process: Option<Pcb>
The process running on the processor.
stopped_process: Option<Pcb>
Intermediate state a process is in during syscalls.
remaining_time: usize
The remaining execution time for the scheduled process.
ready_processes: Vec<Pcb>
The list of all processes ready to be scheduled.
waiting_processes: Vec<Pcb>
The list of all processes waiting for an event or sleeping.
timeslice: NonZeroUsize
The amount of time a ready process gets on the processor.
minimum_remaining_timeslice: usize
The minimum required time on the processor the stopped process must have remaining for it to be scheduled imediately after the syscall that stopped it.
highest_pid: usize
The highest pid given to a process.
sleep_time: usize
The amount of time the processor needs to sleep for a process to wake up if there are no ready processes to schedule.
Is 0
if there are ready processes.
Implementations§
§impl RoundRobinScheduler
impl RoundRobinScheduler
pub fn new(timeslice: NonZeroUsize, minimum_remaining_timeslice: usize) -> Self
pub fn new(timeslice: NonZeroUsize, minimum_remaining_timeslice: usize) -> Self
Creates a new RoundRobinScheduler
.
fn increment_timings(&mut self, _reason: &StopReason)
fn increment_timings(&mut self, _reason: &StopReason)
Increments the timings for all processes.
fn wakeup_processes(&mut self)
fn wakeup_processes(&mut self)
Moves processes that have waked up into the list of ready processes.
fn sleep(&mut self)
fn sleep(&mut self)
Sleeps for the amount of time needed for a process to become ready for scheduling.
fn new_process(&mut self, priority: i8)
fn new_process(&mut self, priority: i8)
Forks a new process with the given priority.
fn set_running(&mut self, process: Pcb)
fn set_running(&mut self, process: Pcb)
Sets a process to into the running state.
fn pid_1_exists(&self) -> bool
fn pid_1_exists(&self) -> bool
Returns true
if the process with pid 1 exists, false
otherwise.
fn scheduled_process(&mut self) -> Option<Pcb>
fn scheduled_process(&mut self) -> Option<Pcb>
Returns the process scheduled to be run.
fn find_sleep_time(&self) -> Option<usize>
fn find_sleep_time(&self) -> Option<usize>
Returns the minimal amount of time the processor needs to sleep for a process to become ready for scheduling.
fn get_all_processes(&self) -> Vec<&Pcb>
fn get_all_processes(&self) -> Vec<&Pcb>
Return an vector of refrences to all processes.
fn syscall_handler(
&mut self,
syscall: Syscall,
remaining_time: usize
) -> SyscallResult
fn syscall_handler(
&mut self,
syscall: Syscall,
remaining_time: usize
) -> SyscallResult
Handles syscalls recievied from the running process.
Trait Implementations§
§impl Scheduler for RoundRobinScheduler
impl Scheduler for RoundRobinScheduler
§fn next(&mut self) -> SchedulingDecision
fn next(&mut self) -> SchedulingDecision
§fn stop(&mut self, _reason: StopReason) -> SyscallResult
fn stop(&mut self, _reason: StopReason) -> SyscallResult
Auto Trait Implementations§
impl RefUnwindSafe for RoundRobinScheduler
impl Send for RoundRobinScheduler
impl Sync for RoundRobinScheduler
impl Unpin for RoundRobinScheduler
impl UnwindSafe for RoundRobinScheduler
Blanket Implementations§
- highest_pid
- minimum_remaining_timeslice
- ready_processes
- remaining_time
- running_process
- sleep_time
- stopped_process
- timeslice
- waiting_processes
Expand description
Data structure that implements a round robin scheduler.
Fields§
running_process: Option<Pcb>
The process running on the processor.
stopped_process: Option<Pcb>
Intermediate state a process is in during syscalls.
remaining_time: usize
The remaining execution time for the scheduled process.
ready_processes: Vec<Vec<Pcb>>
The list of process queues, separated by priority.
waiting_processes: Vec<Pcb>
The list of all processes waiting for an event or sleeping.
timeslice: NonZeroUsize
The amount of time a ready process gets on the processor.
minimum_remaining_timeslice: usize
The minimum required time on the processor the stopped process must have remaining for it to be scheduled imediately after the syscall that stopped it.
highest_pid: usize
The highest pid given to a process.
sleep_time: usize
The amount of time the processor needs to sleep for a process to wake up if there are no ready processes to schedule.
Is 0
if there are ready processes.
Implementations§
§
pub fn new(timeslice: NonZeroUsize, minimum_remaining_timeslice: usize) -> Self
pub fn new(timeslice: NonZeroUsize, minimum_remaining_timeslice: usize) -> Self
Creates a new RoundRobinPrioritiesScheduler
.
fn wakeup_processes(&mut self)
fn wakeup_processes(&mut self)
Moves processes that have waked up into the list of ready processes.
fn increment_timings(&mut self, _reason: &StopReason)
fn increment_timings(&mut self, _reason: &StopReason)
Increments the timings for all processes.
fn sleep(&mut self)
fn sleep(&mut self)
Sleeps for the amount of time needed for a process to become ready for scheduling.
fn new_process(&mut self, priority: i8)
fn new_process(&mut self, priority: i8)
Forks a new process with the given priority.
fn syscall_handler(
&mut self,
syscall: Syscall,
remaining_time: usize
) -> SyscallResult
fn syscall_handler(
&mut self,
syscall: Syscall,
remaining_time: usize
) -> SyscallResult
Handles syscalls recievied from the running process.
fn pid_1_exists(&self) -> bool
fn pid_1_exists(&self) -> bool
Returns true
if the process with pid 1 exists, false
otherwise.
fn scheduled_process(&mut self) -> Option<Pcb>
fn scheduled_process(&mut self) -> Option<Pcb>
Returns the process scheduled to be run.
fn find_sleep_time(&self) -> Option<usize>
fn find_sleep_time(&self) -> Option<usize>
Returns the minimal amount of time the processor needs to sleep for a process to become ready for scheduling.
fn set_running(&mut self, process: Pcb)
fn set_running(&mut self, process: Pcb)
Sets a process to into the running state.
fn get_all_processes(&self) -> Vec<&Pcb>
fn get_all_processes(&self) -> Vec<&Pcb>
Return an vector of refrences to all processes.
Trait Implementations§
§impl Scheduler for RoundRobinPrioritiesScheduler
impl Scheduler for RoundRobinPrioritiesScheduler
§fn next(&mut self) -> SchedulingDecision
fn next(&mut self) -> SchedulingDecision
§fn stop(&mut self, _reason: StopReason) -> SyscallResult
fn stop(&mut self, _reason: StopReason) -> SyscallResult
Auto Trait Implementations§
impl Send for RoundRobinPrioritiesScheduler
impl Sync for RoundRobinPrioritiesScheduler
impl Unpin for RoundRobinPrioritiesScheduler
impl UnwindSafe for RoundRobinPrioritiesScheduler
Blanket Implementations§
- cpu_time
- highest_pid
- minimum_remaining_timeslice
- ready_processes
- remaining_time
- running_process
- sleep_time
- stopped_process
- waiting_processes
Struct scheduler::schedulers::cfs::Cfs
Expand description
Data structure that implements a round robin scheduler.
Fields§
running_process: Option<Pcb>
The process running on the processor.
stopped_process: Option<Pcb>
Intermediate state a process is in during syscalls.
remaining_time: usize
The remaining execution time for the scheduled process.
ready_processes: Vec<Pcb>
The list of all processes ready to be scheduled.
waiting_processes: Vec<Pcb>
The list of all processes waiting for an event or sleeping.
cpu_time: NonZeroUsize
The amount of time a ready process gets on the processor.
minimum_remaining_timeslice: usize
The minimum required time on the processor the stopped process must have remaining for it to be scheduled imediately after the syscall that stopped it.
highest_pid: usize
The highest pid given to a process.
sleep_time: usize
The amount of time the processor needs to sleep for a process to wake up if there are no ready processes to schedule.
Is 0
if there are ready processes.
Implementations§
§impl Cfs
impl Cfs
pub fn new(cpu_time: NonZeroUsize, minimum_remaining_timeslice: usize) -> Self
pub fn new(cpu_time: NonZeroUsize, minimum_remaining_timeslice: usize) -> Self
Creates a new Cfs
.
fn increment_timings(&mut self, _reason: &StopReason)
fn increment_timings(&mut self, _reason: &StopReason)
Increments the timings for all processes.
fn wakeup_processes(&mut self)
fn wakeup_processes(&mut self)
Moves processes that have waked up into the list of ready processes.
fn sleep(&mut self)
fn sleep(&mut self)
Sleeps for the amount of time needed for a process to become ready for scheduling.
fn new_process(&mut self, priority: i8, vruntime: usize)
fn new_process(&mut self, priority: i8, vruntime: usize)
Forks a new process with the given priority.
fn set_running(&mut self, process: Pcb, timeslice: usize)
fn set_running(&mut self, process: Pcb, timeslice: usize)
Sets a process to into the running state.
fn pid_1_exists(&self) -> bool
fn pid_1_exists(&self) -> bool
Returns true
if the process with pid 1 exists, false
otherwise.
fn scheduled_process(&mut self) -> Option<Pcb>
fn scheduled_process(&mut self) -> Option<Pcb>
Returns the process scheduled to be run.
fn find_sleep_time(&self) -> Option<usize>
fn find_sleep_time(&self) -> Option<usize>
Returns the minimal amount of time the processor needs to sleep for a process to become ready for scheduling.
fn get_all_processes(&self) -> Vec<&Pcb>
fn get_all_processes(&self) -> Vec<&Pcb>
Return an vector of refrences to all processes.
fn min_vruntime(&self) -> usize
fn min_vruntime(&self) -> usize
Gets the minimum timeslice from all processes.
fn compute_timeslice(&self) -> NonZeroUsize
fn compute_timeslice(&self) -> NonZeroUsize
Computes the timeslice for the scheduled process.
fn syscall_handler(
&mut self,
syscall: Syscall,
remaining_time: usize
) -> SyscallResult
fn syscall_handler(
&mut self,
syscall: Syscall,
remaining_time: usize
) -> SyscallResult
Handles syscalls recievied from the running process.