[wip] Wrap scheduler-related calls in struct Scheduler for now, pending actual mod scope
This commit is contained in:
		
							parent
							
								
									d3c02f0f5b
								
							
						
					
					
						commit
						0e1c0e45f7
					
				| 
						 | 
				
			
			@ -86,8 +86,8 @@ fn handle_syscall(syscall: SysCall) -> Result<()> {
 | 
			
		|||
        SysCall::Yield => handle_yield(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    schedule();
 | 
			
		||||
    activateThread();
 | 
			
		||||
    Scheduler::schedule();
 | 
			
		||||
    Scheduler::activate_thread();
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -287,8 +287,8 @@ fn handle_interrupt_entry() -> Result<()> {
 | 
			
		|||
        handle_spurious_irq();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    schedule();
 | 
			
		||||
    activate_thread();
 | 
			
		||||
    Scheduler::schedule();
 | 
			
		||||
    Scheduler::activate_thread();
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -354,6 +354,41 @@ impl TCB {
 | 
			
		|||
 | 
			
		||||
// c_handle_syscall called directly from SWI vector entry
 | 
			
		||||
 | 
			
		||||
struct Scheduler;
 | 
			
		||||
 | 
			
		||||
impl Scheduler {
 | 
			
		||||
    /* Values of 0 and ~0 encode ResumeCurrentThread and ChooseNewThread
 | 
			
		||||
     * respectively; other values encode SwitchToThread and must be valid
 | 
			
		||||
     * tcb pointers */
 | 
			
		||||
    //KernelSchedulerAction
 | 
			
		||||
 | 
			
		||||
    fn schedule() {
 | 
			
		||||
        let action = KernelSchedulerAction;
 | 
			
		||||
        if action == !0 { // all ones..
 | 
			
		||||
            if KernelCurrentThread.is_runnable() {
 | 
			
		||||
                Scheduler::enqueue(KernelCurrentThread);
 | 
			
		||||
            }
 | 
			
		||||
            if KernelDomainTime == 0 {
 | 
			
		||||
                next_domain();
 | 
			
		||||
            }
 | 
			
		||||
            Scheduler::choose_thread();
 | 
			
		||||
            KernelSchedulerAction = 0;
 | 
			
		||||
        } else if action != 0 {
 | 
			
		||||
            if KernelCurrentThread.is_runnable() {
 | 
			
		||||
                Scheduler::enqueue(KernelCurrentThread);
 | 
			
		||||
            }
 | 
			
		||||
            Scheduler::switch_to_thread(KernelSchedulerAction);
 | 
			
		||||
            KernelSchedulerAction = 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn activate_thread() {}
 | 
			
		||||
 | 
			
		||||
    fn dequeue(thread: &mut TCB);
 | 
			
		||||
    fn append(thread: &mut TCB);
 | 
			
		||||
    fn reschedule_required();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Nucleus {}
 | 
			
		||||
 | 
			
		||||
impl API for Nucleus {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue