首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CS 480-2程序设计讲解、辅导data程序、c/c++编程语言调试 讲解数据库SQL|辅导R语言程序
项目预算:
开发周期:
发布时间:
要求地区:
PROGRAMMING ASSIGNMENT #1
Reading virtual /proc filesMERGEFORMATMERGEFORMAT
CS 480-2 100 points Spring 2021
Due Fri. Jan. 29 at 11:59 PM.
Early deadline is Thu. Jan. 28.
Programs received by Tue. Feb. 2 will count as 1 day late; programs received by Wed. Feb. 3 will count as 2 days late.
See syllabus for point values.
Topics covered:
Virtual /proc files
OS interface: review of parm handling
Compiler interface: review of makefiles and header guards
Review of basic C++ I/O and record endings
Review of basic object and pointer handling
Review of C++ string class and STL vector class
Specifications:
Answer the questions below about the machine you are running on (turing/hopper) by writing a program that reads the virtual files /proc/cpuinfo and /proc/uptime.
1. Check to see how many parameters have been supplied when your program was called, e.g.:
./hw1.exe myfile.txt
If there are no parameters, use /proc/cpuinfo and /proc/uptime.
If there are two parameters, use those files in place of /proc/cpuinfo and /proc/uptime. If you can’t open the file, for example because it doesn’t exist, print a meaningful error message and quit.
If there is a different number of parameters, print a meaningful error message and quit.
2. Different versions of the operating system may have slightly different versions of the cpuinfo file. You can assume that the item names will be spelled consistently in different versions of the file for turing/hopper, so you can use any sample file to obtain the item names. If any of the items you need is missing, print an appropriate message for that question. Similarly, if any of the items you need is improperly formatted, e.g., no colon or no numeric value, print an appropriate message for that question.
You can not assume anything about line formatting except for the order of the elements: item name, colon, value. For example, you can not assume that there will be exactly one space after a colon, that there will be no extra spaces at the beginning or end of a line, or that any particular combination of spaces will be used. Similarly, you can not assume that the number of digits in a numeric field will always be the same.
3. Processor numbers need not be contiguous, so you need to count the number of distinct processors. (The majority of the input fields repeat for each processor.) Look for the keyword “processor”; don’t depend on a blank line between processors.
To get the number of physical CPUs, you must keep track of the number of distinct physical CPU ids. If there are no physical CPU ids, then the number is 1. CPU ids are not necessarily sequential.
For each physical CPU, look at the “cpu cores” field to get the number of cores for that physical CPU. Again, if that field does not exist, the number is 1, since that is a single-core machine. Add them up to get the total number of processors. Equivalently, you can count the number of distinct processors. You should get the same answer either way.
When a physical CPU has more than one core, those cores share cache.
4. For each item in parts AD, express each output in a numbered complete sentence, e.g.:
B: Questions about the configuration:
1. The machine has __ processors.
2. The machine has __ physical CPUs. (if there is only one: 1 physical CPU.)
...
5. Here are some rules you need to follow for full credit. There will be a 10 point penalty for each rule violated.
a) Use the C++ string class to represent strings. Do not use character arrays.
b) Do not use loops or character arrays to process strings for any of the questions below. Use member functions of the string class. You can use a loop to read the file and to count the number of processors.
c) You may only read each file once and you do not know which order the keywords will come in, so you need to read the file, save the fields you need, and then format your output.
d) Define a Processor class and use the data for each processor to build a Processor object. Use a vector of pointers to keep track of your processors (not an array or vector of objects directly).
e) Store the header and body for each class in separate and appropriately named files, e.g., Processor.h and Processor.cpp.
f) Define at least two functions, one to test whether a physical CPU is already in a data structure and one to determine whether a parameter is included in a longer string, and to return the value if it is. You are welcome to define further functions or classes. Use the second function to extract the value for each keyword, i.e., only code the search once. Use a vector of string to make a list of the physical IDs.
g) Use header guards.
h) You must follow the style and documentation rules given below.
i) You must follow the submission instructions given below.
j) You may not use other inputs than given in the specifications. For example, your program may not ask a question that the user has to answer.
A: Questions about the cpuinfo file
1. What are the names of the files you are reading? (They will either be /proc/cpuinfo and
/proc/cpuinfo or the files listed in the parms.)
2. How many records are there in the first file?
3. How many characters are in the first file?
4. Which system utility or utilities did you use to verify that your answers to questions 2 and 3
are correct?
B: Questions about the configuration
1. How many processors (total cores) does the machine have?
2. How many physical CPUs?
3. What are the physical ids? (List them with spaces or commas between them, or “none” if
no physical ids are listed.)
4. Are there any processors that share cache?
C. Questions about the first processor in the file
1. What is its physical address size?
2. What is its virtual address size?
3. What is the ratio of virtual address size to physical address size? (You can calculate that as
2^(virtual bits - physical bits.)
4. Does it have a floating point unit?
5. How big is the cache in KB?
6. How big is the cache in bytes?
D. Questions about uptime
1. How long has the system been up in seconds? Use the first number in /proc/uptime (or
its replacement file) to determine this.
2. Express that time in days, hours, minutes and seconds. Round off to the nearest tenth of a
second (one decimal place, e.g., 7 days, 1 hour, 2 minutes, and 4.3 seconds)
Administration:
Name your main program hw1.cpp. You may use as many auxiliary files for classes and headers as you like. Provide a makefile (with the name makefile), that your TA can use to compile, run and clean up after your program. The makefile should permit the following commands:
make
make clean
Your makefile should produce an executable file named hw1.exe. Note that this is not the standard naming convention for Linux executables.
Zip up all of your source files (no object files, test files, intermediate subdirectories, or other files). Name your zip file hw1xxxx.zip, where xxxx is your 4letter ID in lower case. Zip is available on turing/hopper, or you can use one of the many free implementations available.
There will be a penalty for violating these rules, e.g., submitting extra files, adding an extra level of subdirectory, using a different compression program, or naming your files differently.
In particular, double-check the following before you submit:
1. You have included a makefile.
2. Your makefile works.
3. Your makefile is named makefile.
4. Your program is named hw1.cpp.
5. Your zip file is named hw1-xxxx.zip as described above.
6. Your zip file does not include any unnecessary files, including test files, object files,
executables, old versions, etc.
7. Your zip file does not include any extra levels of subdirectories.
8. Your zip file is in zip format (not .rar, etc.), regardless of which program you used to create it.
9. You have compiled and tested your program on turing/hopper, regardless of where you
developed it.
Text in the Blackboard comment fields will not be seen by our grading protocol and will be ignored. Feel free to put comments at the top of your program.
Submit the zipped file on Blackboard. We will compile and run them on turing/hopper. You will lose points if your program does not compile and run on turing/hopper, whether the error is due to non-standard code or to not following the submission rules.
Coding style:
You must follow the rules for CSCI 480 on the course web page. There is a pointer on Blackboard, and they are also accessible directly at:
http://www.cs.niu.edu/~freedman/480/480-code01.html.
Testing:
Test your program on turing, on hopper and using a command line parameter. Try each of the provided test files.
Before you test, build your program using your makefile in an empty directory.
Grading:
Your program must run on any legal input. Some extra test files have been provided in the course directory on turing/hopper at
~t90rkf1/d480/dhw1-cpuinfo. Your program must run on all legal cases as specified above; i.e., we do not guarantee that the provided test files will include every possible error condition.
For full credit, your program must work correctly and follow the specs and documentation standards above, including naming conventions and file organization.
Grading rubric:
10 points - proper parm handling
10 points - can open and run every provided test file
80 points - 5 points for answer to each question (there are 16 of them)
In addition, there will be a 10 point penalty for violating any of the rules above (10 points per rule).
Programming hints:
Here are some functions that you might find useful:
File class: getline
String class: find, rfind, find_first_of, find_first_not_of, substr,
length, constant npos
Misc. functions: stoi, stof
(Both of the above are ways to convert a string to a number.)
You are welcome to use any functions of the string class or other C++ classes that you prefer. The web page at http://www.cs.niu.edu/~freedman/480 contains some useful reference materials for C++ classes.
Sample code is available in the course directory on turing/hopper.
Software:
There are many sources of information on zip, including the man entry on turing/hopper.
There are also many sources of information about makefiles and make. Several pointers are available on the course web page. Information about header guards is also available from the course web page.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
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
软件定制开发网!