Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "RR.h"
- static queue_object* RR_queue;
- int g_quantum; //g steht fuer global
- int l_quantum; //local (wird geandert)
- //You can add more global variables
- process* RR_tick (process* running_process){
- if (running_process==NULL || running_process->time_left==0){ // der laufende prozess zuende
- if (RR_queue!=NULL){
- running_process=queue_poll(RR_queue);
- l_quantum = g_quantum;
- }
- }
- if (l_quantum == 0){
- queue_add(running_process, RR_queue);
- running_process = queue_poll(RR_queue);
- l_quantum = g_quantum;
- }
- if (running_process!=NULL){
- running_process->time_left--;
- l_quantum--;
- }
- return running_process;
- }
- int RR_startup(int quantum){
- g_quantum = quantum;
- l_quantum = quantum;
- RR_queue=new_queue();
- if (RR_queue==NULL){
- return 1;
- }
- return 0;
- }
- process* RR_new_arrival(process* arriving_process, process* running_process){
- if(arriving_process!=NULL){
- queue_add(arriving_process, RR_queue);
- }
- return running_process;
- }
- void RR_finish(){
- free_queue(RR_queue);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement