关键词 > CSSE2310/CSSE7231

CSSE2310/CSSE7231 Computer Systems Principles & Programming 2021

发布时间:2022-06-10

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Semester Two Final Exams, 2021

CSSE2310/CSSE7231 Computer Systems Principles & Programming

QUESTION 1 (11 marks 1 mark each)

Note: quotation marks below delimit strings and names but are NOT part of the names.

(a) Write a shell command to show the names (only) of all files and directories in the "/etc"

directory (which is NOT the current directory).

(b) Write a shell command to move all " .spec" files (i.e. files ending " .spec") in the

"/tmp/a4data" directory to the "data" subdirectory of the home directory.

(c) Write a shell command to make a new subdirectory of the current directory called "exam".

(d) Write a shell command to compile and link an executable program called "netserver" that uses pthreads and the maths library from two C files called "threadcalc.c" and         " server.c". All input and output files are in the current working directory.

(e) Write a shell command to save any changes from the subversion working copy (the current directory) to the repository.


(f) Write a shell command to show all lines in a file called "services" (in the "/etc"

directory) that contain the string "tcp".

(g) Write a shell command to show all lines in a file called "resolv.conf" in the "/etc"

directory that do not contain the string "nameserver".

(h) Write a shell command that finds all lines in the file "colours" (in the user’s home       directory) that contain the string "r=255" but not string "g=255" and appends those lines to a file called "red" in the "tmp" subdirectory of the current directory.

(i) Write a shell command that counts the number of lines in a file called "addresses" (in the current directory) that contain the string "Mount Cootha".

(j) Write a shell command that counts all lines in the file "vimrc" (in the "/etc" directory) that contain the string "set" and appends that count value to a file called "set.count" in the "vim" subdirectory of the current directory.

(k) Write a shell command that, in the current directory, creates a symbolic link called "a3test" that points to "testa3.sh" in the "/local/courses/csse2310/bin"

directory.

QUESTION 2 (6 marks 1 mark each)

Write C declarations to declare a variable "foo" as ...

(a) An array of five 8-bit whole numbers (i.e. 8-bit signed integers)

(b) A pointer to a function which can be used as a signal handler.

(c) A thread ID

(d) A floating point number with an initial value of 3.14

(e) An array of integers suitable for passing to the pipe() system call

(f) An instance of a structure that contains two members : a character and an integer.

QUESTION 3 (4 marks 1 mark for each address)

moss.labs.eait.uq.edu.au uses 4KiB pages. Suppose a process on moss has the following page table. All numbers are in base 10.

Page Number

Frame Number

0

-

1

51

2

52

3

-

4

44

5

22

...

50

5641

51

3756

52

5642

53

3743

...

8,191

102

8,192

97

For each of the following virtual addresses, what is the corresponding physical address?    Write your answer in base 10. If accessing the virtual address would result in a                     segmentation fault, then write "SEGFAULT". If there is insufficient information in the page table (i.e. the page number is not listed) then write "UNKNOWN".

Virtual Address

Physical Address

13,456

20,000

60,000

206,495

(6 marks 1 mark each)

Suppose a system uses 43-bit virtual addresses and 40-bit physical addresses and uses a three-level page table.  Pages are 8KiB in size. Page table entries are 8 bytes each.           A process uses the following virtual address range (all numbers are in base 10):

•   1,000 MiB starting at address 0

(a) What is the maximum memory space for a process on this system (in GiB)?

(b) How much memory (in KiB) would be needed to store the page table for this process?

(c) If the process memory usage expanded to 10,000MiB (all starting at address 0), how

much memory (in KiB) would now be needed to store the page table?

(d) If the original process memory usage expanded to 10,000MiB but this was 1,000MiB     starting at address 0 and 9,000MiB at the highest virtual addresses, how much memory (in KiB) would now be needed to store the page table?

(e) For the original memory usage (1,000MiB starting at address 0), if the system used a two

level page table, how much memory (in KiB) would be needed to store the page table?

(f) For the original memory usage (1,000MiB starting at address 0), if the system used a single level page table, how much memory (in MiB) would be needed to store the page table?

(5 marks 1 mark each)

Consider the following program. Assume that all system calls succeed.

#include

#include h>

#include it.h>

int main(int argc, char** argv) {

pid_t pid;

printf("A\n");

if(fork()) {

printf("B\n");

} else {

printf("C\n");

pid=fork();

printf("D\n");

if(pid) {

printf("E\n");

waitpid(pid, NULL, 0);

printf("F\n");

} else {

printf("G\n");

}

}

if(!fork()) {

printf("H\n");

}

printf("J\n");

return 0;

}

(a)  How many processes are created by the execution of this program (including the initial process)?

(b) What is the maximum number of processes that could be running or runnable at any point?

(c)  If standard output buffers are never flushed until a process exits, how many times will the character D’ be output?

(d) What is the minimum number of lines of text that this program will output when run?

(e) What is the maximum number of lines of text that this program will output when run?

(9 marks)

(a)  Fill in the netmask, broadcast address and CIDR for each of the networks (A to D):       (6 marks)

Network

Netmask

Broadcast Address

CIDR

A

B

C

D

(b)  Fill in the detail for the whole network shown above (as it would appear to the rest

of the internet).

Netmask

Broadcast Address

CIDR

(c)  How many unused addresses are there in network D? (i.e. how many additional          machines could be added to that network)                                                             (1 mark)

QUESTION 7

Consider a "unix" file system where

(8 marks)

•    blocks are 32 KiB

•    block pointers are 8 bytes

•    inodes have

o 6 direct pointers

o 4 single indirect pointers

o 2 double indirect pointers

(a) What is the maximum file size on this file system? Express your answer in KiB.    (2 marks)

(b) What is the maximum file size that can be stored without using a double indirect

pointer? Express your answer in KiB.                                                                                            (2 marks)

(c) Assuming only the inode is cached in memory, how many blocks must be accessed to

read bytes 150,000 to 200,000 (inclusive) from a file into memory?                                (2 marks)

(d) Some filesystems store very small files in the inode itself. What’s the size of the largest    file that could be stored in the inode without using a data block? State any assumptions that

you make.