Example #1
0
void restore_regs(cmem *b,TRASH *t){
	for (int i=0;i<sizeof(_REG)/4;i++){
		if (t->reg[i].st && t->reg[i].l_st){
			restore_reg(b,t,i);
		}
	}
}
Example #2
0
void gen_call_op(cmem *b,TRASH *t,GEN_OP *o){
	cmem g;
	init_reg_var(t);
	int n1=rnd()%10+3;
	int n2=rnd()%10+3;
	gen_block(&g,t,n1);
	if (o->st){
		restore_reg(&g,t,o->reg1);
		restore_reg(&g,t,o->reg2);
		t->lc+=gen_op(&g,o);
	}
	gen_block(&g,t,n2);
	restore_regs(&g,t);
	GEN_CALL c;
	c.loc=t->l_size;
	c.narg=o->narg;
	gen_call(b,&c,&g);
}
Example #3
0
void syscall_gate() {
    __asm__("SYSTEM_CALL:");
        __asm__("pushl $0");
        store_reg();
        svc();
        restore_reg();
        __asm__("add $4, %esp");
        iret();
}
Example #4
0
void schedule(){
	saveall_reg();			//hurry not inclue sp	
	__asm__("pop %cx");
	__asm__("pop %eax");	//junk

	if( PCB_queue[ w_is_r].process_status == RUNNING){
		PCB_queue[ w_is_r].process_status = READY;
	}
	while(1){
		if( w_is_r == 0)
			nw_is_r = start_process_num;
		else
			nw_is_r = w_is_r + 1;

		if( nw_is_r > process_num){
			nw_is_r = start_process_num;	
		}
		if( PCB_queue[ nw_is_r].process_status == READY) break;
		w_is_r = nw_is_r;
	}
	
	PCB_queue[ nw_is_r].process_status = RUNNING;

	saveToqueue();			//code order don't change	

	//----------------set ip cs flag--------
	__asm__("pop %ax");
	__asm__("pop %bx");
	__asm__("pop %cx");

	saveall_reg_seg();		//include sp
	__asm__("pop %cx");

	if( _di == 0x1234){	
		isProcessRun = 0;			//shut down process
		nw_is_r = 0;
		process_num --;
		backto_os();
	}else{
		isProcessRun = 1;
	}


	PCB_queue[ w_is_r].tss.SP = _sp;
	PCB_queue[ w_is_r].tss.IP = _ip;
	PCB_queue[ w_is_r].tss.CS = _cs;
	PCB_queue[ w_is_r].tss.Flags = _flags;

	//-----------------end------------------
	_ip = PCB_queue[ nw_is_r].tss.IP;
	_cs = PCB_queue[ nw_is_r].tss.CS;
	_flags = PCB_queue[ nw_is_r].tss.Flags;
	_sp = PCB_queue[ nw_is_r].tss.SP;

	restore_reg_seg();		//include sp
	__asm__("pop %cx");

	queueTodata();		// ax bx cx...
	
	w_is_r = nw_is_r;			//change now running process
	restore_reg();	
	__asm__(" pop %di");		//don't use di in any process is dangerous

	__asm__(" jmp schedule_end");
	while(1);
}