feat: Aether OS v2.6 Solarized Warm Edition, x86_64 Rust microkernel, bootable ISO, and CA assessment reports
258148b verified Download CA6_Rust_Micro_OS_Project/src/timer.rs from varad130407/oslab: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/datasets/varad130407/oslab/resolve/main/CA6_Rust_Micro_OS_Project/src/timer.rs
- Command line
-
hf download hf://datasets/varad130407/oslab/CA6_Rust_Micro_OS_Project/src/timer.rs
-
curl -L -o timer.rs https://huggingface.co/datasets/varad130407/oslab/resolve/main/CA6_Rust_Micro_OS_Project/src/timer.rs
636 Bytes
| pub struct Timer { | |
| pub ticks: usize, | |
| pub quantum: usize, | |
| elapsed_in_quantum: usize, | |
| } | |
| impl Timer { | |
| pub fn new(quantum: usize) -> Self { | |
| assert!(quantum > 0, "timer quantum must be positive"); | |
| Self { | |
| ticks: 0, | |
| quantum, | |
| elapsed_in_quantum: 0, | |
| } | |
| } | |
| pub fn tick(&mut self) -> bool { | |
| self.ticks += 1; | |
| self.elapsed_in_quantum += 1; | |
| if self.elapsed_in_quantum == self.quantum { | |
| self.elapsed_in_quantum = 0; | |
| true | |
| } else { | |
| false | |
| } | |
| } | |
| } | |