void _arch_irq_task_switch(void * _cpu_state) { if(run_queue) { spinlock_lock(&run_queue->spinlock); get_system_time(&run_queue->sched_time); struct kthread * c = run_queue_current(); struct kthread * n = run_queue_next(); spinlock_unlock(&run_queue->spinlock); _BUG_ON(!n); _BUG_ON(!c); if(stack_check(&(c->stack))<0) _BUG(); // TASK WE JUST PUT TO SLEEP BLEW ITS STACK! _switch(c,n,_cpu_state); // schedule next switch. _sched_next_task(NULL); } }
bool AboutConstruction::onEvent(const NEvent& event) { switch( event.EventType ) { case sEventKeyboard: if( event.keyboard.key == KEY_COMMA || event.keyboard.key == KEY_PERIOD ) { _switch( event.keyboard.key ); } break; case sEventGui: if( event.gui.type == guiButtonClicked && ( event.gui.caller->ID() == KEY_COMMA || event.gui.caller->ID() == KEY_PERIOD ) ) { _switch(event.gui.caller->ID()); } break; default: break; } return Infobox::onEvent( event ); }
void _stdcall main(unsigned long p1, unsigned long p2, unsigned long p3) { uint32 *oldesp; struct taskblock *task; _cli(); cpuInit(); _ISRVECT[17]=(uint32)keDoSched; _ISRVECT[32]=(uint32)keTimerIsr; keKernelHeapInit(); keInitTaskSystem(); task=keNewTask("main", keEntryMain, 0, 8, 0x4000); currentTaskId=0; _switch(&(task->esp), &oldesp); }
void keDoSched() { uint32 i; uint32 j; _cli(); i=keSchedNextTask(); while(i==0xFFFFFFFF) { _sti(); _hlt(); _cli(); i=keSchedNextTask(); } // not any task can be sched if(i==currentTaskId) { _sti(); return; // only the current task can be sched } j=currentTaskId; currentTaskId=i; _switch(&(tasks[i]->esp), &(tasks[j]->esp)); }
{ struct task_struct *last; struct thread_info *new_ti, *old_ti; unsigned long flags; local_irq_save(flags); /* */ new_ti = new->stack; old_ti = old->stack; current_thread_info_set[smp_processor_id()] = new_ti; last = (_switch(old_ti, new_ti))->task; local_irq_restore(flags); return last; } /* */ void dump_elf_thread(elf_greg_t *dest, struct pt_regs* regs) { dest[0] = 0; /* */ memcpy(dest+1, regs->gpr+1, 31*sizeof(unsigned long)); dest[32] = regs->pc;