这是一篇来自加拿大的关于运用CS341技能和知识方面能力解决以下3个问题的CS考试代写
Part 1 of 3 (100 points, video, 60 minutes) “My First Office Hours”
“Don’t Panic… Sorry!” a familiar English voice announces, “I’m just adjusting … Aha! Right!”
The world shifts into full view. Sensations of touch, smell, and sound flood your mind. You are in Siebel and a light breeze against your face awakens you out of a dreamy slumber. There’s some tables, a whiteboard, bookcase and chairs. The sensations feel real except the scene is clearly fake the words “History Simulation Test (bug fix 58)” scroll in and blinks slowly in orange and blue letters in the bottom left corner of your vision in Courier New font, confirming that none of this is actually real. Yet the perceptual sensations feel more tangible than the breakfast you had earlier, and definitely more meaningful. A sense of spreading future connections overwhelms you (like a 400-level course on graph theory where the expanding nodes and edges escaped from the paper and leapt into the wild) – connections to people, events, world issues– future interviews, people, conversations, all the things that will help you change the world but have not yet happened but will happen in your future. You take a deep breathe to relax.
“Okay,” the friendly voice continues, “I set the year back to 2023 – which explains the odd fashion choices you’re about to see! In about 1 minute your office hours will start and the first student will walk in. This first test is about whether you can explain to a student some CS 341 – topics, to demonstrate that you actually understand these topics and can be a valuable member of the course staff. So be ready to do some live programming demos, explain the concepts, … whatever you need to help the student thrive in this class.”
“We’re not sure how students learned back in 2023 but the computational-socio-geologists believe they were a social bunch who enjoyed talking and explaining things to each other; they were a strong community of over 2000 that wanted a meaningful life by changing the world and by their connections with each other. Don’t forget to pay it forward!”
Record your 2023 office hour video. Here are the 10 things the CS341 students ask. You might want cross them off as you complete them, or record them as separate videos. We recommend a screen cast with voice recording; the point is for you to explain something and in doing so, demonstrate your own understanding and competency in system programming. Students walk in. They ask the following,
- Why can’t I do strcat(“Hello”,”World”) to create a string with the two strings added together and what can I do instead?
- What’s the difference between malloc(1000) and calloc(1,1000)?
- For the malloc MP my simple malloc is working but it is slow and also uses too much memory.
Can you give me two suggestions on how I could improve it?
- I’ve heard of fork-exec-wait. Can you write and run some code to explain what is going on in each step?
- My program uses 5 FIFO queues. For performance and thread-safety each has its own mutex lock.
But it deadlocks when I lock them to move items between queues. Why and how can I fix it?
- Can you show me an example that creates and uses pthread_barrier that waits for 2 threads to complete before continuing?
- I understand single level page table, can you help me understand 2-level page tables?
- What is the purpose of HTTP’s “KEEP-ALIVE” header; What problem does it help solve?
- If you wanted to speed up a program when would you prefer multiple threads? When would multiple processes be better?
- What’s the purpose of listen and accept system calls?
We expect you will want to record a video of your laptop screen with audio and use a text editor as a whiteboard, but you could also record using your phone. However any method of recording will be acceptable (e.g. phone pointed at piece of paper). We are looking for demonstrations of system programming understanding and competency by you (i.e. things that a CS225 student would not be able to explain but a CS341 student can), such that your office hour is effective and useful. Your spoken words need to be your own words, explanations, ideas and thoughts; reading aloud a Google search result or the course book is not sufficient evidence of your understanding.
You can record multiple parts of a video if you need a break. However don’t worry about fluffs, mistakes and restarts; imagine this was a real office hours – just say oops and carry on! We expect most students will create approximately 30- 60(max) minutes of content. We will only grade the first 60 minutes of video content; which means you have average of 6 minutes per item.
There are multiple methods to record a laptop screen to a mp4 file or to the cloud. Protip: Do a test recording first and review it instead of assuming that it is working; verify your audio and the text is large enough and legible enough to be gradeable check that it is a recording of your screen not your laptop camera! Ultimately you will be sharing the mp4/mov file or providing a URL to your cloud recording; verify that the link works when not logged in as you. Also, mediaspace.illinois.edu may be another useful way to record and share your video (login then click on your own name to get to your Media items).
Grading Rubric (Outline):
0 missing
5 mostly incomplete or misleading or inaccurate
7 mostly correct but a major error – not fully competent
9 mostly helpful for the student; some minor errors
10 helpful; no errors
Part 2 of 3 (100 points, code, 60 minutes) “Nuke from orbit it’s the only way to be sure”
You are working on a tiny Linux environment that will be embedded inside some smart clothes. There’s no disk space for the Linux tools, but today you need to be able to check the running processes and sometimes pause a process. You compile your program pslist.c on a CS341 VM using the following-clang -O0 -Wall -Wextra -g -std=c99 -D_GNU_SOURCE -DDEBUG pslist.c -o pslist
Your program will print out all process numbers found in /proc and, if available, the command line of each process (using fgetc and putc and the contents of /proc/nnn/cmdline). Do not print out anything for the other (non-integer) filenames in /proc. After printing, allow the user to enter one number. Before exiting, if the user input can be parsed as positive integer, send a SIGSTOP to that process. Example use-
$ sleep 50&
$ ./pslist
1 /sbin/init splash
2
(many other lines printed)
405736 sshd: angrave@pts/1
405738
406093 sleep 50
406095 ./pslist
User enters 406093 and presses return
Stopping process 406093
If this signal fails, print the system error message using perror. Example output for different inputs –
Stopping process 999999
SIGSTOP: No such process
Stopping process 1
SIGSTOP: Operation not permitted
Include your netid as a comment to the top of your code, e.g., if your netid is angrave, write
// author: angrave
Rubric, subject to minor modifications:
Source code includes netid author code comment
Prints out process numbers using directory entries listed in /proc
Prints process numbers only; ignores non-integer directory entries in /proc
Prints the command line of each process (if available)
Uses fgetc and putc to print each process’s original command line.
Command line is printed with ASCII nul (\0) characters printed as spaces.
Waits for the user to enter an integer
If the user enters a positive integer, it attempts to send a SIGSTOP to that process.
If this is unsuccessful it prints out an error message to explain why.
Releases dynamic resources requested (file descriptors and memory) as soon as possible.
The following may be useful: opendir,perror,fopen,fgetc,putc,scanf,sscanf,(a)(s)printf,
*Grading: All other behaviors, output, handling missing arguments, files, error conditions etc are unspecified and are not graded; do not ask about them. If unsure, write code comments about your assumptions and then answer accordingly. Allowed sources: You may review your own prior work, use man pages, CS341 course content and stackoverflow.com – cite your sources (URLs) – but you must type new code. The code you submit must represent your competency and skills; you may not seek or use solutions from the Internet or from other students.
Part 3 of 3 (100 points, code, 60 minutes) “My UDP File server”
Your smart clothing was a huge success; but you need a way to get some tiny files in the current directory out of your server using UDP because TCP traffic is blocked.
The client code is already written (see the next page). You start your server and pass in the UDP port and a hard-to-guess super-secret secret on the command line…
clang -pthread -O0 -Wall -Wextra -g -std=c99 -D_GNU_SOURCE -DDEBUG server.c -o serv
./serv 9000 SolarWinds123
Your server will wait and process UDP requests in the form secret:filepath. A valid example is SolarWinds123:server.c. This would send the first 800 bytes (or the filesize, whichever is smaller) of the requested file as a single UDP packet back to the client. If the filepath cannot be opened or the password is incorrect do not send any response. If the file is greater than 800 bytes only send the first 800 bytes of the file.
Create a new pthread to process each server request. Be sure to free up file handles and heap memory, so that server can complete hundreds of requests. A bad request (e.g. a file that cannot be opened) must not prevent other future requests from succeeding.
Append to a file “log.txt”(one per line) the requested filepath of files that were successfully accessed.
However if the filepath is rickroll close the log filehandle then exit the process using SIGQUIT signal.
The following may be useful, to send UDP packets back to the original client.
struct sockaddr_storage source;
socklen_t source_len = sizeof(source);
recvfrom(… 0,(struct sockaddr*)&source,&source_len);
sendto(… 0, (struct sockaddr*) &source, source_len);
You may refer to and copy-paste code from stackoverflow.com, man pages, CS341 course materials and your own previously written code. You must cite your sources/(URLs) for any code that you used that you did not specifically write for this final.