playgame() { setupgame(); /* Set level to 1, get level etc */ /* Loop while checkfinish() says we haven't finished! */ while ( checkfinish() ) { gamekeys(); /* Scan keys */ } }
//fcfs algorithm -- no text referred developed from self logic : Jay Dihenkar //date : 8th March 2014. void fcfs(pptr head,pptr tail) { pptr s_head=NULL; pptr s_tail=NULL; pptr auxnode; int global_time=0; start: while(head!=NULL && head->arr_time==global_time) { auxnode = fetch_from_queue(&head,&tail); add_to_queue(&s_head,&s_tail,auxnode); } if(s_head==NULL) { if(head==NULL) { //all process are served we exit fclose(write); filecopy(stdout,trace); fclose(trace); return; } //else it's empty slot but still processes to come printf("\nThe time slot at %d to %d is free slot!",global_time,global_time+1); // fprintf(trace,"\nThe time slot at %d to %d is free slot!",global_time,global_time+1); goto end_of_loop; } //else s_head not null and hence we serve the head process... s_head=serve(s_head,1); //serve for 1 time slot //check if the process has burst if(checkfinish(s_head)) { printf("\n\t\t\t\tFinish time for pid:%d is %d!",s_head->pid,global_time); // fprintf(trace,"\n\t\t\t\tFinish time for pid:%d is %d!",s_head->pid,global_time); fprintf(write,"\nFinish time for pid:%d is %d!",s_head->pid,global_time); fetch_from_queue(&s_head,&s_tail); } end_of_loop:global_time++; if(global_time>=100) { return; } goto start; }