Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SOURCE CODE: 1 // #0#BEGIN# DO NOT MODIFY THIS COMMENT LINE! 2 // 3 // 4 // #0#END# DO NOT MODIFY THIS COMMENT LINE! 5

image text in transcribed

image text in transcribed

SOURCE CODE:

1 // #0#BEGIN# DO NOT MODIFY THIS COMMENT LINE! 2 // 3 // 4 // #0#END# DO NOT MODIFY THIS COMMENT LINE! 5 6 #include "stdio.h" 7 #include "string.h" 8 #define num 5 // 5 processes 9 10 struct PCB { 11 char ID; // process ID 12 int runtime; //runtime 13 int pri; //priority 14 char state; //statusR-ReadyF-Terminated, r-running 15 }; 16 17 struct PCB pcblist[num]; //PCB array 18 19 20 void init() // initialize PCB 21 { 22 int i; 23 for (i = 0; i PCB[0]" 27 // to require users to input ID, priority, and runtime. 28 // The "0" is the index of each PCB, counting start from 0 29 // Return new line after prompt information 30 // #1#BEGIN# DO NOT MODIFY THIS COMMENT LINE! 31 32 // #1#END# DO NOT MODIFY THIS COMMENT LINE! 33 scanf( 34 "%10s%10d%10d", 35 & pcblist[i].ID, 36 & pcblist[i].pri, 37 & pcblist[i].runtime 38 ); 39 pcblist[i].state = 'R'; // initialize all processes "R" 40 getchar(); // carriage from an "enter" key 41 } 42 } 43 44 int max_pri_process() // determine a process with max priority 45 { 46 int max = -1000; // initialize max priority with smallest value 47 int i; 48 int key; 49 for (i = 0; i

*FILL IN SOURCE CODE 1-8 BLOCKS IN C++ PLEASE*

- Introduction to Round Robin Schedule with a Priority Round Robin (RR) with a priority is a CPU scheduling algorithm where each process is assigned a fixed time slot in a cyclic way Assume there are 5 processes with a structure of a Process Control Block (PCB): 1.Process ID: identify each process. 2.Priority: integer 0-100, the bigger the number is, the higher the priority is. The number will be decreased by 1 once a process has done for a quantum. 3.Execution time (user input): how many ms a process needs 4.Status: Ready (initialized), Terminated and currently running. Represented by letter "F" and "r" respectively. To simplify our simulation, we assume all the 5 processes arrive at the same time 0. Also, we do not require you to implement a cyclic linked list to connect all 5 processes structure using pointers. We define the structure of PCB in source code and simply store them in an array, and looping each PCB every time we use them. -Complete Source Code Read the source code and rest comments, try to understand the function of each line of code Follow the instructions in the comments and insert proper code into the rest 8 blocks to implement a CPU scheduling with RR/Priority. (C/C++ files are acceptable). Read the requirements carefully, because some blocks require exact syntax Play the program for a while and observe how it works. Now we run a specific simulation: (1) take the last five digits reversed and set them as the priority (2) set their running time 1, 2, 3, 4, 5 respectively. (3) Gives any five id your like to the 5 processes For example, my banner id is 903908281 , then the last 5 reversed digits 1 , 8,2, , . and i call 5 process "AA", "BB", "CC", "DD", "EE", then my entire setup for 5 process will be: process idpriorityrunning time 8 2 0 4 0 5

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_2

Step: 3

blur-text-image_3

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 International Workshops Gdm Benchmarx Mcis Snsmw Diew Udm Tsukuba Japan April 2010 Revised Selected Papers Lncs 6193

Authors: Masatoshi Yoshikawa ,Xiaofeng Meng ,Takayuki Yumoto ,Qiang Ma ,Lifeng Sun ,Chiemi Watanabe

2010th Edition

3642145884, 978-3642145889

More Books

Students also viewed these Databases questions

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago

Question

4. Describe the factors that influence self-disclosure

Answered: 1 week ago

Question

1. Explain key aspects of interpersonal relationships

Answered: 1 week ago