『楼 主』:
[原创]dos下进程切换事例
使用 LLM 解释/回答一下
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define INTERRUPT 0xfc
unsigned task1;
unsigned task2;
int l=0;
int h=0;
int num=0;
//void (interrupt far * oldhandler)();
void os_task1(void)
{
while(1)
{
printf("this 1\n"<img src="images/smilies/face-wink.png" align="absmiddle" border="0">;
// getchar();
// sleep(1);
asm int 0xfc
}
}
void os_task2(void)
{
while(1)
{
printf("this 2\n"<img src="images/smilies/face-wink.png" align="absmiddle" border="0">;
// getchar();
// sleep(1);
asm int 0xfc
}
}
void interrupt far handler()
{
// printf("this is interrupt"<img src="images/smilies/face-wink.png" align="absmiddle" border="0">;
h++;
printf("num=%d\n",h);
if(l){
l=0;
//pusha
//pop
// printf("%d\n"",num
/* asm mov bx,offset task2
asm pop ax
asm mov word ptr ,ax
asm pop ax
asm mov word ptr ,ax
// asm popf
*/
{ asm pop ax
asm pop ax
asm pop ax
asm pop ax
asm mov bx,offset task1
asm mov ax,word ptr
asm push ax
asm mov ax,word ptr
asm push ax
//asm pushf
asm iret
} }
else
{
l=1;
asm pop ax
asm pop ax
asm pop ax
asm pop ax
// asm popf
asm mov bx,offset task2
asm mov ax,word ptr
asm push ax
asm mov ax,word ptr
asm push ax
// asm pushf
asm iret
}
}
main()
{
void interrupt far handler();
task1=FP_OFF(os_task1);
task1=FP_SEG(os_task1);
// task2=FP_OFF(os_task2);
// task2=FP_SEG(os_task2);
// os_task1();
// printf("task1=%04x task1=%04x\n",task1,task1);
task2=FP_OFF(os_task2);
task2=FP_SEG(os_task2);
setvect(INTERRUPT,handler);
// asm int 0xfc
os_task1();
}
msn:yaly163@hotmail.com
|