Total members 11894 |It is currently Sat Nov 23, 2024 8:56 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





It's the CPU scheduling priority algorithm function.
But, Average turnaround time and Average waiting time are wrong.
Why is that?
Plz...Help me.

Code:
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);
}





Author:
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : CPU priority algorithm...
 priority queue     -  
 task's priority and how is it used in scheduling?     -  
 cpu priority scheduling in java---codes please..     -  
 source code for SJF and priority for both preemptive C#     -  
 Implementation of FCFS, SJFS, Round Robin and priority algo     -  
 id3 algorithm     -  
 Dijkstra Algorithm     -  
 Rijndael Algorithm     -  
 Data set for ID3 algorithm     -  
 genetic algorithm example     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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