MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / with_pagetable

Function with_pagetable

kernel/src/process.rs:426–445  ·  view source on GitHub ↗

Wrapper which runs a closure with a specified page table Ensures that the original page table is restored after the closure finishes.

(page_table_physaddr: u64, func: F)

Source from the content-addressed store, hash-verified

424/// Ensures that the original page table is restored after the
425/// closure finishes.
426fn with_pagetable<F, R>(page_table_physaddr: u64, func: F) -> R where
427 F: FnOnce() -> R {
428 // Store the page table and switch back before returning
429 let original_page_table = memory::active_pagetable_physaddr();
430
431 // Switch to the new user page table
432 //
433 // Note: We don't need to turn off interrupts because
434 // schedule_next() saves the page table for each thread. This
435 // thread temporarily has a different page table to the other
436 // threads.
437 memory::switch_to_pagetable(page_table_physaddr);
438
439 let result = func();
440
441 // Switch back to original page table
442 memory::switch_to_pagetable(original_page_table);
443
444 result
445}
446
447pub struct Params {
448 pub handles: Vec<Arc<RwLock<Rendezvous>>>,

Callers 1

new_user_threadFunction · 0.85

Calls 2

switch_to_pagetableFunction · 0.85

Tested by

no test coverage detected