Mon Oct 24, 2011 3:24 pm
void func_prior(struct process *queue){
int* gantt=(int*)malloc(sizeof(int)*total);
int next=0;
int a, b=0, priority, i;
// while (i < total){
for(i=0; i<total; ){
for (a=0; a<job; a++){
priority = 10;
while(b < job){
// for (b=0, priority=11; b<job; b++){
if ( queue[b].arrive <= i && queue[b].priority < priority ) {
priority=queue[b].priority;
queue[b].priority = queue[a].priority; //
queue[a].priority = priority; //
}b++;
}
if ( queue[a].priority <= priority && queue[a].arrive <= i ){
for (b=0; queue[a].running>0; b++){
queue[a].running--;
i++;
queue[a].turnaround = i-queue[a].arrive;
queue[a].waiting = queue[a].turnaround - queue[a].run;
}
if (queue[a].priority < job+1) queue[a].priority++;
}
}
}
func_print(queue);
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.