进程管理模拟系统源代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
printf("NO process in queue \n"); return 0; } else { enqueue(wait , p); printf("add a process into wait queue process: PID = %d UID= %d \n" ,p->PID , p->UID); return 1; } }/*block*/ /*输出队列 outputqueue*/ int outputqueue(PCB *head) { PCB *p; if(head -> next == NULL) {/*队列为空*/ printf("queue is null \n"); return 1; } p = head -> next; while(p) {/*打印process id UID*/ printf("PID = %d UID = %d \n" , p -> PID , p -> UID); p = p -> next; } return 0; } /*output输出*/ int output() { printf("REALLLY QUEUE:\n"); outputqueue(really); printf("EXCUTE QUEUE: \n"); outputqueue(excute); printf("WAIT QUEUE: \n");
0x48,0xFE,0x68,0x12,0x28,0x16,0x08, 0x1A,0x08,0x32,0x08,0xD2,0x08,0x12, 0x48,0x12,0x88,0x13,0x14,0x12,0x22, 0x50,0x42,0x20,0x80, }; char han11S[]={ 0x02,0x20,0x42,0x20,0x22,0x28,0x2F, 0xFC,0x02,0x20,0x02,0x20,0xE2,0x20, 0x22,0x28,0x2F,0xFC,0x22,0x20,0x22, 0x20,0x22,0x20,0x24,0x20,0x50,0x26, 0x8F,0xFC,0x00,0x00, }; char han12S[]={ 0x08,0x04,0x1D,0xFE,0xF1,0x04,0x11, 0x04,0x11,0x04,0xFF,0x04,0x11,0xFC, 0x38,0x00,0x37,0xFE,0x54,0x20,0x50, 0x28,0x91,0xFC,0x10,0x20,0x10,0x24, 0x17,0xFE,0x10,0x00, }; char han13S[]={ 0x10,0x40,0x1F,0x7C,0x28,0x90,0x45, 0x08,0x01,0x00,0x7F,0xFE,0x40,0x02, 0x9F,0xF4,0x10,0x10,0x1F,0xF0,0x10, 0x00,0x1F,0xF0,0x10,0x10,0x10,0x10, 0x1F,0xF0,0x10,0x00, }; char han14S[]={ 0x00,0x08,0x13,0xFC,0xFA,0x48,0x22, 0x48,0x23,0xF8,0x22,0x48,0xFA,0x48, 0x23,0xF8,0x20,0x40,0x20,0x50,0x23, 0xF8,0x3C,0x40,0xE0,0x40,0x40,0x44, 0x0F,0xFE,0x00,0x00, }; void drawmat(char *mat,int matsize,int x,int y,int color) {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)) putpixel(x+i*8+k,y+j,color); } /*定义结构体*/ typedef struct PCB { int PID; int UID; struct PCB * next; }PCB; PCB *really , *excute , *wait; /*create queue header */ /*queue operation 入队*/ int enqueue(PCB *head , PCB *node) { PCB *p; p = head; if(p -> next == NULL) { head -> next = node; return 1; } while(p) { if(p -> next == NULL) { p -> next = node; return 1; } else p = p -> next; } }/*enquue*/
0x10,0x10,0x11,0xF8,0x11,0x10,0x11, 0xF0,0xFC,0x04,0x17,0xBE,0x14,0xA4, 0x1F,0xBC,0x30,0x40,0xD0,0x44,0x1F, 0xFE,0x10,0xE0,0x11,0x50,0x12,0x4E, 0x54,0x44,0x20,0x40, }; char han6S[]={ 0x09,0x00,0x09,0x00,0x09,0x04,0x11, 0xFE,0x12,0x80,0x32,0x80,0x54,0x90, 0x98,0xF8,0x10,0x80,0x10,0x80,0x10, 0x88,0x10,0xFC,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80, }; char han7S[]={ 0x00,0x38,0x7F,0xC0,0x04,0x00,0x04, 0x10,0x08,0x20,0x3F,0xC0,0x01,0x00, 0x02,0x20,0x04,0x10,0x3F,0xF8,0x01, 0x08,0x09,0x20,0x09,0x10,0x11,0x08, 0x25,0x08,0x02,0x00, }; char han8S[]={ 0x10,0x80,0x10,0x40,0x20,0x48,0x27, 0xFC,0x48,0x80,0xF9,0x10,0x12,0x08, 0x27,0xFC,0x41,0x24,0xF9,0x20,0x41, 0x20,0x01,0x20,0x1A,0x22,0xE2,0x22, 0x44,0x1E,0x08,0x00, }; char han9S[]={ 0x11,0x10,0x11,0x14,0x1F,0xFE,0x11, 0x10,0xFD,0x18,0x13,0xFC,0x32,0x08, 0x3B,0xF8,0x56,0x08,0x53,0xF8,0x90, 0x40,0x1F,0xFE,0x10,0x40,0x10,0xB0, 0x11,0x0E,0x16,0x04, }; char han10S[]={ 0x10,0x00,0x10,0x08,0x10,0x88,0x12,
PCB *p = dequeue(really); if(p == NULL) { printf("NO process in queue \n"); return 0; } else { enqueue(excute , p); printf("add a process into excute queue process: PID = %d UID= %d \n" ,p->PID , p->UID); return 1; } }/*excute*/ int wake() { PCB *p = dequeue(wait); if(p == NULL) { printf("NO process in queue \n"); return 0; } else { enqueue(really , p); printf("add a process into wait really process: PID = %d UID= %d \n" ,p->PID , p->UID); return 1; } } int block() { PCB *p = dequeue(excute); if(p == NULL) {
来自百度文库
outputqueue(wait); }/*output*/ /*init 初始化*/ int init() { int i; PCB *p; clrscr(); really = (PCB*)malloc(sizeof(PCB)); really -> next=NULL; excute = (PCB*)malloc(sizeof(PCB)); excute -> next=NULL; wait = (PCB*)malloc(sizeof(PCB)); wait -> next = NULL; printf("_____________________________PROCESS SECHUDLE__________________________________\n"); printf("now is initing"); for(i=0;i<18;i++) { printf(". "); delay(10000000000); } printf("\ninput PID and UID as integer , 0 0 as over\n"); while(1) { p = (PCB*)malloc(sizeof(PCB)); p -> next = NULL; scanf("%d %d",&p -> PID , &p -> UID); if(p -> PID == 0 && p -> UID == 0) break; else { if(enqueue(really , p)) {
#include "stdio.h" #include"graphics.h" #include "dos.h" #include "stdlib.h" #include "conio.h" #define SEC 3 #define NULL 0 char han1S[]={ 0x00,0x80,0x00,0x80,0xFC,0x80,0x04, 0xFC,0x45,0x04,0x46,0x48,0x28,0x40, 0x28,0x40,0x10,0x40,0x28,0x40,0x24, 0xA0,0x44,0xA0,0x81,0x10,0x01,0x08, 0x02,0x0E,0x0C,0x04, }; char han2S[]={ 0x00,0x00,0x41,0x84,0x26,0x7E,0x14, 0x44,0x04,0x44,0x04,0x44,0xF4,0x44, 0x14,0xC4,0x15,0x44,0x16,0x54,0x14, 0x48,0x10,0x40,0x10,0x40,0x28,0x46, 0x47,0xFC,0x00,0x00, }; char han3S[]={ 0x02,0x20,0x42,0x20,0x22,0x28,0x2F, 0xFC,0x02,0x20,0x02,0x20,0xE2,0x20, 0x22,0x28,0x2F,0xFC,0x22,0x20,0x22, 0x20,0x22,0x20,0x24,0x20,0x50,0x26, 0x8F,0xFC,0x00,0x00, }; char han4S[]={ 0x04,0x00,0x02,0x00,0x01,0x00,0x01, 0x00,0x01,0x00,0x02,0x80,0x02,0x80, 0x02,0x80,0x04,0x40,0x04,0x40,0x08, 0x20,0x08,0x20,0x10,0x10,0x20,0x10, 0x40,0x0E,0x80,0x04, }; char han5S[]={
/*dequeue 出队列 */ PCB * dequeue(PCB *head) { PCB *p; p = head; if(p -> next == NULL) { return NULL; } else { p = p -> next; head -> next = p -> next; p -> next = NULL; return p; } /*head to next*/ }/*dequeue*/ /*PCB operate*/ /*新建进程*/ int create() { PCB *p; p = (PCB*)malloc(sizeof(PCB)); p -> next = NULL; printf("input PID and UID to a new process\n"); scanf("%d %d",&p -> PID,&p -> UID); if(enqueue(really , p)) printf("create a process: PID = %d UID = %d\n", p -> PID , p -> UID); else printf("create Failed\n"); }/*create*/ /*执行 fexcute*/ int fexcute() {