Home arrow Forums
OSDEV Forums  


Zoey
User

Fresh Osdever
Posts: 1
graphgraph
Karma: 0  
round robin scheduling - 2004/10/16 03:51 Hi could any one please give the C program simulation of round robin scheduling ..which accepets process id,arrival time and burst time as inputs and gives turnaround time and waiting time as output...

like creating three threads..with read,which in order runs the two scheduling threads(they perform Sjf scheduling form ready queue with mutex)

yaehh...its complicated...could anyone..povide me with some idea ,code..with which...i can....shoot off...

thanks...
Joey


  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
root
Moderator

Moderator
Posts: 121
graphgraph
Karma: 1  
Re: round robin scheduling - 2004/10/16 09:19 One of the oldest, simplest, fairest, and most widely used scheduling algorithms is round robin. Each process is assigned a time interval, called its quantum, which it is allowed to run. If the process is still running at the end of the quantum, the CPU is preempted and given to another process. If the process has blocked of finished before the quantum has elapsed, the CPU switching is done when process blocks, of course.

As about its implementation, akk the scheduler needs to do is maintain a list of runnable processes. When the quantum runs out on a process, it is put on the end of the list.

The only interesting issue with round robin is the length of the quantum. Switching from one process to another requires a certain amount of time for doing the saving and loading registers and memory maps, updating mic tables etc.

I don't have the time now, but round robin is easy to implement. You could paste here your exisiting code, and we'll work it out.

Good luck!
  | | The administrator has disabled public write access.
bben86
User

Fresh Osdever
Posts: 1
graphgraph
Karma: 0  
Re: round robin scheduling - 2005/05/12 20:37 you say implementation is easy, but I'm still confused on the subject. Is there some interrupt that we can write an interrupt service routine for to switch between processes...or what?
how is it that the processor is preempted and taken away from the current process. i think i get how i would give it to another process if i could figure out how to get it away from the first.
  | | The administrator has disabled public write access.
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re: round robin scheduling - 2005/05/13 08:45 Hello,
there's indeed an IRQ that is generated every X ms seconds by the PIT (programmable inval timer: http://www.nondot.org/sabre/os/files/MiscHW/PIT.txt" target="_blank">tutorial, official documentation). So all you have to do is to set up the PIT and write a handler for IRQ 0 that will initiate the task-switch.

A task is defined by the processors state (registers) and its context. In order to switch task you therefore have to save the regs of the current task in some structure, load the values of the task to be run into the CPU regs and then jump to it. Although this can be done (almost..) completly in software, the x86 CPUs also support a mechanism for hardware-taskswitching. It's however seldomly used because all register are allways saved (not really neccessary) which takes a lot of time..

If you need some example code you can have a look at Chris Giese pmode tutorials or the tutorial at bonafide os development.

regards,
gaf
  | | The administrator has disabled public write access.

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar