From ff2016b80263690c215594c91db6715c9fc8f21e Mon Sep 17 00:00:00 2001 From: Yahya-Ashraf-Mohamed Date: Tue, 3 Jan 2023 18:49:23 +0200 Subject: [PATCH] Resolving Round Robin Errors & Cleaning Repo --- Events_Log.txt | 20 +- Header_File/Event_Struct.h | 1 + How to run.txt | 3 - Makefile | 10 +- Min_Heap.c | 123 -------- PG.out | Bin 23040 -> 0 bytes README | 17 -- README.md | 24 ++ RR.out | Bin 23752 -> 0 bytes Round_Robin.c | 22 +- SJF.c | 574 ------------------------------------- SRTN.c | 416 --------------------------- Stats.txt | 6 +- clk.out | Bin 17392 -> 0 bytes process.c | 44 +-- process.out | Bin 17320 -> 0 bytes process_generator.c | 4 +- process_generator.out | Bin 23016 -> 0 bytes 18 files changed, 65 insertions(+), 1199 deletions(-) delete mode 100644 How to run.txt delete mode 100644 Min_Heap.c delete mode 100644 PG.out delete mode 100644 README create mode 100644 README.md delete mode 100644 RR.out delete mode 100644 SJF.c delete mode 100644 SRTN.c delete mode 100644 clk.out delete mode 100644 process.out delete mode 100644 process_generator.out diff --git a/Events_Log.txt b/Events_Log.txt index 95e7835..b2f40c4 100644 --- a/Events_Log.txt +++ b/Events_Log.txt @@ -1,12 +1,8 @@ -At time 2 process 4 started arr 17 total 20 remain 20 wait -15 -At time 12 process 4 stopped arr 17 total 20 remain 10 wait -15 -At time 12 process 1 started arr 2 total 10 remain 10 wait 10 -At time 21 process 1 finished arr 2 total 10 remain 0 wait 10 TA 19 WTA 1.90 -At time 21 process 2 started arr 5 total 4 remain 4 wait 16 -At time 25 process 2 finished arr 5 total 4 remain 0 wait 16 TA 20 WTA 5.00 -At time 25 process 3 started arr 7 total 3 remain 3 wait 18 -At time 28 process 3 finished arr 7 total 3 remain 0 wait 18 TA 21 WTA 7.00 -At time 28 process 4 resumed arr 17 total 20 remain 10 wait 1 -At time 38 process 4 finished arr 17 total 20 remain 0 wait 1 TA 21 WTA 1.05 -At time 38 process 4 started arr 17 total 20 remain 20 wait 21 -At time 57 process 4 finished arr 17 total 20 remain 0 wait 21 TA 40 WTA 2.00 +At time 2 process 1 started arr 2 total 10 remain 10 wait 0 +At time 12 process 1 finished arr 2 total 10 remain 0 wait 0 TA 10 WTA 1.00 +At time 12 process 2 started arr 5 total 4 remain 4 wait 7 +At time 16 process 2 finished arr 5 total 4 remain 0 wait 7 TA 11 WTA 2.75 +At time 16 process 3 started arr 7 total 3 remain 3 wait 9 +At time 19 process 3 finished arr 7 total 3 remain 0 wait 9 TA 12 WTA 4.00 +At time 19 process 4 started arr 17 total 20 remain 20 wait 2 +At time 39 process 4 finished arr 17 total 20 remain 0 wait 2 TA 22 WTA 1.10 diff --git a/Header_File/Event_Struct.h b/Header_File/Event_Struct.h index f65d377..1b0309a 100644 --- a/Header_File/Event_Struct.h +++ b/Header_File/Event_Struct.h @@ -50,6 +50,7 @@ void PrintEvent_Console(const Event *pEvent) printf("\n"); } +//print event using the same output file format void PrintEvent_File(const Event *pEvent, FILE *pFile) { fprintf(pFile, "At time %d ", pEvent->Time_Step); diff --git a/How to run.txt b/How to run.txt deleted file mode 100644 index 7fc5341..0000000 --- a/How to run.txt +++ /dev/null @@ -1,3 +0,0 @@ -1) compile clk.c -2) compile each algorithm -3) compile process_generator.c diff --git a/Makefile b/Makefile index 649993d..2a08ab7 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,18 @@ build: gcc process_generator.c -o process_generator.out gcc clk.c -o clk.out gcc Round_Robin.c -o RR.out - gcc PHPF.c -o PHPF.out - gcc SRTN.c -o SRTN.out - gcc SJF.c -o SJF.out + gcc process.c -o process.out gcc test_generator.c -o test_generator.out clean: - rm -f *.out processes.txt + rm -f *.out all: clean build run: ./process_generator.out + + +complete: + diff --git a/Min_Heap.c b/Min_Heap.c deleted file mode 100644 index aed3a4c..0000000 --- a/Min_Heap.c +++ /dev/null @@ -1,123 +0,0 @@ -#include "Header_File/Min_Heap.h" - -#include - -#ifndef SC_HEAP_MAX -#define SC_HEAP_MAX SIZE_MAX / sizeof(struct sc_heap_data) -#endif - -bool sc_heap_init(struct sc_heap *h, size_t cap) -{ - void *e; - const size_t sz = cap * sizeof(struct sc_heap_data); - - *h = (struct sc_heap){0}; - - if (cap == 0) { - return true; - } - - if (cap > SC_HEAP_MAX || (e = sc_heap_malloc(sz)) == NULL) { - return false; - } - - h->elems = e; - h->cap = cap; - - return true; -} - -void sc_heap_term(struct sc_heap *h) -{ - sc_heap_free(h->elems); - - *h = (struct sc_heap){ - .elems = NULL, - }; -} - -size_t sc_heap_size(struct sc_heap *h) -{ - return h->size; -} - -void sc_heap_clear(struct sc_heap *h) -{ - h->size = 0; -} - -bool sc_heap_add(struct sc_heap *h, int64_t key, void *data) -{ - size_t i, cap, m; - void *exp; - - if (++h->size >= h->cap) { - cap = h->cap != 0 ? h->cap * 2 : 4; - m = cap * 2 * sizeof(*h->elems); - - if (h->cap >= SC_HEAP_MAX / 2 || - (exp = sc_heap_realloc(h->elems, m)) == NULL) { - return false; - } - - h->elems = exp; - h->cap = cap; - } - - i = h->size; - while (i != 1 && key < h->elems[i / 2].key) { - h->elems[i] = h->elems[i / 2]; - i /= 2; - } - - h->elems[i].key = key; - h->elems[i].data = data; - - return true; -} - -struct sc_heap_data *sc_heap_peek(struct sc_heap *h) -{ - if (h->size == 0) { - return NULL; - } - - // Top element is always at heap->elems[1]. - return &h->elems[1]; -} - -struct sc_heap_data *sc_heap_pop(struct sc_heap *h) -{ - size_t i = 1, child = 2; - struct sc_heap_data last; - - if (h->size == 0) { - return NULL; - } - - // Top element is always at heap->elems[1]. - h->elems[0] = h->elems[1]; - - last = h->elems[h->size--]; - while (child <= h->size) { - if (child < h->size && - h->elems[child].key > h->elems[child + 1].key) { - child++; - }; - - if (last.key <= h->elems[child].key) { - break; - } - - h->elems[i] = h->elems[child]; - - i = child; - child *= 2; - } - - h->elems[i] = last; - - return &h->elems[0]; -} - - diff --git a/PG.out b/PG.out deleted file mode 100644 index 198f3c8492ebcd61d04bd6fd18efbfcc3d118767..0000000000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0*{l2RiXN{NC3W}T zZ>7B*W|>r!)NmQ7@l$S}a@ni<_=?gyT>9a1$NuQDSNHoB-S0AR*Z(T)>0XSSX7+t- z_1#^!zTy>q2e!qUy?Xw-Q(l-VJ*eU>OW<#=rNG%_V#_f05`YitKf#}SNvEQlP^`jx?V2{2n|yyN~-Er z@Hkn&nl=ho_VV_Ef_bdOP|S1?wdWp3#GgPw&_X$Z={A=i|5g2JSWaitTime = getClk() - pCurrentProcess->ArrivalTime; AddEvent(START); // Create a start event + + Number_Of_Process = Number_Of_Process -1; } // [Case 2] the process was stopped and its turn to resume else @@ -285,6 +293,8 @@ void Process_Termination(int signum) Switch_Context_Flag = 1; //set flag to 1 so main loop knows it's time to switch context as // if the process Finished before quanta time Ends other process will start + + signal(SIGCHLD, Process_Termination); // Re-bind SIGCHLD with Process_Termination } int isTie() diff --git a/SJF.c b/SJF.c deleted file mode 100644 index d9968c6..0000000 --- a/SJF.c +++ /dev/null @@ -1,574 +0,0 @@ -#include "Header_File/headers.h" -#include "Header_File/Process_Struct.h" -#include "Header_File/Process_Heap.h" -#include "Header_File/Message_Buffer.h" -#include "Header_File/Events_Queue.h" -#include "Header_File/Process_Queue.h" - -//Functions headers -void initIPC(); -void ExcuteProcess(); -int Receive_Process(); -void Clean_Resources(int signum); -void AddEvent(enum Event_Type Etype); -void Process_Termination(int signum); -void Log_AllEvents(unsigned int start_time, unsigned int end_time); -void Process_Arrival_Handler(int signum); - - -//Global Parameters -event_queue EventQueue; //Event Queue -int recievedMsgQueueId =0; //ID of MsgQueue to recieve process from process generator -unsigned short switchContextFlag =0; //switch context flag {1 = UNLOCKED or switch, 0 = LOCKED or no switch} -unsigned int allProcessCount = 0; //#processes, initially -unsigned int recievedProcessCount=0; -bool isAllRecieved = 0; -Process *pCurrentProcess =NULL; //Pointer to the current running process -heap_t *ProcessPQueue; - -int main(int argc, char *argv[]) -{ - printf("SJF: SJF scheduling Algorithm started\n"); - - //Initializing CLK, IPCs & dat - initClk(); //Inisialize clock - initIPC(); //Inicialze mesaageQueue IPC to recieve processes from process generator - - allProcessCount = atoi(argv[1]); - EventQueue = NewEventQueue(); //Initialize Event Queue - ProcessPQueue = (heap_t *) calloc(1, sizeof(heap_t)); - - //link Signal handlers to signals - signal(SIGUSR1, Process_Arrival_Handler); - signal(SIGINT, Clean_Resources); //handle SIGINT to Clean resources - signal(SIGCHLD, Process_Termination); //handle when a process finishes execution using ChildHandler - - //SJF Excution// - pause(); //suspend until the next signal arrives - unsigned int start_time = getClk(); - while (1) - { - //Recieving the process from the process generator - pause(); - //Check if the critical section is unlocked && there are ready processes in the system - if (switchContextFlag && !HeapEmpty(ProcessPQueue)) - { - switchContextFlag = 0; //Critical Section is now Locked - pCurrentProcess = HeapPop(ProcessPQueue); - ExcuteProcess(); - } - // Check if all processes recieved or not - //Check if all processes are finished - if (isAllRecieved && HeapEmpty(ProcessPQueue) && switchContextFlag) - break; - } - unsigned int end_time = getClk(); - Log_AllEvents(start_time, end_time); - raise(SIGINT); // Clean & Exit - - return 0; -} - -//Initialize IPC and connect to Process Genrator -void initIPC() -{ - key_t key = ftok(Ftok_File, Ftok_Key); //Same parameters as used in Process Generator - recievedMsgQueueId = msgget(key, 0); - if (recievedMsgQueueId == -1) { - perror("SJF: IPC initialization failed!"); - raise(SIGINT); //Clean & Exit - } - printf("SJF: MessageQueue IPC ready!\n"); -} - -int Receive_Process() -{ - Message msg; - // Error in recieving the MsgQueue - if (msgrcv(recievedMsgQueueId, (void *) &msg, sizeof(msg.mProcess), 0, IPC_NOWAIT) == -1) - { - perror("SJF: Error while receiving!"); - return -1; - } - - // if message was retrieved from the message queue - - - printf("SJF: Received by SJF scheduler\n"); - - - Process *pProcess = malloc(sizeof(Process)); // allocate memory for the received process - - - while (!pProcess) { - - - perror("SJF: Malloc Failed!"); - - - printf("SJF: Trying Again..."); - - - pProcess = malloc(sizeof(Process)); - - - } - - - *pProcess = msg.mProcess; //store the process received in the allocated space - - - HeapPush(ProcessPQueue, pProcess->Runtime, pProcess);//push the process pointer into the main processes queue - - - - - - - - //update recievedProcessCount - - - recievedProcessCount +=1; - - - isAllRecieved = (allProcessCount==recievedProcessCount); - - - - - - - - return 0; - - -} - - - - - - - -void Process_Arrival_Handler(int signum) - - -{ - - - Receive_Process(); - - -} - - - - - - - -void Clean_Resources(int signum) - - -{ - - - printf("SJF: Cleaning SJF scheduler resources...\n"); - - - - - - Process *pProcess = NULL; // deallocate before the pointer holds any process - - - Event *pEvent = NULL; // deallocate before the pointer holds any event - - - while (EventQueueDequeue(EventQueue, &pEvent)) //while event queue is not empty - - - { - - - pProcess = pEvent->pProcess; - - - free(pProcess); - - - free(pEvent); //free memory allocated by the event - - - } - - - printf("SJF: Done! SJF Scheduler is now clean.\n"); - - - exit(EXIT_SUCCESS); - - -} - - - - - - - - - - - - -//Each process runs to completion - - -void ExcuteProcess() - - -{ - - - pCurrentProcess->Pid = fork(); //forking a new process - - - while (pCurrentProcess->Pid ==-1) //Error in forking - - - { - - - perror("SJF: Error in forking process!"); - - - printf("SJF: Trying to fork again...\n"); - - - pCurrentProcess->Pid = fork(); - - - } - - - - - - //to be excuted in the forked process itself - - - if (pCurrentProcess->Pid == 0) - - - { - - - char buffer[10]; //buffer to convert runtime from int to string - - - sprintf(buffer, "%d", pCurrentProcess->Runtime); - - - char *argv[] = {"process.out", buffer, NULL}; - - - execv("process.out", argv); - - - - - - //the following will be excuted only if execv() fails. - - - perror("SJF: ERROR! Process execution failed"); - - - exit(EXIT_FAILURE); - - - } - - - // to be excuted in this parent process - - - switchContextFlag =0; - - - //Calculate the waiting time for the current process - - - pCurrentProcess->WaitTime = getClk() - pCurrentProcess->ArrivalTime; - - - - - - //Update the event Queue with the start of the current process - - - AddEvent(START); - - -} - - - - - - - - - - - - -void AddEvent(enum Event_Type Etype) - - -{ - - - Event *pCurrentEvent = malloc(sizeof(Event)); - - - while (!pCurrentEvent) { - - - perror("SJF: Malloc failed"); - - - printf("SJF: Trying again"); - - - pCurrentEvent = malloc(sizeof(Event)); - - - } - - - - - - - - pCurrentEvent->Time_Step = getClk(); - - - if (Etype == FINISH) { - - - pCurrentEvent->Turn_Around_Time = getClk() - pCurrentProcess->ArrivalTime; - - - pCurrentEvent->Weight_Turn_Around_Time = (double) pCurrentEvent->Turn_Around_Time / pCurrentProcess->Runtime; - - - } - - - pCurrentEvent->pProcess = pCurrentProcess; - - - pCurrentEvent->Current_Wait_Time = pCurrentProcess->WaitTime; - - - pCurrentEvent->Type = Etype; - - - pCurrentEvent->Current_Remaining_Time = pCurrentProcess->RemainTime; - - - EventQueueEnqueue(EventQueue, pCurrentEvent); - - -} - - - - - - - - - - - - -void Process_Termination(int signum) - - -{ - - - if (!waitpid(pCurrentProcess->Pid, NULL, WNOHANG)) // if current process did not terminate. return back - - - return; - - - - - - - - pCurrentProcess->RemainTime = 0; //process finished - - - AddEvent(FINISH); - - - - - - - - switchContextFlag = 1; //Process is terminated, and then, it's time for context switch - - -} - - - - - - - -void Log_AllEvents(unsigned int start_time, unsigned int end_time) - - -{ - - - unsigned int runtime_sum = 0, - - - waiting_sum = 0, - - - count = 0; - - - - - - double wta_sum = 0, - - - wta_squared_sum = 0; - - - - - - - - FILE *pFile = fopen("Events_Log.txt", "w"); - - - Event *pNextEvent = NULL; - - - - - - - - // Loop until event queue is empty - - - while (EventQueueDequeue(EventQueue, &pNextEvent)) - - - { - - - PrintEvent_Console(pNextEvent); - - - PrintEvent_File(pNextEvent, pFile); - - - if (pNextEvent->Type == FINISH) { - - - runtime_sum += pNextEvent->pProcess->Runtime; - - - waiting_sum += pNextEvent->Current_Wait_Time; - - - count++; - - - wta_sum += pNextEvent->Weight_Turn_Around_Time; - - - wta_squared_sum += pNextEvent->Weight_Turn_Around_Time * pNextEvent->Weight_Turn_Around_Time; - - - free(pNextEvent->pProcess); - - - } - - - free(pNextEvent); //free memory allocated by the event - - - } - - - fclose(pFile); - - - - - - - double cpu_utilization = runtime_sum * 100.0 / (end_time - start_time); - - - double avg_wta = wta_sum / count; - - - double avg_waiting = (double) waiting_sum / count; - - - - - - - - pFile = fopen("Stats.txt", "w"); - - - printf("\nCPU utilization = %.2f\n", cpu_utilization); - - - printf("Avg WTA = %.2f\n", avg_wta); - - - printf("Avg Waiting = %.2f\n", avg_waiting); - - - - - - - - fprintf(pFile, "Avg WTA = %.2f\n", avg_wta); - - - fprintf(pFile, "Avg Waiting = %.2f\n", avg_waiting); - - - fprintf(pFile, "\nCPU utilization = %.2f\n", cpu_utilization); - - -} - - diff --git a/SRTN.c b/SRTN.c deleted file mode 100644 index 668854e..0000000 --- a/SRTN.c +++ /dev/null @@ -1,416 +0,0 @@ -#include -#include -#include "Header_File/Message_Buffer.h" -#include "Header_File/headers.h" -#include "Header_File/Events_Queue.h" -#include "Header_File/Event_Struct.h" -#include "Header_File/Min_Heap.h" -#include "Header_File/Process_Queue.h" -//#include "Header_File/SRTN.h" -//================================================================================ -/**/void SRTN_start(struct Processes *process_ptr); -void SRTN_stop(struct Processes *process_ptr); -void SRTN_resume(struct Processes *process_ptr); -void SRTN_finish_handler(int signum); -struct Processes * SRTN_compare(struct Processes *process_ptr , struct Processes *process_running); -unsigned int SRTN_RemaininTime(struct Processes *process_ptr ); -void InitIPC(); -void Process_Arrival_Handler(int signum); -int Receive_Process(); -void AddEvent(struct Processes *process_ptr,enum EventType Etype); -void Log_AllEvents(unsigned int start_time, unsigned int end_time); -void SRTN_clear_resources(); -void SRTN_excecute();//*/ -//================================================================================ -//queues -PriorityQueue ReadyQueue; // Ready processes priority queue arranged ascendingly by remaining time -PriorityQueue *pReadyQueue = &ReadyQueue; // ReadyQueue pointer - -queue FinishedQueue; // Queue of finished processes -event_queue EventQueue; //queue of events {START,STOP,RESUMED,FINISH} - -// process pointers -PriorityQueue_data *Pprocess = NULL; -struct Processes *pRunning = NULL; -struct Processes *pRunningNext = NULL; - -//variables -int isRunning = 0; // returns 1 if there is a process currently running -int issending = 1; //need to take number of process // 1->all processes diddn't arrive yet 0->all processes arrived -int Received_MsgQueue_Id; -//================================================================================ -void SRTN_start(struct Processes *process_ptr) -{ - pRunning = process_ptr; - pRunning->RemainTime = pRunning->Runtime; - pRunning->startBefore = 1; - pRunning->StartTime = getClk(); - pRunning->ResumeTime = getClk(); - isRunning = 1; - - //process will exit ready queue to start running - dequeue_PriorityQueue(pReadyQueue); - - // Create new process - int pid = fork(); - pRunning->mPid = pid; - - //fork error - if (pid == -1) - { - perror("Error in fork (SRTN_start)"); - exit(-1); - } - - - // Child (new process) - if (pid == 0) - { - - printf("(SRTN_start) A process created with pid = %d \n", getpid()); - - // remaining time must be string to be able to send it as an argument to process file - // Convert the remaining time to string - char RemaininTime_str[50]; - tostring(RemaininTime_str,pRunning->RemainTime); - //sprintf(RemaininTime_str, "%d", pRunning->RemainTime); - - - // calling execvp system call to replace the image of the child with process file - // sending remaining time as an argument to the process file - char* command = "./process.out"; - char* argument_list[] ={"./process.out", RemaininTime_str, NULL}; - int status_code = execvp(command,argument_list); - - //execvp error - if (status_code == -1) - { - perror("Error in execvp (SRTN_start)"); - exit(-1); - } - } - - -} -//================================================================================= -void SRTN_stop(struct Processes *process_ptr) -{ - process_ptr->LastStop = getClk(); - process_ptr->RemainTime = SRTN_RemaininTime(process_ptr); - isRunning = 0; - pRunning = NULL; - - int pid = process_ptr->mPid; - kill(pid,SIGSTOP); - - // process will return back to ready queue - enqueue_PriorityQueue(pReadyQueue,process_ptr->RemainTime, process_ptr); - -} -//================================================================================= -void SRTN_resume(struct Processes *process_ptr) -{ - pRunning = process_ptr; - pRunning->ResumeTime = getClk(); - isRunning = 1; - - //process will exit ready queue to resume running - dequeue_PriorityQueue(pReadyQueue); - - int pid = getpid(); - kill(pid,SIGCONT); - - if(pid == pRunning->mPid) - { - printf("(SRTN_resume) A process with pid = %d resumed \n", getpid()); - - // remaining time must be string to be able to send it as an argument to process file - // Convert the remaining time to string - char RemaininTime_str[50]; - //tostring(RemaininTime_str,pRunning->RemainTime); - sprintf(RemaininTime_str, "%d", pRunning->RemainTime); - - - // calling execvp system call to replace the image of the child with process file - // sending remaining time as an argument to the process file - char* command = "./process.out"; - char* argument_list[] ={"./process.out", RemaininTime_str, NULL}; - int status_code = execvp(command,argument_list); - - //execvp error - if (status_code == -1) - { - perror("Error in execvp (SRTN_resume)"); - exit(-1); - } - - } -} -//================================================================================== -//done still finish event -void SRTN_finish_handler(int signum) //move to scheduler -{ - //setting values - pRunning->FinishTime = getClk(); - pRunning->LastStop = getClk(); - pRunning->RemainTime = 0; - isRunning = 0; - pRunning = NULL; - - // other calculations here - - // move process to finished processes queue - ProcEnqueue(FinishedQueue,pRunning); - - //Event finished - AddEvent(pRunning,FINISH); - - int status; // exit code of child - int wpid = wait(&status); // pid of waited child who sent the signal - - // sending sigkill signal to the process - kill(wpid, SIGKILL); - - signal(SIGCHLD, SRTN_finish_handler); -} -//=================================================================================== -struct Processes * SRTN_compare(struct Processes *process_ptr , struct Processes *process_running) -{ - unsigned int process_remaintime = process_ptr->RemainTime; - unsigned int running_process_remaintime = SRTN_RemaininTime(process_running); - - //new process has smaller remaintime - if(process_remaintime < running_process_remaintime) - return process_ptr; - //running process has smaller remaintime - else if (process_remaintime > running_process_remaintime) - return process_running; - // if both have same remaining time running process will continue - else if (process_remaintime == running_process_remaintime) - return process_running; -} -//=================================================================================== -// remaining time of current running process = Remaining time in process struct - (current time - resumed time) -unsigned int SRTN_RemaininTime(struct Processes *process_ptr ) -{ - - unsigned int remaining_t; - remaining_t = process_ptr->RemainTime - (getClk() - process_ptr->ResumeTime); - //notes: - //when assigning start time assign it to resumed time also - //when assigning run time assigne it to remaining time also - return remaining_t; - -} -//============================================================= Dealing with message queue ====================================== -// Initialize the IPC and Connect it the process_generator -void InitIPC() -{ - key_t key = ftok(Ftok_File, Ftok_Key); //same parameters used in process_generator - Received_MsgQueue_Id = msgget(key, 0); - if (Received_MsgQueue_Id == -1) { - perror("SRTN: SRTN IPC init failed!"); - raise(SIGINT); - } - printf("SRTN: SRTN IPC ready...\n"); -} - -void Process_Arrival_Handler(int signum) -{ - //keep looping as long as a process was received in the current iteration - while (!Receive_Process()); -} - - -int Receive_Process() -{ - Message msg; - // receive a message or return immediately if their is no proecees - if (msgrcv(Received_MsgQueue_Id, (void *) &msg, sizeof(msg.mProcess), 0, IPC_NOWAIT) == -1) { - perror("SRTN: Error while receiving!"); - return -1; - } - - // if message was retrieved from the message queue - printf("SRTN: Received by SRTN scheduler\n"); - struct Processes *pProcess = malloc(sizeof(Process)); // allocate memory for the received process - while (!pProcess) { - perror("SRTN: Malloc Failed!"); - printf("SRTN: Trying Again..."); - pProcess = malloc(sizeof(Process)); - } - *pProcess = msg.mProcess; //store the process received in the allocated space - enqueue_PriorityQueue(pReadyQueue,pProcess->Runtime,pProcess);//push the process pointer into the ready process priority queue queue - return 0; -} -//============================================================= Dealing with Events ====================================== -// in each process AddEvent(#state of the event {START,STOP,RESUMED,FINISH}); -void AddEvent(struct Processes *process_ptr,enum Event_Type Etype) -{ - Event *pCurrentEvent = malloc(sizeof(Event)); - while (!pCurrentEvent) { - perror("SRTN: Malloc failed"); - printf("SRTN: Trying again"); - pCurrentEvent = malloc(sizeof(Event)); - } - - pCurrentEvent->Time_Step = getClk(); - if (Etype == FINISH) { - pCurrentEvent->Turn_Around_Time = getClk() - process_ptr->ArrivalTime; - pCurrentEvent->Weight_Turn_Around_Time = (double) pCurrentEvent->Turn_Around_Time / process_ptr->Runtime; - } - pCurrentEvent->pProcess = process_ptr; - pCurrentEvent->Current_Wait_Time = process_ptr->WaitTime; //Need to be discussed(wait time:turnaround -start)(wastedtime=turnaround-run) - pCurrentEvent->Type = Etype; - pCurrentEvent->Current_Remaining_Time = process_ptr->RemainTime; - EventQueueEnqueue(EventQueue, pCurrentEvent); -} - -void Log_AllEvents(unsigned int start_time, unsigned int end_time) -{ - unsigned int runtime_sum = 0, - waiting_sum = 0, - count = 0; - - double wta_sum = 0, - wta_squared_sum = 0; - - FILE *pFile = fopen("Events_Log.txt", "w"); - Event *pNextEvent = NULL; - - // Loop until event queue is empty - while (EventQueueDequeue(EventQueue, &pNextEvent)) - { - PrintEvent_Console(pNextEvent); - PrintEvent_File(pNextEvent, pFile); - if (pNextEvent->Type == FINISH) { - runtime_sum += pNextEvent->pProcess->Runtime; - waiting_sum += pNextEvent->Current_Wait_Time; - count++; - wta_sum += pNextEvent->Weight_Turn_Around_Time; - wta_squared_sum += pNextEvent->Weight_Turn_Around_Time * pNextEvent->Weight_Turn_Around_Time; - free(pNextEvent->pProcess); - } - free(pNextEvent); //free memory allocated by the event - } - fclose(pFile); - - double cpu_utilization = runtime_sum * 100.0 / (end_time - start_time); - double avg_wta = wta_sum / count; - double avg_waiting = (double) waiting_sum / count; - - pFile = fopen("Stats.txt", "w"); - printf("\nCPU utilization = %.2f\n", cpu_utilization); - printf("Avg WTA = %.2f\n", avg_wta); - printf("Avg Waiting = %.2f\n", avg_waiting); - - fprintf(pFile, "Avg WTA = %.2f\n", avg_wta); - fprintf(pFile, "Avg Waiting = %.2f\n", avg_waiting); - fprintf(pFile, "\nCPU utilization = %.2f\n", cpu_utilization); -} -//=================================================================================== -void SRTN_clear_resources() -{ - struct Processes *Pprocess = NULL; // deallocate before the pointer holds any process - while (ProcDequeue(FinishedQueue, Pprocess)) //while processes queue is not empty - free(Pprocess); //free memory allocated for this process - - Event *pEvent = NULL; // deallocate before the pointer holds any event - while (EventQueueDequeue(EventQueue, &pEvent)) //while event queue is not empty - free(pEvent); //free memory allocated by the event - - destroy_PriorityQueue(pReadyQueue); - if(pRunning) - free(pRunning); - if(pRunningNext) - free(pRunningNext); -} -//=================================================================================== -void SRTN_excecute() //will be moved to scheduler -{ - //initializing queues - PriorityQueue ReadyQueue = NewPriorityQueue(pReadyQueue, 0); - queue FinishedQueue = NewProcQueue(); - EventQueue = NewEventQueue(); - - - initClk(); //initialize clock - InitIPC(); // Creat and Connect message queue with the Message queue of the process_generator - - //signal sent from child will be handled by SRTN_finish_handler - signal(SIGCHLD, SRTN_finish_handler); - //signal sent from process generator (when new process arrive) will be handled by Process_Arrival_Handler - signal(SIGUSR1, Process_Arrival_Handler); - //handling interrupt signal - signal(SIGINT, SRTN_clear_resources()); - - pause(); // Wait for the first process to arrive - unsigned int start_time = getClk(); // Get the start time - - //this while will run until all processes arrive and finish excecuting - while ( issending || (Pprocess = peek_PriorityQueue(pReadyQueue)) != NULL ) - //while ((Pprocess = peek_PriorityQueue(pReadyQueue)) != NULL || finished < no_process) - { - if(Pprocess != NULL) - { - - if(!isRunning) //if there is no running process currently - { - if(!(Pprocess-> startBefore)) //check if the process didn't run before (first time for process to run) - { - SRTN_start(Pprocess); - AddEvent(Pprocess,START); - } - else - { - SRTN_resume(Pprocess); - AddEvent(Pprocess,RESUMED); - } - - } - else - { - - pRunningNext = SRTN_compare(Pprocess,pRunning); - if (pRunning != pRunningNext) - { - //stop running process - if(SRTN_current_RemaininTime(pRunning)) - { - SRTN_stop(pRunning); - AddEvent(pRunning,STOP); - } - //if process is finished process exit on her own - - - - //running next process can start or resume - if(!(pRunningNext-> startBefore)) //check if the process didn't run before (first time for process to run) - { - SRTN_start(pRunningNext); - AddEvent(pRunningNext,START); - } - - else - { - SRTN_resume(pRunningNext); - AddEvent(pRunningNext,RESUMED); - } - - - } - } - } - } //while loop - - SRTN_clear_resources(); - - unsigned int finish_time = getClk(); // Get the finish time - Log_AllEvents(start_time, finish_time); - raise(SIGINT); // Clean & Exit - -} //SRTN_excecute() - -//=================================================================================== - - diff --git a/Stats.txt b/Stats.txt index 4add730..55a4b84 100644 --- a/Stats.txt +++ b/Stats.txt @@ -1,4 +1,4 @@ -Avg WTA = 3.39 -Avg Waiting = 13.20 +Avg WTA = 2.21 +Avg Waiting = 4.50 -CPU utilization = 103.64 +CPU utilization = 100.00 diff --git a/clk.out b/clk.out deleted file mode 100644 index 164bf1d32a2ffece54a2a110da1981afc4a6bb72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17392 zcmeHPe{dAl9e+s(1cggLz=*9ZNIO`~5hx(2=v_#{1p^`w#a393+>*QDau@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O(HJ+C8}YLK}T&xedHK*nvqR+Z0m zCMzn+e-{~U@!9jbgsH}giu&#E1pW!unp}TgzcA(U)w0xC-?G~%GPK{x_Powvx{HE~ zL~W!jx1ZO|31HM@w&(Q_(>Eb=C*{t8?m>>$(rnM`CZ;o#CfA?!m_7(Ot<9O|^%YZ1 z+579SV9}2Z#gy%N9maG(DRTM#_J3d5Hz+-R|G<>rSCBo$%y0h;Fp3HL$HR%86!ot_ z{Qduw&t6k@Ob3)ZCO-G#CqDaQN`Wcs7qj2vv*-0BQV9G$ zY{xu(@9ehc^(j++@5TE5_`RjO!Gb@M)_a8%tkfHL~zS#M5*7ukHzR#Z5 z#Z0%7b64`0e;hJ;rsgp5I*QMy`}LV;dK$LXE_;68*Hs4)iS=ymBG34F2x#nb`Me(I z|8Ic*Uje%RD6t*);|sv3iEPj7_PBbGr}e5ku|3n#Fm~IEkkYQVDVM`O*p7Kxj}gY@ z^K){Ivgdh@_5Jn}RQXDs)dbsL>mYW9>PpE?dF 0) - { - current_time = getClk(); - - //detecting clk increment - if (previous_time < current_time) - { - remainingtime--; - previous_time = current_time; - } - - printf("(process.c) Remaining time: %d\n", remainingtime); - - } - - if(remainingtime == 0) - exit(1); //exit with exit code 1 (shild signal is sent to parent) - - //============================================================= - destroyClk(false); - - return 0; -} +#include "time.h" +int main(int agrc, char *argv[]) { + int runtime = atoi(argv[1]); + while ((clock() / CLOCKS_PER_SEC) < runtime); + exit(EXIT_SUCCESS); +} \ No newline at end of file diff --git a/process.out b/process.out deleted file mode 100644 index 5b40724566351a89a98394e2b2182edc9428e868..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17320 zcmeHPeQ;b=6~CMGBZYLcg%(09^tG0;6|zlAThn6cZoc}0DTOw%Fj5|y>}#^q{bKhm zBptwDq{B`d4Kt#3lrdOFJL))bbezHR-#x#3&bjxV``*pF`|j;$o7-B-d_KXcT-+j1>R(_oAu1TZnKA$&Q7`7h z_fm14m;>@G$(iLL6QI;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WXqBe5 zY!7d3)|zi?(%^iGQ#C5Irn_znZ*6UKmdFD!K*4b-tyv`xYSVV1ZE4%q5N^}9wY2PL zZr9qw4Qlj_47HLWw7rB=YvBBbocjGT7z6w?d}%$yt^XL2%l2Fl538k|z% zF~{ReMb9K*h0$onJR9Y9U_U73EEBs6e z>lvfZMs?<5aNsW%B`Vy|T4O}Ig;ei}WP3y~+LweXOf)iP$^CjJ8%re}f(B(7Jsv>= z%BACm2+E-eLN?f)0ueJ=y-NfQ9p1VH@x}t}l)T1*dJo-7JrD^?GJTl$lxe|vs49|( zfiu$_##aR4eonwWT5N*&&p3Rtf~gz+W}B&+p2rz^ok_(~m-C1pg%7Un*q)#N85JnA zC!Y71TMrq#{hd@l;|f+Jb&mkdXZ` zKI5|I=P$-5cwk)i>=ySY+w13bB_sb%#rp2}{fz9bY828WY$lO`$B*TgA%pd^y{ecc zjCY%&_3f_zH7K#$A686NM%-^;Pwx89Kp{R0)3jr)d-+_sTc2gdb6{I#v*+LEdTW4$ z#CoPQEi-=+3h>(H`gtAA|4#t_e*k#@VPZQT|L+2aU1WRyeJ)K8;6rF+OKi`G>oU8& z2$6EFiCho6U^|v^&jNB>KR*u#$e!mp)_2=4p!!Lj)dbt$U@>L}+ltAKeC?Pe=68r3 z9;Cos3p5;*u;RzArrivalTime == current_time) { - is_time = true; SendProcess(pNextProcess); //send this process to the scheduler ProcDequeue(Waiting_ProcessQueue, &pNextProcess); //dequeue this process from the processes queue kill(Scheduler_Pid, SIGUSR1); //send SIGUSR1 to the scheduler free(pNextProcess); //free memory allocated by this process } + usleep(900000); //sleep 0.9 sec } // Clear all resources || send 0 = normal exit || other = interrupt diff --git a/process_generator.out b/process_generator.out deleted file mode 100644 index 942535c8e24e78fb229a038825deb19d33facf19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23016 zcmeHPeRx#WnLm>-5EYU^KqDetL@ibr0|Ev#H30@D2pB_9Y}M(Ixk;u>X5!2pOkA;a zBi7k5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