#include <stdlib.h>
#include<stdio.h>
#include<graphics.h>
#include <bios.h>
#include"OS.h"
#define ENTER 0x1c0d
#define left 0x4b00
#define right 0x4d00
#define up 0x4800
#define down 0x5000
#define pageup 0x4900
#define pagedown 0x5100
#define MAX_MENU 7/*根据情况改变可以在菜单显示的最大项*/
#define MAX 10
typedef struct pcb
{
int pid; /*进程PID*/
int static_prior; /*进程静优先级*/
int dynamic_prior; /*进程动态*/
int need_time; /*需要运行的时间*/
int run_time; /*已运行时间*/
int state; /*进程状态*/
int memory_need; /*所需主存大小*/
int memory_start;
int source; /*用到的资源数*/
int max;
int allocation;
int need;
int request1;
int time1;
int request2;
int time2;
struct pcb* next;
}PCB;
typedef struct mem
{
int id; /*分区号*/
int size; /*大小*/
int start; /*起始地址*/
int state;/*状态*/
struct mem* next;
}MEM;
void *p;
size_t area;
struct MENU
{
/*左上角*/
int x;
int y;
/*右下角*/
int x1;
int y1;
int state;
int sel;
unsigned char Active[MAX_MENU];/* 菜单项是否激活的标志*/
};
struct MENU A={5,15,55,35,0,-1};
struct MENU B={55,15,105,35,0,-1};
struct MENU C={105,15,155,35,0,-1};
struct MENU D={155,15,205,35,0,-1};
struct MENU E={205,15,255,35,0,-1};
struct MENU F={255,15,320,35,0,-1};
struct MENU G={320,15,370,35,0,-1};
struct MENU H={370,15,420,35,0,-1};
struct MENU I={420,15,470,35,0,-1};
struct MENU J={470,15,520,35,0,-1};
PCB *pcbQueen;
int key;
int flag,flag2,flag3,Avaliable;
int num_Proc=0,speed,page=0;
MEM *memQueen;
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0;
registerbgidriver(EGAVGA_driver);
initgraph(&gd, &gm, "");
}
void drawmat(char *mat,int matsize,int x,int y,int color)
/*依次:字模指针、点阵大小、起始坐标(x,y)、颜色*/
{
int i, j, k, n;
n = (matsize - 1) / 8 + 1;
for(j = 0; j < matsize; j++)
for(i = 0; i < n; i++)
for(k = 0;k < 8; k++)
if(mat[j * n + i] & (0x80 >> k)) /*测试为1的位则显示*/
putpixel(x + i * 8 + k, y + j, color);
}
void DrawBtn(struct MENU *tm,char *txt,int n)
{
int i;
for(i=0;i<n;i++)
drawmat(txt+i*24,12,tm->x+15+15*i,tm->y+4,BLACK);
}
void Winp(struct MENU *t,int state)
{
/*非高亮模式*/
if(state==1)
{
/*两条暗边框线*/
setcolor(0);
line(t->x,t->y,t->x,t->y1);
line(t->x,t->y,t->x1,t->y);
/*两条亮边框线*/
setcolor(15);
line(t->x1,t->y,t->x1,t->y1);
line(t->x,t->y1,t->x1,t->y1);
}
/*高亮模式*/
else
{
/*两条亮边框线*/
setcolor(15);
line(t->x,t->y,t->x,t->y1);
line(t->x,t->y,t->x1,t->y);
/*两条暗边框线*/
setcolor(0);
line(t->x1,t->y,t->x1,t->y1);
line(t->x,t->y1,t->x1,t->y1);
}
}
void menu(void)
{
int a[3],i;
setcolor(15); /*画菜单*/
line(2,428,636,428);
line(3,429,635,429);
line(2,428,2,481);
line(3,429,3,482);
/* drawmat(cao12S,12,4,435,15);
drawmat(zuo12S,12,16,435,15); */
drawmat(shuo12S,12,250,435,15);
drawmat(ming12S,12,262,435,15);
drawmat(b12S,12,272,435,15);
for(i=0;i<5;i++)
drawmat(avali+24*i,12,40+15*i,435,15);
drawmat(num[Avaliable/10],12,120,435,15);
drawmat(num[Avaliable%10],12,130,435,15);
setfillstyle(1, 2); /*四种状态*/
bar(312,448,322,462);
drawmat(yun12S,12,332,450,15);
drawmat(hang12S,12,344,450,15);
setfillstyle(1, 4);
bar(382,448,392,462);
for(i=0;i<2;i++)
drawmat(wait+24*i,12,402+12*i,450,15);
setfillstyle(1, 14);
bar(452,448,462,462);
drawmat(jiu12S,12,472,450,15);
drawmat(xu12S,12,484,450,15);
setfillstyle(1, 0);
bar(522,448,532,462);
drawmat(houbei,12,542,450,15);
drawmat(houbei+24,12,554,450,15);
setfillstyle(1,3);
bar(592,448,602,462);
drawmat(gua12S,12,612,450,15);
drawmat(qi12S,12,624,450,15);
setfillstyle(1,7);
bar(2,2,638,52);
setcolor(0);
line(2,51,638,51);
line (3,52,637,52);
setcolor(1);
setfillstyle(1,1);
bar(2,2,640,14);
for(i=0;i<6;i++)
drawmat(operation+24*i,12,2+12*i,3,15);
DrawBtn(&A,xinjian,2);
DrawBtn(&B,chakan,2);
DrawBtn(&C,shanchu,2);
DrawBtn(&D,guaqi,2);
DrawBtn(&E,jiegua,2);
DrawBtn(&F,fenqubiao,3);
if(flag)
DrawBtn(&G,zanting,2);
else
DrawBtn(&G,jixu,2);
DrawBtn(&H,guanyu,2);
DrawBtn(&I,bangzhu,2);
DrawBtn(&J,tuichu,2);
switch(key)
{
case 1: Winp(&A,0);;break;
case 2:Winp(&B,0);break;
case 3:Winp(&C,0);break;
case 4:Winp(&D,0);break;
case 5:Winp(&E,0);break;
case 6:Winp(&F,0);break;
case 7:Winp(&G,0);break;
case 8:Winp(&H,0);break;
case 9:Winp(&I,0);break;
case 10:Winp(&J,0);break;
}
/* DrawBtn(&New,xinjian);
DrawBtn(&View,chakan);
DrawBtn(&Set,shezhi);
DrawBtn(&Proc,jincheng);
DrawBtn(&Help,bangzhu);
switch(key)
{
case 1:
if(New.state==1)
{a[0]=4;
a[1]=4;
PullMenuDown(nm,2,&New,a);
if(New.sel!=-1)
Xorbar(New.x+3,New.y1+6+New.sel*20,New.x+97,New.y1+22+New.sel*20,14);
}
else
Winp(&New,0);
break;
case 2:
if(View.state==1)
{a[0]=4;
a[1]=3;
PullMenuDown(vm,2,&View,a);
if(View.sel!=-1)
Xorbar(View.x+3,View.y1+6+View.sel*20,View.x+97,View.y1+22+View.sel*20,14);
}
else
Winp(&View,0);
break;
case 3:
if(Set.state==1)
{a[0]=2;
a[1]=3;
a[2]=2;
PullMenuDown(sm,3,&Set,a);
if(Set.sel!=-1)
Xorbar(Set.x+3,Set.y1+6+Set.sel*20,Set.x+97,Set.y1+22+Set.sel*20,14);
}
else
Winp(&Set,0);
break;
case 4:
if(Proc.state==1)
{a[0]=2;
a[1]=2;
a[2]=2;
PullMenuDown(pm,3,&Proc,a);
if(Proc.sel!=-1)
Xorbar(Proc.x+3,Proc.y1+6+Proc.sel*20,Proc.x+97,Proc.y1+22+Proc.sel*20,14);
}
else
Winp(&Proc,0);
break;
case 5:
if(Help.state==1)
{a[0]=2;
PullMenuDown(hm,1,&Help,a);
if(Help.sel!=-1)
Xorbar(Help.x+3,Help.y1+6+Help.sel*20,Help.x+97,Help.y1+22+Help.sel*20,14);
}
else
Winp(&Help,0);
break;
} */
}
void board()
{ int i;
setcolor(15);
line(0,0,640,0);
line(0,1,639,1);
line(0,0,0,640);
line(1,0,1,639);
setfillstyle(1, 8);
bar(2,2,638,638);
drawmat(chu24S,24,220,60,12);
drawmat(li24S,24,240,60,12); /*处理机调度模拟程序*/
drawmat(ji24S,24,260,60,12);
drawmat(tiao24S,24,280,60,12);
drawmat(du24S,24,300,60,12);
drawmat(mo24S,24,320,60,12);
drawmat(ni24S,24,340,60,12);
drawmat(cheng24S,24,360,60,12);
drawmat(xu24S,24,380,60,12);
outtextxy(15,103,"PID");
drawmat(you12S,12,72,100,15); /*优先权*/
drawmat(xian12S,12,86,100,15);
drawmat(quan12S,12,100,100,15);
drawmat(nei12S,12,150,100,15); /