[][src]Function sunrise_kernel::scheduler::unschedule

pub fn unschedule<'a, LOCK, GUARD>(
    lock: &'a LOCK,
    guard: GUARD
) -> Result<GUARD, UserspaceError> where
    LOCK: Lock<'a, GUARD>,
    GUARD: 'a, 

Removes the current thread from the schedule queue, and schedule.

The passed lock will remain locked until the thread is safely removed from the schedule queue. In other words, event handling code should wait for that lock to be dropped before attempting to call add_to_schedule_queue.

The reason behind this behavior is that add_to_schedule_queue checks if a thread is currently in the schedule queue, before adding it in. It does the check by checking if the thread is either in the list of threads to run, or if it's the currently running one and in a Running state. The lock will be dropped once the thread is transitioned to the Stopped state, allowing add_to_schedule_queue to work again.

It will be relocked just before the thread starts running again. Specifically, it will be relocked when CURRENT_THREAD is set back to the current thread, but before its state is changed back to Running. This allows using SpinLockIRQs as a lock.

The lock should be used to avoid race conditions between registering for an event, and unscheduling.

The current thread will not be ran again unless it was registered for rescheduling.