rustubs/
proc.rs

1//! process and synchronization model
2
3use crate::arch::x86_64::is_int_enabled;
4use crate::defs;
5use crate::machine::keyctrl;
6use sync::bellringer;
7pub mod exec;
8pub mod loader;
9pub mod sched;
10pub mod sync;
11pub mod task;
12
13/// this is an optimization: reserve spaces in sync array to avoid runtime
14/// allocation inside of critical sections Note that the rust alloc collections
15/// doesn't have a API like "set this vec to at least xyz capacity." so we can
16/// only do a implicit `reserve` here. Meaning if this is called _after_ the the
17/// queues receive elements, they will have more capacity than specified here.
18/// safety: this function assmues interrupt is disabled
19pub fn init() {
20	assert!(!is_int_enabled());
21	sched::GLOBAL_SCHEDULER
22		.lock()
23		.run_queue
24		.reserve(defs::Limits::SCHED_RUN_QUEUE_MIN_CAP);
25	bellringer::BELLRINGER
26		.lock()
27		.bedroom
28		.reserve(defs::Limits::SEM_WAIT_QUEUE_MIN_CAP);
29	// semaphore has no "lock"
30	unsafe {
31		keyctrl::KEY_BUFFER
32			.get_pool_mut()
33			.reserve(defs::Limits::SEM_WAIT_QUEUE_MIN_CAP);
34	}
35}