📄 global.h
字号:
/****************************************************************************
*****************************************************************************
文件名称: GLOBAL.H
模块名称: 全局变量定义模块
模块作用:
编写者一: 蔡晓跃(AP0106338)
编写者二:
编写日期:
完成日期:
程序行数: 380
*****************************************************************************
*****************************************************************************/
#define LINEEND 10
#define ENTERKEY 13
#define FREE 0
#define TAKEN 1
#define TRUE 1
#define FALSE 0
#define JOB 1001
#define BEGIN 1002
#define POB 1003
#define DATA 1004
#define DOE 1005
#define POE 1006
#define JOE 1007
#define INSTRUCTION 1008
#define PAGESIZE 100
#define MEMORYSIZE 300
#define HARDDISKSIZE 1000
#define SYSTEM_JOB_SCHEDUL -1
#define SYSTEM_PROCESS_SCHEDUL -2
#define SYSTEM_KILL_PROCESS -3
#define SYSTEM_SUPERWAIT -4
#define SYSTEM_INPUT_PROCESS -5
#define SYSTEM_OUTPUT_PROCESS -6
#define SUCCEED 1
#define OUTOFMEMORY 2
#define UNKOWN_INSTRUCTION 3
#define PROCESSFINISH 4
#define TIMEOUT 5
#define INTERRUPT 6
#define PI 0
#define PI0 0
#define PI1 1
#define PI2 2
#define PI3 3
#define PI4 4
#define PI5 5
#define PI6 6
#define PI7 7
#define PI8 8
#define SI 1
#define SI0 0
#define SI1 1
#define SI2 2
#define SI3 3
#define SI4 4
#define TI 2
#define TI0 0
#define TI1 1
#define IOI 3
#define IOI0 0
#define IOI1 1
#define IOI2 2
#define IOI3 3
#define IOI4 4
#define IOI5 5
#define IOI6 6
#define IOI7 7
#define WRONG_CODE -1
#define OVER_RUN -2
#define WRONG_OPERATION_NUMBER -3
#define JOBCANNOTMALLOC -4
#define JOBATTRIBUTEERROR -5
#define GRAPHICS 1
#define TEXT 2
#define UNIT_TIME 500
#define UNIT_LINE_LEN 3
#define yellowS 251
#define blueS 252
#define redS 249
#define greenS 250
#define lineS 254
#define whiteS 255
#define printS 9
#define paperS 0
#define shutdownS 254
#define systempS 247
#define blackS 0
#define machineS 181
/*---------------------------------------------------------------------------*/
#define x_left (getmaxx()-640)/2
#define y_temp_top (getmaxy()-480)/2
int y_top=0;
/* 图形方式下显示计算器(CPU)的基坐标参数*/
#define cpu_left 340+x_left
#define cpu_top 150+y_top
#define cpu_width 50
#define cpu_height 50
/* 图形方式下显示就绪队列的基坐标参数*/
#define ready_left 325+x_left
#define ready_top 70+y_top
#define ready_width 181
#define ready_height 30
/* 图形方式下显示系统进程的基坐标参数*/
#define system_left 425+x_left
#define system_top 140+y_top
#define system_width 80
#define system_height 101
/* 图形方式下显示CPU、系统参数及中断参数的基坐标参数*/
#define cpui_left 125+x_left-10
#define cpui_top error_top
#define cpui_width 175
#define cpui_height 15
#define cpui_error_offset 27
/* 图形方式下显示提示和错误信息的基坐标参数*/
#define error_left cpui_left+cpui_width+cpui_error_offset
#define error_top 370+y_top
#define error_width 200
#define error_height 15
#define printer_mid_top 300+y_top
#define printer_top_off 18
#define printer_left_off 16
#define printer_left 10+x_left
#define printer_height 20
#define printer_width 128
#define print_left 15+x_left
#define print_top 70+y_top
#define print_width 118
#define print_height 230
#define out_left 190+x_left
#define out_top 70+y_top
#define out_width 101
#define out_height 30
#define in_left 260+x_left
#define in_top 290+y_top
#define in_width 201
#define in_height 30
#define sysbuf_left 190+x_left
#define sysbuf_top 140+y_top
#define sysbuf_width 30
#define sysbuf_height 100
#define userbuf_left 260+x_left
#define userbuf_top 140+y_top
#define userbuf_width 30
#define userbuf_height 121
#define keyboard_left 170+x_left
#define keyboard_top 290+y_top
#define keyboard_width 72
#define keyboard_height 40
#define memorypage_left 539 +x_left
#define memorypage_top 25+y_top
#define memorypage_width 100
#define memorypage_height 15
#define box_left 50+x_left
#define box_top 370+y_top
#define box_width 50
#define box_height 100
#define box_top_off 15
#define box_left_off 25
#define box_buttom_width 20
#define box_buttom_height 10
#define COLOR1 yellow_color
#define COLOR2 253
#define COLOR3 COLOR2
#define COLOR4 COLOR2
#define COLOR5 COLOR2
#define COLOR6 print_color
/****************************************************************************
功 能:模拟系统寄存器和中断状态寄存器
编写日期: 2003-9-25
*****************************************************************************/
struct p_m
{
int size; /* size of this page */
int base; /* base address of this page */
int status; /* status of this page, such as 0 if
this page is free and 1 otherwise */
}PAGE_OF_MEMORY[3];
typedef enum p_state
{
Ready,
Running,
Block,
Destory
}PState;
struct
{
char status;
int time;
int process[3];
int waits; /* 申请该通道的队列长度*/
}CHST[3];
typedef struct p_pcb
{
int p_id;
int p_pc;
char p_c;
long p_r;
char p_name[5];
char p_runtime[5];
char p_outputline[5];
char p_type; /* 'S'--system process 'U'--user process */
int p_base; /* the base address of the process */
int p_prog_start;
int p_prog_end;
int p_data_start;
int p_data_end;
int p_length; /* total length of the process */
int p_pri; /* the priority number of the process */
PState p_status; /* such as "ready","runnig","block" */
int p_int_status; /* set 1,2,3 if this process apply for an interruption
and set 0 otherwise */
struct p_pcb *p_prev; /* the point to the prev_process */
struct p_pcb *p_next; /* the point to the next_process */
int p_tick; /* total time process had run */
int p_page_of_memory; /* the number of page in memory when job had loaded in memory */
int p_color; /* job color when display in graphics mode */
int p_output_lines;
int p_running_time;
int p_output_information_line;
char p_other[5]; /* temporary buf ,store string such as result or instruction*/
int p_error; /* -1 if no error occur,else error line's number */
int p_job_table[10]; /* 存放该作业的占用用户存储区的页号 */
char p_print[10][5]; /* 存放要打印的信息 */
int p_index; /* 存放该进程对应于输入井的位置,下标 */
}PCB;
/* 作业控制块 */
typedef struct j_jcb
{
char j_id; /* 作业的ID号,可以有它占用作业表的下标作为ID号 */
char j_name[5];
char j_build_time[11]; /* 2003-10-10 */
char j_output[20][4]; /* 可以输出20个结果 */
char j_output_line[5]; /* 要输出的行数 */
char j_runtime[5]; /*运行时间 */
int j_p_start; /* 作业程序段在输入井中的首地址 */
int j_p_end ; /* 作业程序段在输入井中的末地址 */
int j_d_start; /* 作业数据段在输入井中的首地址 */
int j_d_end ; /* 作业数据段在输入井中的末地址 */
struct j_jcb *j_next; /*指向下一个作业的指针 */
int j_length; /* 对作业后备队列的头结点(长度) 而其它结点表示作业的长度。 */
int j_loaded_length; /* 当前作业已经装入用户内存区的长度 (即判断P2是否完成对该作业的操作)*/
int j_index; /* 它表示正在传送的硬盘块号,要间接引用 j_hd_table[index] 来得到 */
int j_job_table[10]; /* 存放该作业的占用用户存储区的页号 */
int j_hd_table[10]; /* 存放该作业占用的磁盘道号 */
char j_print[10][5]; /* 存放要打印的信息 */
int j_running_time;
int j_output_lines;
int j_color;
int j_error; /* 出错的类型 */
int j_error_row; /* 出错的行号 */
}JCB;
/* 系统JCB表 */
typedef struct jcb_t
{
int index;
char status; /* 如果是 "T" 表示被占用,如果是 "F" 表示空闲。 */
}JCB_TABLE;
struct
{
int left;
int top;
int right;
int bottom;
int wt;
int wb;
int tt;
int tb;
char *p;
}WIN[4];
typedef struct
{
int x;
int y;
}G_POINT;
/* 内存页表 */
char MEMORY_TABLE[30];
char HARDDISK_TRACK[100];
/* 作业预输入表 */
JCB_TABLE JCBTABLE[10];
JCB *J_INPUT_JOB_HEAD;
JCB *J_INPUT_JOB_TAIL;
JCB *J_DEALING_JOB_HEAD;
JCB *J_DEALING_JOB_TAIL;
JCB *J_OUTPUT_JOB_HEAD;
JCB *J_OUTPUT_JOB_TAIL;
JCB *J_TEMP_JOB; /* 指向当前正在预输入的作业 JCB */
PCB *SYSTEM_READY_QUEUE;
PCB *SYSTEM_BLOCK_QUEUE;
PCB *P_JOB_SCHEDUL;
PCB *P_INPUT_PROCESS;
PCB *P_OUTPUT_PROCESS;
PCB *P_PROCESS_SCHEDUL;
PCB *P_PROCESS_KILL;
PCB *P_PROCESS_SUPERWAIT;
PCB *JOB_QUEUE;
PCB *READY_QUEUE;
/*PCB *READY_QUEUE_TAIL; 指向用户作业就绪队列的尾部 */
PCB *RUNNING_QUEUE;
PCB *SI_BLOCK_QUEUE;
PCB *IO_BLOCK_QUEUE[3];
PCB *IO1_BLOCK_QUEUE;
PCB *IO2_BLOCK_QUEUE;
PCB *IO3_BLOCK_QUEUE;
int HDWPOINTER; /* 指向输入井的下标 */
int PRO_BASE; /* base address of the process */
int PRO_LENGTH; /* legnth of the process in the memory */
char *HDWpointer; /* a pointer point to cisual-harddisk current point (write) */
char *temp_HDWpointer;
char *HDRpointer; /* a pointer point to cisual-harddisk current point (read) */
char *temp_HDRpointer;
int HDlength; /* a number discription the length had write to visual-harddisk */
long R;
char C;
int PC;
char MODE;
int __PI;
int __SI;
int __IOI;
int __TI;
char PTR[4];
int RTIME;
int TIME;
int ID; /* this variable decide the id when malloc a node */
int INT_TYPE[4]; /* sign the type of interrupt, such as 'P' = PI;
'S' = SI; 'T' = TI; 'I' = IOI */
char HD[HARDDISKSIZE][4];
char MM[MEMORYSIZE][4];
char SYSTEM_INPUT_BUF[10][22];
char SYSTEM_OUTPUT_BUF[10][4];
int CURRENT_WINDOW;
int CURRENT_WINDOW_X1;
int CURRENT_WINDOW_X2;
int CURRENT_WINDOW_Y1;
int CURRENT_WINDOW_Y2;
char CURRENT_INSTRUCTION[5];
char *INF[]={"(PRINTER) OUTPUT INFORMATION ","CPU-MEMORY-INTERRUPT","QUEUES INFORMATION","OTHERS"};
char *ERROR_INF[]={"OUT OF ADDRESS","INVALID INSTRUCTION","OPERATION OVERFLOW","TOO MANY INSTRUCTIONS","DATA OVERFLOW","NEED MORE LINE FOR OUTPUT","NEED MOER TIME TO FINISH"};
int HAD_CHANGED_WINDOW;
int DISPLAY_MODE = GRAPHICS;
int COLOR_MODE = 256;
long DELAY_TIME = UNIT_TIME;
int TIMESLICE = 10;
int SYS_ERROR;
int OUT_INFORMATION_LINE;
char jobfilename[20]={"jobs.txt"};
FILE *INPUT_FILE;
long FILEOFFSET; /* 存放读取用户作业文件时的读写指针 */
int HARDDISK_TRACK_INDEX;
/* 当前填充模式 */
struct fillsettingstype fillinfo;
/* 当前线条模式 */
struct linesettingstype lineinfo;
int JCBPCB_CURRENT_COLOR; /* 分配颜色时要用 */
int LINE_FROM_SYSTEM_MEMORY_TO_INPUT_BUF_INDEX[2];
int LINE_FROM_INPUT_BUF_TO_USERBUF[2];
int KERNEL_TIME;
int USER_TIME;
int SUPERWAIT_TIME;
int KEYBOARD_TIMES;
int HARDDISK_TIMES;
int PRINTER_TIMES;
struct time LOGIN_TIME;
struct time LOGOUT_TIME;
int DISPLAY_PICTURE_OK=FALSE;
int yellow_color = yellowS;
int blue_color = blueS;
int red_color = redS;
int green_color = greenS;
int line_color= lineS;
int white_color = whiteS;
int print_color = printS;
int paper_color = paperS;
int shutdown_color = shutdownS;
int systemp_death_color = systempS;
int black_color = blackS;
int machine_color = machineS;
int DISPLAY_BY_STEP = FALSE;
int DISPLAY_FLASH = TRUE;
int DISPLAY_VERSION = FALSE;
int DISPLAY_MEMORY_STATUS = TRUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -