首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CPU留学生编程讲解、辅导C++程序、program编程语言讲解 调试Matlab程序|辅导Web开发
项目预算:
开发周期:
发布时间:
要求地区:
Answer all the questions below. Once you are finished, print the code of
Question 2 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 2 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 Earliest
Deadline First real-time CPU scheduling algorithm, which is the scheduling
algorithm that students often use when doing their homework assignments.
Warning: there are many different ways to write the code for this homework
assignment, which makes detecting cheating easier...
Note: sice 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 strictly 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 and
the period for the process. You can assume that all burst times and
periods are strictly positive, and that the period for a given process is
always at least as big as the burst time of the same process, there is no
need to check for all these things in your program. You can also assume
that all processes have the same arrival time: zero.
Here is an example of what running the program must look like (where 2, 25,
50, 35, and 80 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 2
Enter the burst time of process 1: 25
Enter the period of process 1: 50
Enter the burst time of process 2: 35
Enter the period of process 2: 80
============================================================
Once your program has read all this information from the user, your program
must schedule the processes using the Earliest Deadline First algorithm and
print the computed schedule on the screen. The printed schedule must start
at time 0 and continue up to (but not including) MaxTime, where MaxTime is
the Least Common Multiple of all the periods.
Here is some C code that you can use in your program to compute the Least
Common Multiple of an array of integers:
// Greatest Common Divisor (recursive version)
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
// Least Common Multiple
int lcm(int a[], int num) {
int result = 1;
for(int i = 0; i < num; i++) {
result *= a[i] / gcd(result, a[i]);
}
return result;
}
If you give an array of process periods to this lcm function then the
function returns as result the Least Common Multiple of all the periods.
The second argument num of the lcm function is the number of elements in
the array.
When scheduling the processes, your program must indicate:
- when a process’s current CPU burst starts;
- when a process’s current CPU burst ends;
- when a process is preempted (replaced on the CPU) by another process;
- when MaxTime is reached and the scheduling ends.
Here is an example of what running the program must then look like (where
2, 25, 50, 35, and 80 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 2
Enter the burst time of process 1: 25
Enter the period of process 1: 50
Enter the burst time of process 2: 35
Enter the period of process 2: 80
0: process 1 starts
25: process 1 ends
25: process 2 starts
60: process 2 ends
60: process 1 starts
85: process 1 ends
85: process 2 starts
100: process 2 preempted!
100: process 1 starts
125: process 1 ends
125: process 2 starts
145: process 2 ends
150: process 1 starts
175: process 1 ends
175: process 2 starts
210: process 2 ends
210: process 1 starts
235: process 1 ends
240: process 2 starts
250: process 2 preempted!
250: process 1 starts
275: process 1 ends
275: process 2 starts
300: process 2 ends
300: process 1 starts
325: process 1 ends
325: process 2 starts
350: process 2 preempted!
350: process 1 starts
375: process 1 ends
375: process 2 starts
385: process 2 ends
400: MaxTime reached
============================================================
(Compare this output with the Gantt chart on slide 5.48 of the lecture notes.)
Your program must also indicate when a process misses its deadline and by
how many milliseconds the deadline was then missed. Here is another
example of what running the program must then look like (where 2, 25, 50,
50, and 80 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 2
Enter the burst time of process 1: 25
Enter the period of process 1: 50
Enter the burst time of process 2: 50
Enter the period of process 2: 80
0: process 1 starts
25: process 1 ends
25: process 2 starts
75: process 2 ends
75: process 1 starts
100: process 1 ends
100: process 1 starts
125: process 1 ends
125: process 2 starts
160: process 2 missed deadline (15 ms left)
160: process 2 preempted!
160: process 1 starts
185: process 1 ends
185: process 2 starts
240: process 2 missed deadline (10 ms left)
240: process 2 preempted!
240: process 1 starts
250: process 1 missed deadline (15 ms left)
290: process 1 ends
290: process 2 starts
320: process 2 missed deadline (30 ms left)
320: process 2 preempted!
320: process 1 starts
345: process 1 ends
345: process 2 starts
350: process 2 preempted!
350: process 1 starts
375: process 1 ends
375: process 2 starts
400: MaxTime reached
============================================================
Here is another example of what running the program must look like (where
3, 20, 40, 40, 80, 30, and 60 are inputs typed by the user on the
keyboard):
============================================================
Enter the number of processes to schedule: 3
Enter the burst time of process 1: 20
Enter the period of process 1: 40
Enter the burst time of process 2: 40
Enter the period of process 2: 80
Enter the burst time of process 3: 30
Enter the period of process 3: 60
0: process 1 starts
20: process 1 ends
20: process 3 starts
50: process 3 ends
50: process 1 starts
70: process 1 ends
70: process 2 starts
80: process 2 missed deadline (30 ms left)
80: process 2 preempted!
80: process 1 starts
100: process 1 ends
100: process 3 starts
120: process 3 missed deadline (10 ms left)
120: process 3 preempted!
120: process 1 starts
140: process 1 ends
140: process 2 starts
160: process 2 missed deadline (50 ms left)
160: process 2 preempted!
160: process 3 starts
180: process 3 missed deadline (20 ms left)
180: process 3 preempted!
180: process 1 starts
200: process 1 ends
200: process 1 starts
220: process 1 ends
220: process 2 starts
240: MaxTime reached
============================================================
2) Modify your program so that it now also prints the Average Waiting Time.
Since processes are executed periodically, computing the Average Waiting
Time must be done as follows:
- compute the sum of all the waiting times for all the processes from time
0 up to (but not including) MaxTime.
- compute the number of times all the processes start a new CPU burst from
time 0 up to (but not including) MaxTime (this number is also equal to
the total number of periods for all the processes from time 0 up to (but
not including) MaxTime);
- divide the total waiting time by the total number of burst times to get
the Average Waiting Time.
Here is an example of what running the program must then look like (where
2, 25, 50, 35, and 80 are inputs typed by the user on the keyboard):
============================================================
Enter the number of processes to schedule: 2
Enter the burst time of process 1: 25
Enter the period of process 1: 50
Enter the burst time of process 2: 35
Enter the period of process 2: 80
0: process 1 starts
25: process 1 ends
25: process 2 starts
60: process 2 ends
60: process 1 starts
85: process 1 ends
85: process 2 starts
100: process 2 preempted!
100: process 1 starts
125: process 1 ends
125: process 2 starts
145: process 2 ends
150: process 1 starts
175: process 1 ends
175: process 2 starts
210: process 2 ends
210: process 1 starts
235: process 1 ends
240: process 2 starts
250: process 2 preempted!
250: process 1 starts
275: process 1 ends
275: process 2 starts
300: process 2 ends
300: process 1 starts
325: process 1 ends
325: process 2 starts
350: process 2 preempted!
350: process 1 starts
375: process 1 ends
375: process 2 starts
385: process 2 ends
400: MaxTime reached
Sum of all waiting times: 145
Number of CPU bursts: 13
Average Waiting Time: 11.153846
============================================================
Here is another example of what running the program must then look like
(where 3, 20, 40, 40, 80, 30, and 60 are inputs typed by the user on the
keyboard):
============================================================
Enter the number of processes to schedule: 3
Enter the burst time of process 1: 20
Enter the period of process 1: 40
Enter the burst time of process 2: 40
Enter the period of process 2: 80
Enter the burst time of process 3: 30
Enter the period of process 3: 60
0: process 1 starts
20: process 1 ends
20: process 3 starts
50: process 3 ends
50: process 1 starts
70: process 1 ends
70: process 2 starts
80: process 2 missed deadline (30 ms left)
80: process 2 preempted!
80: process 1 starts
100: process 1 ends
100: process 3 starts
120: process 3 missed deadline (10 ms left)
120: process 3 preempted!
120: process 1 starts
140: process 1 ends
140: process 2 starts
160: process 2 missed deadline (50 ms left)
160: process 2 preempted!
160: process 3 starts
180: process 3 missed deadline (20 ms left)
180: process 3 preempted!
180: process 1 starts
200: process 1 ends
200: process 1 starts
220: process 1 ends
220: process 2 starts
240: MaxTime reached
Sum of all waiting times: 380
Number of CPU bursts: 13
Average Waiting Time: 29.230769
============================================================
Here are a few extra instructions:
- Give meaningful names to your variables so we 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-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!