当前位置: 技术问答>linux和unix
tc 下面,中断函数的编写及线程的调度!
来源: 互联网 发布时间:2015-08-29
本文导语: 我做了一个操作系统的线程调度程序,有点问题,各位帮忙看看! 是在tc 下面做的。涉及到中断函数的编写。 #include #include #include #include #include #define TL 5 #define FINISHED 0 #define RUNNING 1 #define READY 2 #define...
我做了一个操作系统的线程调度程序,有点问题,各位帮忙看看!
是在tc 下面做的。涉及到中断函数的编写。
#include
#include
#include
#include
#include
#define TL 5
#define FINISHED 0
#define RUNNING 1
#define READY 2
#define BLOCKED 3
#define NTCB 10
#define GET_INDOS 0x34
#define GET_CRIT_ERR 0x5d06
char far *indos_ptr=0;
char far *crit_err_ptr=0;
extern int current=0;/**/
int timeout=0;
void interrupt(*old_int8)(void);
void interrupt new_int8(void);
typedef int(far *codeptr)(void);
void interrupt swtch(void);
void tcb_state(void);
int create(char *name,codeptr code,int stacklen);
void over(void);
void InitInDos(void);
int DosBusy(void);
int P_choice(void);
struct int_regs{
unsigned bp;
unsigned di;
unsigned si;
unsigned ds;
unsigned es;
unsigned dx;
unsigned cx;
unsigned bx;
unsigned ax;
unsigned ip;
unsigned cs;
unsigned flags;
};
struct char_regs
{
unsigned char al;
unsigned char ah;
unsigned char bl;
unsigned char bh;
unsigned char cl;
unsigned char ch;
unsigned char dl;
unsigned char dh;
};
union fregs{
struct int_regs x;
struct char_regs h;
};
struct fsregs{
unsigned es;
unsigned cs;
unsigned ss;
unsigned ds;
};
struct TCB{
unsigned char* stack;
unsigned int ss;
unsigned int sp;
char state;
char name[10];
}tcb[NTCB];
void interrupt swtch(void){
int i;
(*old_int8)();
InitInDos();
if(DosBusy){
disable();
tcb[current].ss=_SS;
tcb[current].sp=_SP;
if(tcb[current].state==RUNNING)
tcb[current].state=READY;
i=P_choice();
_SP=tcb[i].sp;
_SS=tcb[i].ss;
tcb[i].state=RUNNING;
current=i;
timeout=0;
enable();
}
}
void interrupt new_int8(void){
int i;
(*old_int8)();
InitInDos();
if(timeout++
是在tc 下面做的。涉及到中断函数的编写。
#include
#include
#include
#include
#include
#define TL 5
#define FINISHED 0
#define RUNNING 1
#define READY 2
#define BLOCKED 3
#define NTCB 10
#define GET_INDOS 0x34
#define GET_CRIT_ERR 0x5d06
char far *indos_ptr=0;
char far *crit_err_ptr=0;
extern int current=0;/**/
int timeout=0;
void interrupt(*old_int8)(void);
void interrupt new_int8(void);
typedef int(far *codeptr)(void);
void interrupt swtch(void);
void tcb_state(void);
int create(char *name,codeptr code,int stacklen);
void over(void);
void InitInDos(void);
int DosBusy(void);
int P_choice(void);
struct int_regs{
unsigned bp;
unsigned di;
unsigned si;
unsigned ds;
unsigned es;
unsigned dx;
unsigned cx;
unsigned bx;
unsigned ax;
unsigned ip;
unsigned cs;
unsigned flags;
};
struct char_regs
{
unsigned char al;
unsigned char ah;
unsigned char bl;
unsigned char bh;
unsigned char cl;
unsigned char ch;
unsigned char dl;
unsigned char dh;
};
union fregs{
struct int_regs x;
struct char_regs h;
};
struct fsregs{
unsigned es;
unsigned cs;
unsigned ss;
unsigned ds;
};
struct TCB{
unsigned char* stack;
unsigned int ss;
unsigned int sp;
char state;
char name[10];
}tcb[NTCB];
void interrupt swtch(void){
int i;
(*old_int8)();
InitInDos();
if(DosBusy){
disable();
tcb[current].ss=_SS;
tcb[current].sp=_SP;
if(tcb[current].state==RUNNING)
tcb[current].state=READY;
i=P_choice();
_SP=tcb[i].sp;
_SS=tcb[i].ss;
tcb[i].state=RUNNING;
current=i;
timeout=0;
enable();
}
}
void interrupt new_int8(void){
int i;
(*old_int8)();
InitInDos();
if(timeout++