首页 > > 详细

辅导program留学生、讲解C++编程语言、辅导C/C++、date讲解辅导留学生 Statistics统计、回归、迭代|辅导Web

Answer all the questions below. Once you are finished, print the code of
Question 3 on paper and submit the paper at the start of the lecture on the
due date. Put your name (in English) and student ID number on the paper.
Also add to your paper a picture of your program running.
In addition, upload the C file (only the C file itself, nothing else, no
ZIP file) for Question 3 on iSpace.
Late homework assignments will not be accepted, unless you have a valid
written excuse (medical, etc.). You must do this assignment alone. No
team work or "talking with your friends" will be accepted. No copying from
the Internet. Cheating means zero.
0) The goal of this homework assignment is to implement the Round Robin CPU
scheduling algorithm.
Warning: there are many different ways to write the code for this homework
assignment, which makes detecting cheating easier...
Note: since there are many different ways to write the code, make sure that
you put MANY comments in your code explaining how your code works! Also
give good meaningful names to your variables (including arrays), otherwise
you will lose points.
1) Write a program that does the following.
- Asks the user to enter the number of processes to schedule (you can
assume that this number is always positive, there is no need to check for
that in your program).
- For each process to schedule, ask the user the enter the burst time for
the process (you can assume that all burst times are positive, there is
no need to check for that in your program).
- Asks the user to enter the length of the time quantum q that must be
used by the Round Robin algorithm (you can assume that this number is
always strictly positive, there is no need to check for that in your
program).
Here is an example of what running the program must look like (where 3, 24,
3, 3, and 4 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 3
Enter the burst time of process 1: 24
Enter the burst time of process 2: 3
Enter the burst time of process 3: 3
Enter the length of the time quantum q: 4
============================================================
Once your program has received all this information from the user, your
program must compute a schedule for the processes using the Round Robin
algorithm and print the schedule on the screen.
Here is an example of what running the program must then look like (where
3, 24, 3, 3, and 4 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 3
Enter the burst time of process 1: 24
Enter the burst time of process 2: 3
Enter the burst time of process 3: 3
Enter the length of the time quantum q: 4
1 1 1 1 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
============================================================
(Compare this last line with the Gantt chart on slide 18 of the lecture
notes for Chapter 5.)
Here is another example of what running the program must then look like
(where 4, 6, 3, 1, 7, and 2 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 4
Enter the burst time of process 1: 6
Enter the burst time of process 2: 3
Enter the burst time of process 3: 1
Enter the burst time of process 4: 7
Enter the length of the time quantum q: 2
1 1 2 2 3 4 4 1 1 2 4 4 1 1 4 4 4
============================================================
2) Modify your program so that it now also prints the Average Waiting Time
(AWT) and the Average Turnaround Time (ATT).
Here is an example of what running the program must then look like (where
3, 24, 3, 3, and 4 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 3
Enter the burst time of process 1: 24
Enter the burst time of process 2: 3
Enter the burst time of process 3: 3
Enter the length of the time quantum q: 4
1 1 1 1 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
AWT: 5.666667 ATT: 15.666667
============================================================
Here is another example of what running the program must then look like
(where 4, 6, 3, 1, 7, and 2 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 4
Enter the burst time of process 1: 6
Enter the burst time of process 2: 3
Enter the burst time of process 3: 1
Enter the burst time of process 4: 7
Enter the length of the time quantum q: 2
1 1 2 2 3 4 4 1 1 2 4 4 1 1 4 4 4
AWT: 7.250000 ATT: 11.500000
============================================================
(Compare the Average Turnaround Time on this last line with the value of
the Average Turnaround Time in the figure on slide 20 of the lecture notes
for Chapter 5 when the time quantum is 2.)
3) Modify your program so that, instead of asking the user to enter the
length of the time quantum q, the program now asks the user to enter the
maximum length of the time quantum q.
You program must then compute the process schedule, the average waiting
time, and the average turnaround time for all values of q between 1 and the
maximum length of the time quantum specified by the user.
Here is an example of what running the program must then look like (where
3, 24, 3, 3, and 4 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 3
Enter the burst time of process 1: 24
Enter the burst time of process 2: 3
Enter the burst time of process 3: 3
Enter the maximum length of the time quantum q: 4
q = 1: 1 2 3 1 2 3 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
q = 1: AWT: 5.666667 ATT: 15.666667
q = 2: 1 1 2 2 3 3 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
q = 2: AWT: 6.333333 ATT: 16.333333
q = 3: 1 1 1 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
q = 3: AWT: 5.000000 ATT: 15.000000
q = 4: 1 1 1 1 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
q = 4: AWT: 5.666667 ATT: 15.666667
============================================================
Here is another example of what running the program must then look like
(where 4, 6, 3, 1, 7, and 7 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 4
Enter the burst time of process 1: 6
Enter the burst time of process 2: 3
Enter the burst time of process 3: 1
Enter the burst time of process 4: 7
Enter the maximum length of the time quantum q: 7
q = 1: 1 2 3 4 1 2 4 1 2 4 1 4 1 4 1 4 4
q = 1: AWT: 6.750000 ATT: 11.000000
q = 2: 1 1 2 2 3 4 4 1 1 2 4 4 1 1 4 4 4
q = 2: AWT: 7.250000 ATT: 11.500000
q = 3: 1 1 1 2 2 2 3 4 4 4 1 1 1 4 4 4 4
q = 3: AWT: 6.500000 ATT: 10.750000
q = 4: 1 1 1 1 2 2 2 3 4 4 4 4 1 1 4 4 4
q = 4: AWT: 7.250000 ATT: 11.500000
q = 5: 1 1 1 1 1 2 2 2 3 4 4 4 4 4 1 4 4
q = 5: AWT: 8.000000 ATT: 12.250000
q = 6: 1 1 1 1 1 1 2 2 2 3 4 4 4 4 4 4 4
q = 6: AWT: 6.250000 ATT: 10.500000
q = 7: 1 1 1 1 1 1 2 2 2 3 4 4 4 4 4 4 4
q = 7: AWT: 6.250000 ATT: 10.500000
============================================================
(Compare all the Average Turnaround Times computed in this example with all
the values in the figure on slide 20 of the lecture notes for Chapter 5
when the time quantum varies from 1 to 7.)
(Also note how, when q is 7, the Round Robin algorithm behaves like the
First-Come First-Served (FCFS) algorithm; see slide 17 of the lecture notes
for Chapter 5 in the case when q is large.)
Here are a few extra instructions:
- Give meaningful names to your variables so I can easily know what each
variable is used for in your program.
- Put comments in your code (in English!) to explain WHAT your code is
doing and also to explain HOW your program is doing it.
- Make sure all your code is properly indented (formatted). Your code
must be beautiful to read.
- Include a picture of your program running, even if your program is not
completely finished.
Failure to follow these instructions will result in you losing points.
The End!

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!