首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
CSE-381讲解、辅导Canvas留学生、讲解C++语言、C++程序设计调试 讲解数据库SQL|调试C/C++编程
Due before: 11:59 PM (before Midnight) on Dec 4 2019
Page 1 of 6
CSE-381: Systems 2
Homework #9
Due: Wednesday Dec 4 2019 before 11:59 PM
Email-based help Cutoff: 5:00 PM on Tue, Dec 3 2019
Maximum Points: 35
Submission Instructions
This homework assignment must be turned-in electronically via Canvas. Ensure your
C++ source code is named MUID_hw3.cpp, where MUID is your Miami University
Unique ID. Ensure your program compiles without any warnings or style violations.
Ensure you thoroughly test operations of your program as indicated. Once you have
tested your implementation, upload the following onto Canvas:
1. The 1 C++ source file developed for this homework.
General Note: Upload each file associated with homework individually to Canvas. Do
not upload archive file formats such as zip/tar/gz/7zip/rar etc.
Objective
The objective of this homework is to:
• Do some self-research/learning
• Understand the use of /proc file system
• Review the use of server sockets for communication
• Review fork, exec, and pipes in preparation for final exam.
• Extend a C++ program that can be used as a web server
• Develop a web server to run programs & monitor programs
Grading Rubric:
The program submitted for this homework must pass necessary base
case test(s) in order to qualify for earning any score at all.
Programs that do not meet base case requirements will be assigned
zero score!
Program that do not compile, have a method longer than 25 lines, or
just some skeleton code will be assigned zero score.
• See points set for each command and overall structure, organization, conciseness,
variable-names, etc. in the next page. If your methods are not concise points will be
deducted.
• -1 Points: for each warning generated by the compiler (warnings are most likely sources
of errors in C++ programs)
Due before: 11:59 PM (before Midnight) on Dec 4 2019
Page 2 of 6
NOTE: Violating CSE programming style guidelines is a compiler error! Your program should
not have any style violations.
Background
The /proc file system is a logical view of internal data that is maintained by the Linux kernel
about a process. For a given process the kernel exposes a logical file called
/proc/[pid]/stat (where [pid ]is the process ID, e.g., /proc/235/stat). This stats
file contains a variety of statistics about the process that can be used to report runtime statistics
about the process. In this homework, you will be using the following 3 values as described in the
following URL: http://man7.org/linux/man-pages/man5/proc.5.html
Word number
in stats file
Logical name
for Value
Notes
14th word utime (float) Cumulative user time. This value must be divided by divide
by sysconf(_SC_CLK_TCK) to get value in seconds
and round it using std::round.
15th word stime (float) Cumulative system time. This value must be divided by
divide by sysconf(_SC_CLK_TCK) to get value in
seconds and round it using std:round.
23rd word vsize (long) Current virtual memory size in bytes. This value must be
divided by 106 to get memory size in MB.
Starter code
The starter code for this homework is just the solution for Exercise #8 along with test inputs &
outputs supplied as a zip file. Invest time to refresh your memory by reviewing Exercise #8.
Requirements
Suitably extend (how you modify is up to you) the starter source code to perform the following
additional functionality:
1. Base case -- Run a program & record runtime statistics [22 points]: Run a specified
command with suitable arguments and return the output and runtime statistics in the
HTML format shown further below.
a. Outputs are sent line-by-line to the client using chunked encoding.
b. Record and print runtime statistics every second by opening & reading
/proc/[pid]/stat
c. Reading and printing statistics each second for the duration of a child process can
be accomplished as suggested below:
int exitCode = 0;
while (waitpid(pid, &exitCode, WNOHANG) == 0) {
sleep(1); // sleep for 1 second.
// Record current statistics about the process.
}
d. You must run the above loop in a separate thread to record the necessary
statistics.
Due before: 11:59 PM (before Midnight) on Dec 4 2019
Page 3 of 6
e. The recorded statistics must finally be sent to the client as one chunk at the end
of child-program execution.
• Note on formatting statistics: The statistics on each line of the output is
rounded using the std::round method..
! The base case is relatively straightforward. You are given plenty of time to finish
this homework. Consequently, if the base case does not operate as expected, as per
the course policy, the whole program will be assigned zero score.
2. Setup statistics to plot a chart [8 points]: If the genChart parameter (3rd parameter) to
the serveClient method is true, then the program should also generate the runtime
statistics as a JSON array in the following format:
[ second, utime+stime, vsize ]
See annotated HTML in base case output below for details.
Note: This output should use exactly the same statistics values from base case. Do not reread
the stats file to generate the statistics in JSON output.
3. Code quality [5 points]: Five points in this homework are reserved for good code quality,
effective code reuse, and documentation (in the form of doxygen comments). These 5
points would be the hardest to earn in this homework.
Functional testing
The supplied starter code already includes a simple test harness that will also be used for testing
and grading purposes. Several test inputs and expected output files are also supplied to
streamline your testing as shown below. The true/false flag (i.e., last command-line
argument) is used to enable/disable generation of JSON format used to plot charts.
$ ./hw9 base_case1_inputs.txt my_base_case1_output.txt false
$ diff my_base_case1_output.txt base_case1_expected_outputs.txt
Testing for graph case:
$ ./hw9 base_case1_inputs.txt my_graph_case1_output.txt true
$ diff my_graph_case1_output.txt graph_case1_expected_outputs.txt
Needless to add, the above diff commands will not produce any output if the outputs are
identical.
! Testing note: Due to non-deterministic scheduling and multiple users on the
machine, the CPU time and virtual memory use could be a bit different in some
cases. Minor differences in values or 1-more/1-less line of output is expected and
normal. This note also applies to testing via the CODE plug-in.
Ensure you test with input files and corresponding expected outputs prior to submission.
Due before: 11:59 PM (before Midnight) on Dec 4 2019
Page 4 of 6
Browser testing
You absolutely should test operation of your webserver running on
os1.csi.miamioh.edu. A partial screenshot is shown further below for your reference (you
will have to use a different port number instead of 4000).
Submit to Canvas
This homework assignment must be turned-in electronically via Canvas. Ensure your C++ source
files are named appropriately. Ensure your program compiles (without any warnings or style
errors) successfully. Ensure you have tested operations of your program with a browser. Once
you have tested your implementation, upload the following onto Canvas:
Ø The 1 C++ source file you developed for this homework. See earlier Testing note.
Upload all the necessary C++ source files to onto Canvas independently. Do not submit
zip/7zip/tar/gzip files. Upload each file independently.
Screenshot of browser test:
Due before: 11:59 PM (before Midnight) on Dec 4 2019
Page 5 of 6
Base case #2 Annotated output HTML
Parts of the HTML highlighted in gray are fixed/constant strings that can be hardcoded in your
program. Values highlighted in red are chunk sizes in hexadecimal notation.
HTTP/1.1 200 OK
Content-Type: text/html
Transfer-Encoding: chunked
Connection: Close
156
Output from program
1b
Using CPU for computation.
1d
Using memory for operations.
1b
Using CPU for computation.
1d
Using memory for operations.
10
Exit code: 0
6a3
Runtime statistics
Time (sec)
User time
System time
Memory
(MB)
1
1
0
14
2
2
0
14
3
3
0
14
4
4
0
22
5
4
0
22
6
4
0
31
7
4
0
31
8
4
0
47
9
4
0
47
Due before: 11:59 PM (before Midnight) on Dec 4 2019
Page 6 of 6
10
4
0
14
11
4
1
14
12
5
1
14
13
6
1
14
14
7
1
22
15
7
1
22
16
7
1
39
17
7
1
39
18
7
1
73
19
7
1
73
20
7
1
39
21
7
1
0
0
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
mgt202辅导 、讲解 java/pytho...
2025-06-28
讲解 pbt205—project-based l...
2025-06-28
辅导 comp3702 artificial int...
2025-06-28
辅导 cs3214 fall 2022 projec...
2025-06-28
辅导 turnitin assignment讲解...
2025-06-28
辅导 finite element modellin...
2025-06-28
讲解 stat3600 linear statist...
2025-06-28
辅导 problem set #3讲解 matl...
2025-06-28
讲解 elen90066 embedded syst...
2025-06-28
讲解 automatic counting of d...
2025-06-28
讲解 ct60a9602 functional pr...
2025-06-28
辅导 stat3600 linear statist...
2025-06-28
辅导 csci 1110: assignment 2...
2025-06-28
辅导 geography调试r语言
2025-06-28
辅导 introduction to informa...
2025-06-28
辅导 envir 100: introduction...
2025-06-28
辅导 assessment 3 - individu...
2025-06-28
讲解 laboratory 1讲解 留学生...
2025-06-28
辅导 ct60a9600 renewable ene...
2025-06-28
辅导 economics 140a homework...
2025-06-28
热点标签
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: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!