pub fn switch_to(process: RcProcess) {
    assert!(process.lock().is_running());

    let old_process = current();

    let old_id = old_process.lock().id();
    let new_id = process.lock().id();

    let old_hw_state = old_process.lock().hw_state;
    let new_hw_state = process.lock().hw_state;

    trace!("SWITCH PID{} {:p} (strong={}) -> PID{} {:p} (strong={})",
        old_id, old_process, Arc::strong_count(&old_process),
        new_id, process, Arc::strong_count(&process));

    drop(old_process);

    // Don't switch pageset for processes that don't have a memory space.
    //
    // This allows kernel processes to have lighter context switching - the
    // kernel pageset is always accessible anyway.
    if let Some(pageset) = process.lock().pageset() {
        // Safety: we got the pageset from another process, so it shouldn't be
        // anything weird
        unsafe {
            paging::set_current_pageset(Some(pageset));
        }
    }

    drop(mem::replace(&mut global_state().lock().current_process, process));

    // Do the magic!
    unsafe {
        process_hw_switch(old_hw_state, new_hw_state);
    }
}
/// Change the current process (immediately).
///
/// # Panics
///
/// Panics if the process to switch to is not in the `Running` state.
Change the current process (immediately).
Change the current process ( immediately ) .
pub fn switch_to(process: RcProcess) {
    assert!(process.lock().is_running());
    let old_process = current();
    let old_id = old_process.lock().id();
    let new_id = process.lock().id();
    let old_hw_state = old_process.lock().hw_state;
    let new_hw_state = process.lock().hw_state;
    trace!("SWITCH PID{} {:p} (strong={}) -> PID{} {:p} (strong={})",
        old_id, old_process, Arc::strong_count(&old_process),
        new_id, process, Arc::strong_count(&process));
    drop(old_process);
    // Don't switch pageset for processes that don't have a memory space.
    //
    // This allows kernel processes to have lighter context switching - the
    // kernel pageset is always accessible anyway.
    if let Some(pageset) = process.lock().pageset() {
        // Safety: we got the pageset from another process, so it shouldn't be
        // anything weird
        unsafe {
            paging::set_current_pageset(Some(pageset));
        }
    }
    drop(mem::replace(&mut global_state().lock().current_process, process));
    // Do the magic!
    unsafe {
        process_hw_switch(old_hw_state, new_hw_state);
    }
}
pub fn switch_to ( process : RcProcess ) { assert ! ( process lock ( ) is_running ( ) ) ; let old_process = current ( ) ; let old_id = old_process . lock ( ) . id ( ) ; let new_id = process . lock ( ) . id ( ) ; let old_hw_state = old_process . lock ( ) . hw_state ; let new_hw_state = process . lock ( ) . hw_state ; trace ! ( " " old_id old_process Arc strong_count ( old_process ) new_id process Arc strong_count ( process ) ) ; drop ( old_process ) ; // Don't switch pageset for processes that don't have a memory space. // // This allows kernel processes to have lighter context switching - the // kernel pageset is always accessible anyway. if let Some ( pageset ) = process . lock ( ) . pageset ( ) { // Safety: we got the pageset from another process, so it shouldn't be // anything weird unsafe { paging :: set_current_pageset ( Some ( pageset ) ) ; } } drop ( mem :: replace ( & mut global_state ( ) . lock ( ) . current_process , process ) ) ; // Do the magic! unsafe { process_hw_switch ( old_hw_state , new_hw_state ) ; } }
Change the current process (immediately).
Change the current process ( immediately ) .
process
RcProcess
panics
Panics if the process to switch to is not in the `Running` state.
Panics if the process to switch to is not in the ` Running ` state .