Example #1
0
void scheduler_rr(uint32_t sp)
{
    int i;
    int vm_count;
    int prev_vm_id;
    int next_vm_id;

    bool vm_valid;
    bool not_in_wfi;

    vm_count = sizeof(vm) / sizeof(guest);
    prev_vm_id = vm_id;
    next_vm_id = vm_id;

    //switch to other guests first if possible
    for(i = 0; i < vm_count; i++)
    {
        next_vm_id++;

        if(next_vm_id == vm_count)
        {
            next_vm_id = 0;
        }

        vm_valid = vm[next_vm_id].valid;
        not_in_wfi = vm[next_vm_id].sched.wfi_state != WFI_In;

        if(vm_valid && not_in_wfi)
        {
            //printm(d_scheduler, "vm switch, vm %d to vm %d", prev_vm_id, next_vm_id);

            //leaving from wfi
            if(vm[next_vm_id].sched.wfi_state == WFI_PendingIRQ)
            {
                printd(d_scheduler, "leave wfi");
                vm[next_vm_id].sched.wfi_state = WFI_Out;
                //scheduler_wait_gic_vcpu_if();
            }

            guest_suspend(&vm[prev_vm_id], sp);
            guest_restore(&vm[next_vm_id], sp);

            monitor_trigger(&sys_monitor, VM_SWITCH);

            scheduler_reset_timer();
            scheduler_leave_idle();
            return;
        }
    }

    //nothing to switch
    guest_suspend(&vm[prev_vm_id], sp);

    scheduler_reset_timer();
    scheduler_enter_idle();

    //never return
    idle_thread();
}
Example #2
0
File: idle.c Project: mewbak/seL4
/** DONT_TRANSLATE */
void NORETURN NO_INLINE VISIBLE halt(void)
{
    /* halt is actually, idle thread without the interrupts */
    MSR("daif", (DAIF_DEBUG | DAIF_SERROR | DAIF_IRQ | DAIF_FIRQ));

#ifdef CONFIG_PRINTING
    printf("halting...");
#ifdef CONFIG_DEBUG_BUILD
    debug_printKernelEntryReason();
#endif
#endif
    idle_thread();
    UNREACHABLE();
}