feat: Aurora Neural OS v2.6 x86_64 microkernel, white theme GUI, and page replacement research
d097788 verified Download CA6_Rust_Micro_OS_Project/src/timer.rs from vedraj1309/oslab: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/datasets/vedraj1309/oslab/resolve/main/CA6_Rust_Micro_OS_Project/src/timer.rs
- Command line
-
hf download hf://datasets/vedraj1309/oslab/CA6_Rust_Micro_OS_Project/src/timer.rs
-
curl -L -o timer.rs https://huggingface.co/datasets/vedraj1309/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 | |
| } | |
| } | |
| } | |