您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 进程调度 操作系统 进程控制模拟
  所属分类: 网络攻防
  开发工具:
  文件大小: 6kb
  下载次数: 0
  上传时间: 2009-05-19
  提 供 者: hanshan********
 详细说明: 用于进程控制模拟 #include #include #include #include #include #include #include #include "ggg.h" #include "os.h" #include "menu.h" void draw_bar() { int y,color,yy; setbkcolor(HiColor(BK_COLOR)); rect(0,0,SCREEN_W-1,SCREEN_H-1,HiColor(0xC0C0C0)); for (color = 652, y = 92,yy=1; y <121; ++y, color += 2048,++yy) { hline(1,yy,480,color); } /* rectfill(1, 1, 480, 30,HiColor(0xFFFFFF)); */ line(481,1,481,430,HiColor(0xFFFFFF)); hline(1,434,SCREEN_W-2,HiColor(0xFFFFFF)); } char *input(char *text) { char *in; int i=0; in=calloc(12,sizeof(char)); showMessage(text); in[i]=getch(); while(in[i]!=13) { rectfill(5, 455, 5+(8*10), 455, HiColor(BK_COLOR)); string_out(in,5,450); vsync(); i++; if(i>10){ return 0; } in[i]=getch(); } in[i]=0; return in; } #define PCB_W 60 #define PCB_H 20 #define PCB_LEFT 30 #define LINE_H 10 void draw_PCB(int start_x,int start_y,int end_x,int end_y,int color,PCB *p,int text_color) { set_str_color(HiColor(text_color)); rectfill(start_x+PCB_LEFT,start_y+LINE_H,end_x-PCB_LEFT,end_y,color); line(start_x+PCB_LEFT+(PCB_W/2),start_y,start_x+PCB_LEFT+(PCB_W/2),start_y+LINE_H,0); if(p->hasname==1) textout(p->name,start_x+PCB_LEFT,start_y+LINE_H+5); set_str_color(1); } void draw_PCB_point(PCB_point *p) { int i=0; int start_x,start_y; char c; PCB *temp; rectfill(p->start_x,p->start_y,p->end_x,p->end_y,HiColor(BK_COLOR)); temp=p->next; set_str_color(HiColor(0x00ff00)); string_out(p->name,p->start_x+10,6); for(i=0;inum;i++) { start_x=p->start_x; start_y=p->this_y; draw_PCB(start_x,start_y,p->end_x,start_y+PCB_H+LINE_H,p->color,temp,p->text_color); p->this_y=start_y+PCB_H+LINE_H; temp=temp->link; } set_str_color(1); itoa(p->num,c,10); string_out(c,p->this_x,p->this_y); } char *show_input() { char *n,*p; n=input("请输入进程名:"); p=calloc(100,sizeof(char)); strcpy(p,"输入数据成功,你输入的数据为: "); strcat(p,n); showMessage(p); return n; } void reset_this(PCB_point *p) { p->this_x=p->start_x; p->this_y=p->start_y; } void create_proess() { char *text; scare_mouse(); showMessage("\nplease input text:"); /*text=(char *)malloc(100);*/ text=show_input(); create(text); unscare_mouse(); } void keymode() { char choice; char *msg; /*printf("start:\n"); */ PCB_point_init(); while(1) { reset_this(freelist); reset_this(runlist); reset_this(runablelist); reset_this(blocklist); draw_PCB_point(freelist) ; draw_PCB_point(runlist) ; draw_PCB_point(runablelist) ; draw_PCB_point(blocklist) ; showMessage("请输入操作指令:"); choice=getch(); switch(choice) { case 'c': create_proess(); break; /*case 's': list(); break;*/ case 'p': dispatch(); break; case 't': timeout(); break; case 'b': block(); break; case 'w': wakeup(); break; case 'e': quit_PCB(); break; case 'x': exit(0); } } } void quit() { exit(0); } #define BUTTON_W 80 #define BUTTON_H 30 void init_menu() { button *b; btinsert(createbutton(521,30,521+BUTTON_W,30+BUTTON_H,"创建进程",create_proess)); btinsert(createbutton(521,90,521+BUTTON_W,90+BUTTON_H,"调度进程",dispatch)); btinsert(createbutton(521,150,521+BUTTON_W,150+BUTTON_H,"阻塞进程",block)); btinsert(createbutton(521,210,521+BUTTON_W,210+BUTTON_H,"唤醒进程",wakeup)); btinsert(createbutton(521,270,521+BUTTON_W,270+BUTTON_H,"时间片到",timeout)); btinsert(createbutton(521,330,521+BUTTON_W,330+BUTTON_H,"结束进程",quit_PCB)); btinsert(createbutton(521,390,521+BUTTON_W,390+BUTTON_H,"退出程序",quit)); b=btlist->next; while(b!=NULL) { button_fill(b); b=b->link; } } void update(PCB_point *t) { if(t->changed) { reset_this(t); draw_PCB_point(t) ; t->changed=0; } } void main() { char *n,*p; PCB_point *li; neo_init(); set_vbe_mode(VBE640X480X64K); install_timer(new_1ch_int); /*change_timer(50); */ /*set_cn_size(0); */ install_mouse(); /*设置鼠标移动范围*/ set_mouse_range(0, 0, SCREEN_W, SCREEN_H); draw_bar(); PCB_point_init(); /* keymode(); draw_PCB(0,31,120,31+PCB_H+LINE_H,HiColor(0xFF0000)); li=(PCB_point *)malloc(sizeof(PCB_point)); set_PCB_point(li,NULL,10,10,0,31,120,431,HiColor(0xFF0000)); draw_PCB_point(li) ; */ init_menu(); while(1){ update(freelist); update(runlist); update(runablelist); update(blocklist); mouse_refresh(); chk_mouse(); LOOP_END_OF_TIMER(); } showMessage("按任意键退出!"); getch(); quit(); } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 进程控制
 输入关键字,在本站1000多万海量源码库中尽情搜索: