multi tasking: run executables
Posted: Fri Oct 03, 2008 2:38 pm
Have a nice day guy's:
today i have very interested question,most of us will faced
HOW to run 2,3,...,n executables @ the same time
the code bellow is a part of my UNEXT/os kernel
the problem is:
when i tried this code in my multi thread, each EXE will start from begining
need your opinions
today i have very interested question,most of us will faced
HOW to run 2,3,...,n executables @ the same time
the code bellow is a part of my UNEXT/os kernel
Code: Select all
int EXE_returnedValue;//var. to save returned offset
byte exec(char* fileName,void* _segment,char* parameter){
byte fileRetValue;
fileRetValue=_fopen(fileName,r); //open file
switch(fileRetValue){
case 0: return DIR_NOT_FOUND;
case 1: return FILE_NOT_FOUND;
}
_fcopy2segment(_segment); //copy content of file to buffer
_fclose(); //close file
_saveTCRegs(); //save turbo C registres and flags (AX,..)
EXE_returnedValue=(int)return_point;//get returned offset
_decompressMZ();//get CS,DS,SS from EXE
_setupMZ(); //setup new Regs,Flags for EXE
asm{ push MZ_segment //point to jump
push MZ_offset //CS:IP
retf //jump to our EXE
}
asm return_point label byte //when EXE finish will go here throu interrupt
return EXE_DONE;
}
void interrupt killEXE(){//this method must call from EXE to KILL process
_loadTCRegs();//return to previous TC registers
memset(_segment,NULL,_fSize());//clear buffer
asm{mov ax,cs
push ax
push EXE_returnedValue
retf
}
}
main(){
THREAD _thread; _thread.add(exec("system/Fileviw.exe",0x20000000L,"doc/test.txt"));
_thread.add(exec("system/bscript.exe",0x30000000L,"script/intro.bs"));
_thread.schedule();
}
when i tried this code in my multi thread, each EXE will start from begining
need your opinions