void releaseR(struct PCB1 *); void setNewPCB(char *,int,int,int); struct PCB1 * runTheProcess();
void newPCB(){ }
thisP->next=NULL;
thisP->No=SequenceNumber; SequenceNumber++;
printf(\½ø³ÌºÅ %d\\n\printf(\ÊäÈë½ø³ÌÃû£º\scanf(\printf(\ÊäÈëÓÅÏȼ¶£º\scanf(\printf(\ÊäÈë½øÈëÄÚ´æʱ¼ä£º\
scanf(\printf(\ÊäÈë·þÎñʱ¼ä£º\
scanf(\thisP=newP; if(head==NULL){
head=newP;
//ÅжÏÍ·½ÚµãÊÇ·ñΪ¿Õ
//Ϊ¿Õ£¬Í·½ÚµãÖ¸Ïòпª±ÙµÄÄÚ´æ
//½¨Á¢PCB
newP=(struct PCB1 *)malloc(sizeof(struct PCB1));
}else{ }
thisP=head;
while(thisP->next!=NULL){ }
thisP->next=newP;
//±éÀúµ¥Á´±í£¬ÕÒµ½×îºóÒ»¸öÔªËØ
thisP=thisP->next;
void buildProcess(){ }
int i=0;
//´´½¨½ø³Ì
printf(\ÊäÈë½ø³ÌÊýÁ¿£º\scanf(\while(i newPCB(); i++; void readyList(struct PCB1 *pcb){ } struct PCB1 * callMemory(){ int at; //µ½´ïʱ¼ä if(readyHead==NULL){ readyHead=newP; //µ¥Á´±íµÄÐÎʽ´´½¨¾ÍÐ÷¶ÓÁÐ newP=(struct PCB1 *)malloc(sizeof(struct PCB1)); }else{ } thisP=newP; strcpy(thisP->name,pcb->name); thisP->No=pcb->No; thisP->priority=pcb->priority; thisP->enterMemoryTime=pcb->enterMemoryTime; thisP->serviceTime=pcb->serviceTime; thisP->next=NULL; thisP=readyHead; while(thisP->next!=NULL){ } thisP->next=newP; thisP=thisP->next; //µ÷ÈëÄڴ棬·µ»Øµ÷ÈëÄÚ´æµÄÁ´±í½Úµã struct PCB1 *markP; if(head==NULL){ printf(\³ÌÐòûÓÐÕÒµ½¡£\\n\ }else{ markP=thisP=head; //±ê¼ÇÖ¸ÏòÍ·½Úµã //µ½´ïʱ¼äΪͷ½Úµãµ½´ïʱ¼ä at=thisP->enterMemoryTime; while(thisP->next!=NULL){ //µ±ÏÂÒ»½Úµã²»Îª¿Õ //Åжϵ±Ç°Ê±¼äÊÇ·ñ´óÓÚÏÂÒ» if(at>thisP->next->enterMemoryTime){ ½Úµãʱ¼ä } void run(){ //¾²Ì¬ÓÅÏȼ¶Ëã·¨Ö´ÐС£ } return markP; } } thisP=thisP->next; //Ïòºó±éÀú markP=thisP->next; //ÊÇ£¬±ê¼Ç´Ë½Úµã at=markP->enterMemoryTime; //µ½´ïʱ¼ä¸ü¸ÄΪ±ê¼Çʱ¼ä struct PCB1 *temp; //ÁÙʱ½ÚµãÓÃÀ´´æ´¢µ÷ÈëÄÚ´æ½Úµã struct PCB1 *runPro; int i; //ÓÃÀ´½ÓÊÕÖ´ÐеĽڵã //Ñ»·³õʼÌõ¼þ //µ½´ïʱ¼ä£¬¿ªÊ¼Ö´ÐÐʱ¼ä£¬ÔËÐÐʱ¼ä¡£ //ÖÜתʱ¼ä int at,srt,runtime=0; int turnOverTime; double ptot; //´øȨÖÜתʱ¼ä if(head==NULL){ printf(\ûÓз¢ÏÖ½ø³Ì¡£\\n\ }else{ for(i=0;i while(head!=NULL){ temp=callMemory(); if(i==0){//³õʼÇé¿öÏÂÇò¿ªÊ¼Ö´ÐÐʱ¼ä£¬Íê³Éʱ¼ä£¬ÖÜתʱ¼ä£¬´øȨÖÜת //Ñ»·½ø³ÌµÄÊýÁ¿´Î ʱ¼ä srt=at=temp->enterMemoryTime; runtime=at+temp->serviceTime; } } turnOverTime=runtime-at; ptot=turnOverTime*1.0/temp->serviceTime; readyList(temp); //³õʼÄÉÈë¾ÍÐ÷ÁбíÒÔ¼°ºóÐø release(temp); //ÊͷŽø³Ì while(head!=NULL&&(temp=callMemory())->enterMemoryTime<=runtime){ } } } runPro=runTheProcess(); if(i>0){ } printf(\µ±Ç°Ö´ÐеĽø³Ì£º\\n\printField(); printPCB(runPro,srt,runtime,turnOverTime,ptot); releaseR(runPro); printf(\¾ÍÐ÷½ø³ÌÁÐ±í£º\\n\ListAllPCB(readyHead); printf(\ //³õʼ֮ºó£¬¼ÆËã¸÷ʱ¼ä¼°ÖÜת } readyList(temp); //Ñ»·ÅжÏÊÇ·ñÄÉÈë¾ÍÐ÷Áбí release(temp); srt=runtime; runtime+=runPro->serviceTime; turnOverTime=runtime-runPro->enterMemoryTime; ptot=turnOverTime*1.0/runPro->serviceTime; struct PCB1 * runTheProcess(){ //Ö´ÐеĽø³Ì£¬·µ»ØÒªÖ´Ðнø³ÌµÄ½Úµã int time,pri; struct PCB1 *markThis; //±ê¼ÇÒª·µ»ØµÄ½Úµã if(readyHead==NULL){ printf(\ûÓпÉÔËÐеĽø³Ì¡£\\n\