CSSE2310 2021-linux终端和c

CSSE2310 2021 SEM2 exam answers UQAttic.net CSSE2310: 2021 SEM2 exam answers UQAttic Other exam papers Please contribute to these documents. If you’re looking for an effective way to familiarise yourself with the course material, you can’t go past collaborating with fellow students. We have laboured to put these up, and so at the very least point out where you think we are wrong! You’ll get more out of the course, you’ll do better in the exam, and other students will benefit from your input as well. To get editing permissions, visit UQAttic.net and provide us with your Google Account address by clicking on the “Get editing permissions” button on the front page. Style. Type answers in blue beneath each question. If you’re unsure of your answer, highlight your answer text then hit Ctrl+Alt+M to create a comment beside the text. Once you’re satisfied with the answer, click the “Resolve” button on the comment. If you want some extra explanation from someone else on their answer, highlight the other person’s answer and repeat the procedure above. It’s the day of the CSSE2310 2022 Sem 1 exam so time to try the one from last sem lmao CSSE2310 2021 SEM2 exam answers UQAttic.net a) ls -a ~/etc Etc is a directory in root so wouldn’t it just be /etc [+1] Mv /tmp/a4data/*.spec ~/data [+1] Mkdir exam Gcc -lpthread -lm threadcalc.c server.c -o netserver (unsure) Gcc -pthread -lm threadcalc.c server.c -o netserver (to link pthread it’s just -pthread, no “l”) svn commit Grep tcp /etc/services Grep -v nameserver /etc/resolv.conf Grep r=255 ~/colours | grep -v g=255 >> ./tmp/red Grep -c “Mount Cootha” addresses CSSE2310 2021 SEM2 exam answers UQAttic.net Grep -c set /etc/vimrc >> ./vim/set.count Ln -s /local/courses/csse2310/bin/testa3.sh a3test Uint8_t foo[5]; (-1) int8_t foo[5]; -> asks for signed integers [+1] void (*foo)(int); Pthread_t foo; [+1] Float foo = 3.14; float foo = 3.14f; Int foo[2]; [+1] Struct { Char c; Int i; } foo; CSSE2310 2021 SEM2 exam answers UQAttic.net 13,456 – SEGFAULT [+1] 20,000 – 183,840 [+1] 60,000 – UNKNOWN [+1] 206,495 – 23,107,231 [+1] CSSE2310 2021 SEM2 exam answers UQAttic.net 2^43 Bytes = 2^13 GiB Entries per page = 8KiB/8 = 1KiB = 1024 Bytes 3rd level size = 1024 * 8KiB = 8192KiB = 8MiB 2nd level size = 1024 * 8MiB = 8192MiB = 8GiB Num 3rd level page = 1000MiB/8MiB = 125 pages Total mem = (1 + 1 + 125) * 8KiB = 1016KiB Num 3rd level page = 10,000MiB/8MiB = 1250 pages Now need at least 2 2nd level pages to store references Total mem = (1 + 2 + 1250) * 8KiB = 10024KiB Page table size = (1 + 1 + 2 + 125 + 1125) * 8KiB = 10 032 KiB Top Level Table: 2^20 entries * 8 bytes per entry = 2^23 bytes = 8 MiB = 8192 KiB 8192KiB + 125 * 8KiB = 9192 KiB (+1) 2^30 entries * 8 bytes each = 2^20 * 2^10 * 2^3 bytes = 8192 MiB (+1) Explanation please Exam consultation 2 covers a similar example but; CSSE2310 2021 SEM2 exam answers UQAttic.net – For 9f – Consider the visual address, and how there are a total of 43 bits, with 13 being used for offset. If only a single level exists, that means that there exists only one block with a total of 30 bits assigned by the visual address to that one block. – So, the one first level block contains 2^30 entries – Each entry is 8 bytes, so 2^30 * 8 = 2^33 bytes = 2^13 MiB = 8192MiB – For 9e – From previous questions, we know that each level contains 10 bits for a 3-level visual address in this example, so it would have been | 10 bits | 10 bits | 10 bits | 13 bits offset | With the change from 3 levels to two, the remaining bits after the 2nd level become part of the first, so it becomes | 20 bits | 10 bits | 13 bits offset | – The size of the first level page is equal to the number of entries * entry size = 2^20 * 8 And the size of the 2nd level entries are 8KiB each – We also know the number of second level entries from before, which was 125 (just do address range (1,000 MiB) / page size (8 KiB)). Find size of second level with num entries * page size = 125 * 8KiB CSSE2310 2021 SEM2 exam answers UQAttic.net 6 (+1) – I got 5 (nevermind, got 6 now…below diagram is incorrect at point G) 5 (+1) CSSE2310 2021 SEM2 exam answers UQAttic.net 4 (+1) 17 (+1) 31 (+1) x CSSE2310 2021 SEM2 exam answers UQAttic.net Network A: Lowest address – 34.15.160.1 = 34.15.160.0000 0001 Highest address – 34.15.160.128 = 34.15.160.1000 0000 CIDR = Netmask = Broadcast = Network B: Lowest address – 34.15.160.1 = 34.15.160.0000 0001 Highest address – 34.15.160.128 = 34.15.160.1000 0000 2^4 – 3 = 13 (CIDR is /28 , so 32 – 28 = 4 bits for ports. 2^4 = 16. 3 already in use by the network, so 16 – 3 = 13 total remaining addresses. Would be good to get some confirmation on this) /28 -> 16 addresses, 4 in use, 2 reserved, therefore 10 unused addresses. (6 + (2^10 * 4) + (2^20 * 2)) * 32KiB = 67,240,128 KiB Thought it would be 32KiB/8 bytes = 4096 pointers per block (6 + (4096 * 4) + ((4096^2) * 2)) * 32KiB = 1,074,266,304 KiB[+4] (6 + 4096 *4) * 32 = 524480 KiB [+1] CSSE2310 2021 SEM2 exam answers UQAttic.net 4 -> 3 for block reads at file, 1 for single indirect at block 6 4 – don’t get the above explanation, but the memory starts in direct pointer 4, uses 5 and 6, and then uses the first pointer in the first single indirect, for a total of 4 blocks. Inode Permissions Owner Timestamp Block pointers (12 total for this question) Meta Data Size Can store data in block pointer section of inode such that, 12 pointers * 8 bytes per pointer = 96 bytes total storage [+1] Assumption: that there is a way to mark an iNode as containing binary data and not a pointer to a block, as otherwise the kernel may attempt to use binary data as a block address/index. ^^ This was a guess unsure if it’s right CSSE2310 2021 SEM2 exam answers UQAttic.net Chmod g-r exam (unsure) Chmod g-rx (I think get access to file inside a dic means interacting with the dic, which needs x (I tried on moss: without x, I cannot cd into the dic [+1] Chmod o+x resources (unsure) Chmod o+r resource chmod g-r resource(tested on moss, [ls] is related to r 4 6 minus link between itself and “.” [+1] 0, link still exists with file results[+1] Alice, bob ->permissions are given to all with r, x for user, group and other, so i’d assume anyone can use this transaction CSSE2310 2021 SEM2 exam answers UQAttic.net alice, bob, dave, eve, fred anyone not part of course as far as i can tell as well as alice (the user) Alice, dave, eve fred Bob, dave, fred, eve Bob, carol, dave, eve CSSE2310 2021 SEM2 exam answers UQAttic.net Q10) CSSE2310 2021 SEM2 exam answers UQAttic.net 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 int main(int argc, char* argv[]) { 9 int infile = open(argv[1], O_RDONLY); 10 int fd[2]; 11 pipe(fd); 12 dup2(fd[1], STDOUT_FILENO); 13 dup2(infile, STDIN_FILENO); 14 pid_t pid; 15 16 if (pid = fork()) { 17 close(fd[1]); 18 } else { 19 // child 20 execlp(argv[3], argv[3], NULL); 21 } 22 23 int outfile = open(argv[2], O_WRONLY);n 24 dup2(fd[0], STDIN_FILENO); 25 dup2(outfile, STDOUT_FILENO); 26 execvp(argv[4], argv + 4); 27 return 0; 28 } Seems to work but maybe not the best way…. I wonder if its ok to just exec /bin/bash lmao MakeFile CC=gcc CFLAGS=-Wall -pedantic -std=gnu99 .PHONY:=clean all: execpipe #Generate executable by linking object files CSSE2310 2021 SEM2 exam answers UQAttic.net execpipe: execpipe.c $(CC) $(CFLAGS) execpipe.c -o execpipe clean: rm -f *.o rm -f execpipe