Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void finalize _ stats ( SCHEDULER _ STATS * stats ) { / / todo } void mark _ process _ start ( SCHEDULER _

void finalize_stats(SCHEDULER_STATS* stats){
// todo
}
void mark_process_start(SCHEDULER_STATS* stats, PROCESS* p, float curr_time, float time_slice){
// todo
}
void mark_process_run(SCHEDULER_STATS* stats, PROCESS* p, float curr_time, float time_slice){
// todo
}
void mark_process_end(SCHEDULER_STATS* stats, PROCESS* p, float end_time, float time_slice_remaining){
// todo
}
Complete the avove todo's which are functions in c.
Write the code for that.
Write the code such that It passes thee test case.
I am giving you test cases for these functions.
#include
#include "../src/student_code.h"
#include "../src/process.h"
#include "../src/process_list.h"
#include "../src/process_scheduling.h"
Test(HelperFunctions, mark_process_start, .disabled=false){
SCHEDULER_STATS* s = get_empty_stats_block();
PROCESS *p = create_process(1.0f,0,0.0f);
mark_process_start(s, p,0.0f,1.0f);
cr_assert(p->length ==1.0f);
cr_assert(p->priority ==0);
cr_assert(p->entry_time ==0.0f);
cr_assert(p->time_remaining ==1.0f);
cr_assert(s->num_processes_started ==1);
cr_assert(s->num_processes_completed ==0);
cr_assert(s->sum_of_turnaround_times ==0.0f);
cr_assert(s->sum_of_response_time ==0.0f);
cr_assert(s->average_turnaround_time ==0.0f);
cr_assert(s->average_response_time ==0.0f);
cr_assert(s->completion_time ==0.0f);
}
Test(HelperFunctions, mark_process_run, .disabled=false){
SCHEDULER_STATS* s = get_empty_stats_block();
PROCESS *p = create_process(1.0f,0,0.0f);
mark_process_run(s, p,0.0f,1.0f);
cr_assert(p->length ==1.0f);
cr_assert(p->priority ==0);
cr_assert(p->entry_time ==0.0f);
cr_assert(p->time_remaining ==0.0f);
cr_assert(s->num_processes_started ==0);
cr_assert(s->num_processes_completed ==0);
cr_assert(s->sum_of_turnaround_times ==0.0f);
cr_assert(s->sum_of_response_time ==0.0f);
cr_assert(s->average_turnaround_time ==0.0f);
cr_assert(s->average_response_time ==0.0f);
cr_assert(s->completion_time ==0.0f);
}
Test(HelperFunctions, mark_process_end, .disabled=false){
SCHEDULER_STATS* s = get_empty_stats_block();
PROCESS *p = create_process(1.0f,0,0.0f);
p->time_remaining =0; // Pretend the job ran
mark_process_end(s, p,1.0f,0.0f);
cr_assert(p->length ==1.0f);
cr_assert(p->priority ==0);
cr_assert(p->entry_time ==0.0f);
cr_assert(p->time_remaining ==0.0f);
cr_assert(s->num_processes_started ==0);
cr_assert(s->num_processes_completed ==1);
cr_assert(s->sum_of_turnaround_times ==1.0f);
cr_assert(s->sum_of_response_time ==0.0f);
cr_assert(s->average_turnaround_time ==0.0f);
cr_assert(s->average_response_time ==0.0f);
cr_assert(s->completion_time ==0.0f);
}
Test(HelperFunctions, finalize_stats, .disabled=false){
SCHEDULER_STATS* s = get_empty_stats_block();
PROCESS *p0= create_process(1.0f,0,0.0f);
PROCESS *p1= create_process(1.0f,0,0.0f);
mark_process_start(s, p0,0.0f,1.0f);
mark_process_run(s, p0,0.0f,1.0f);
mark_process_end(s, p0,1.0f,0.0f);
mark_process_start(s, p1,1.0f,1.0f);
mark_process_run(s, p1,1.0f,1.0f);
mark_process_end(s, p1,2.0f,0.0f);
finalize_stats(s);
cr_assert(s->num_processes_started ==2);
cr_assert(s->num_processes_completed ==2);
cr_assert(s->sum_of_turnaround_times ==3.0f);
cr_assert(s->sum_of_response_time ==1.0f);
cr_assert(s->average_turnaround_time ==1.5f);
cr_assert(s->average_response_time ==0.5f);
cr_assert(s->completion_time ==0.0f);
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

Students also viewed these Databases questions

Question

Consider this article:...

Answered: 1 week ago