辅导案例-CSSE2310

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Possible marks: 100
Instructions:
1. This is an individual exam. You can use code given to you by course staff this semester or code
which you wrote yourself this semester.
2. Download the answer text file from blackboard.
3. Answer Questions 1–6 in that file (using plain ascii text).
4. Question 7 will require you to write one or more C files. The names required for these files are
given in the question.
5. Submit your answers via blackboard.
• Attach all of your answer files to the same submission (Don’t submit once for each file).
• Do not change the names of the files.
• You may submit multiple times (within the timelimit) but each submission should be com-
plete.
6. If you wish to record assumptions you relied upon, you may do so at the end of the answer file.
• Do not use this part as an alternative answer box.
Page 1 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 1) Write shell commands to do the following: [10 marks (1 each)]
A) Make an executable program from start.c which links the maths library.
B) Output the last 3 lines of bill
C) Output all lines from bill which contain “mud” but not “mudcake”.
D) Output the 4-th column of bill (columns are separated by spaces).
E) Output all lines from bill which contain “cake” in reverse (lexacographic) order.
Page 2 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
F) Remove pots.c from the svn repository.
G) Compile pond.c and append errors to logs.err
H) Make an executable program called box from dims.c and space.c.
I) List all filenames in the current directory which have at least four characters in them and which
end in .cc
J) Record changes made to dims.c and space.c into the svn repository.
Page 3 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 2) Write C to declare foo as . . . : [6 marks (1 each)]
A) An array of five true / false values.
B) An array of ten strings.
C) A pointer to a function which returns a small integer and takes a character.
D) A pointer to an integer which is modified by multiple threads.
E) A string which should not be modified by this code.
F) A high precision floating point number.
Page 4 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 3) [6 marks (2 each)]
Suppose a system uses 32bit virtual addresses, 36bit physical addresses and a two level page table.
Pages are 4KiB (4096 Bytes) each. Page table entries are 4 Bytes each.
(All addresses are expressed in base 10).
A) A process uses virtual address ranges:
• 3MiB starting at 57344
• 1MiB starting at 29356032
How much memory would be required to store the page table.
B) Part of a page table for a process is given below:
Page Frame
18 -
19 18
20 16
21 17
22 21
Which physical address do the following virtual addresses map to?
(If they would SEGFAULT say so.)
77829
77823
Page 5 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
C) A single threaded process accesses the following virtual addresses in order. It segfaults on the last
one.
94447
73633
92457
82916
Assuming that the process uses consistent virtual pages each time it runs, which of the following
addresses would cause a segfault if accessed? (In your answer file, write each address followed by
“Yes” or “No” as appropriate).
Segfaults?
91109 Yes / No
86015 Yes / No
82098 Yes / No
94386 Yes / No
Page 6 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 4) [11 marks]
Consider the following directory listing:
$ ls -ali
total 2164
1067385 drwxr-xr-x 3 andy football 4096 Jul 17 11:08 .
1065112 drwxr-xr-x 1 andy football 4096 Jul 17 10:43 ..
1061551 -rwxr-xr-x 1 librarian football 8192 Jul 19 10:23 apt
1067391 lrwxrwxrwx 1 librarian football 4 Jul 17 10:59 backup -> data
1066833 ddrxr-xr-x 2 librarian football 4096 Jul 17 10:59 data
1067386 -rwxr-xr-x 1 andy football 2190232 Jul 17 11:00 generate
1068104 lrwxrwxrwx 1 andy football 4 Jul 17 11:09 install -> apt
1067407 -rw-r--r-- 2 andy football 179 Jul 17 11:05 log2
1067392 -rw-r--r-- 1 andy football 179 Jul 18 11:05 logs
1067407 -rw-r--r-- 2 librarian football 179 Jul 17 11:05 logx
1067408 lrwxrwxrwx 1 andy football 4 Jul 17 11:08 logz -> logs
A) There are some inconsistencies in the listing. What are they? [4 marks]
B) What command was used to create backup. [2 marks]
C) What command would prevent members of the football group (other than andy) from running
install but not affect anyone else? [2 marks]
Page 7 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
D) A system has the following ordinary users and groups (and no others): [3 marks]
User Groups
mustrum university football
librarian university football
andy football
havelock palace
Consider the following directory listing:
-r--r-x--- 1 mustrum palace 138856 Jul 17 10:46 f1
--w-r-xrwx 1 librarian university 2190232 Jul 17 11:49 f2
---xr--r-x 1 mustrum football 24000 Jul 17 09:14 f3
Which users are allowed to:
1. Read from p1?
2. Write to p2?
3. Run p3?
Page 8 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 5) [15 marks]
Consider the following network (assume that all networks are as small as possible):
15.0.134.7
15.0.134.11
15.0.134.13 15.0.134.1
15.0.124.6
15.0.124.31
15.0.124.33
15.0.124.19
15.0.119.101
15.0.119.103
15.0.119.95
15.0.119.1
A
B C
Internet
X1 X2
Y1
Y2
W1 W2
Z1
Z2
192.168.0.3
192.168.0.2
192.168.9.6
192.168.9.5
192.168.12.3
192.168.11.2
15.0.130.11
15.0.130.10
X1
X2
Y1
Y2
Z1
Z2
W1
W2
D
E
A) Fill in the details for each of the subnets in the diagram. [6 marks]
(Assume each network is as small as possible.)
Network Netmask Broadcast CIDR
A
B
C
B) Fill in the detail for the whole network shown above (as it should appear to the rest of the internet).
Netmask Broadcast CIDR
Page 9 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
C) How many unused addresses are in each of the following networks? [2 marks]
A
C
E
D) An organisation owns the 8.19.29.0/21 block and they wish to break it into networks each
containing 128 machines. What is the maximum number of such networks they could have? [2 marks]
E) Which layer of the network stack are each of the following terms primarily associated with? [3 marks]
putty
ethernet
MAC
IPv6
UDP
TCP
Page 10 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 6) Consider a “unix” filesystem where: [8 marks, 2 each]
• blocks are 8KiB
• block pointers are 8 Bytes.
• inodes have:
– 6 direct pointers
– 3 single indirect pointers
– 2 double indirect pointers.
A) What is the smallest file size which requires use of the second single indirect pointer?
B) What is the maximum file size on this filesystem?
C) If the inode had one of the double indirects replaced was with a “triple indirect”, what would be
the new maximum file size on this filesystem?
D) Assuming the inode is cached in RAM, how many blocks would need to be accessed to read the
40963rd byte in the file?
Page 11 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
Question 7) [44 marks]
In this question you will be required to write one or more c programs described below. There will
be constraints on what the files are to be called and which functions you are not allowed to use.
You can develop the programs on your own machines if you wish. However, they must compile and
run on moss for marking purposes. You must attach each file to your blackboard exam submission.
Write two files:
• hub.c : gcc hub.c -std=gnu99 -pedantic -o hub
• short.c : gcc short.c -std=gnu99 -pedantic -o short
These files can only #include system headers. They must not include other .c files.
short p1 p2
Connect to ports p1 and p2 on localhost. Anything read from p1 should be written to p2. Anything
read from p2 should be written to p1.
hub
The hub program listens on a number of emphemeral ports and prints out their port numbers. Input
read from each port is either discarded or sent out one of the other ports. The first commandline
argument is the number of ports to listen on. The remaining commandline arguments are pairs of
numbers. The first being the input port and the second being the output port. It is an error (your
choice of message) to have the wrong number of arguments or to have a port listed for input more
than once.
For example: hub 3 0 1
Would output: 5400
5931
5501
Any text sent to port 5400 (port #0) would be read and sent out via the connection to port 5931
(port #1). Any input sent to port 5501 (port #2) should be discarded. Any input sent to port #1
should also be discarded.
Page 12 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
END OF EXAMINATION
Page 13 of 14
Semester One Final Examination, 2020 CSSE2310 [version=A1728C0]
You may detach this sheet.
Do not record answers on this sheet.
Example addresses:
broadcast 130.102.17.255
netmask 255.255.255.0
CIDR 130.102.17.0/24
%c character
%d integer
%u unsigned integer
%lf double (scanf)
%f double (printf)
%p void pointer
%ld long integer
grep [-v] [ $ ^ . * ]
ls [-ladi]
ps [-ef]
sort [-r -k]
uniq [-c]
cat
head [-]
tail [-]
cut [-f -d]
wc [-l]
diff
svn
chmod
ln [-s]
rm [-rf]
mkdir
rmdir
cp [-r]
mv
vim/nano
less
Layers
link
application
onion
physical
network
gooey caramel
transport
KiB = 210 Bytes
MiB = 220 Bytes
GiB = 230 Bytes
[ ] array access
. member selection
− > follow and select
+ +−−
sizeof
∼ bitwise not
! logical not
+ - unary forms
& address of
* follow
( ) cast
* / %
+ - binary forms
><<=>=
== !=
& bitwise AND
ˆ bitwise XOR
| bitwise OR
&& logical AND
|| logical OR
? : ternary operator
= += -= . . .
, comma operator
Page table
TLB
Frame
Page
Page 14 of 14

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468