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


CSDS 338 Intro to OS and Concurrent Programming

Explain 3


Here is your explain 3 assignment. First, let me make it clear. This assignment requires a lot of thinkings and reasoning. When I made it, I intended to make it sufficiently hard but is also fairly easy. Even though a sufficient answer to some questions would be only a few sentences, there will be a trick that makes you struggle a lot. As soon as you figured out the trick, the whole question would be simple and straightforward. This assignment will be due on the last day of instruction.

Some questions were originally prepared for your midterm, but Prof. Loui stopped me, then these questions became your third explain assignment. The purpose of this assignment is to explore the world of operating systems a little bit deeper than lecture, but you should be able to resolve these problems based on our in-class discussions. We recognized that most questions in this assignment would be significantly harder than any previous, so the weight of this assignment in your overall final grade would be lighter. So don’t worry too much if you screwed up this assignment.

Collaboration is welcomed, but please bring your original thoughts to your submission, even it might be wrong. This means you may discuss with others or use references, but you must not use others’ ideas directly, even been properly cited. For example, in explain 2, some of you used the Microsoft advice for question 6, but it will bring you 0 points if you do the same here.

If you have any questions about this assignment, including clarifications, please post a question on Piazza (preferred, so I won’t miss it, and everyone can see it), or email your graduate TA (yxg604).

We do expect an average of this assignment to be around 60%, if you carefully answered all questions with your original ideas and completely followed the instruction.

Multiple bonuses could be considered if you make your response nice, neat, and clean. A bonus could be given at the grader’s discretion. However, such a bonus must not exceed 20% of your assignment raw grade.

Question 6 is a added optional question. You are NOT required to do this question. If you do it, you will received credit on anything you made it correct. You will not be penalized if for no attempt or any unsuccessful attempts.


1 (1 pt) The growth of stack

In most cases, recursive calls and loops, either for or while, can be translated into the other form. Some translations could be hard, while some others might be easy. Recall the functionality and purpose of the segmentation protection mechanism people deployed in a modern operating system. When doing some com-plicated programming work using the object-oriented programming practice in C involving multi-threading, Dr. C falls into some interesting segmentation faults where she/he/they cannot locate any part of the code to blame on. We learned that Dr. C encountered this segmentation fault in some recursion function. The recursion shall not stop until some magic condition was triggered. However, we do not have the prior knowledge which tells where the magic will happen or if it even exists.

You are now hired by Dr. C as her/his/their research assistant, and you were assigned to fix this fault. What would you do? Justify your answer. (Hint: think about the differences between loop and recursion.)


2 (1.5 pts) The Julia language

You might claim Python is the best language in the world, and some might even claim it for PHP. But now, let’s talk about Julia. We know that Julia is a run-time compiled language, which means Julia com-piler will compile the script right before being executed (https://en.wikipedia.org/wiki/Just-in-time_compilation). Besides being a compiling language making it fast, Julia is also a powerful language that can utilize any given C library without additional operations. If an external library is loaded, it can have the library memorize some value for future computation. However, even though the Julia community is developing the global variable support for Julia, the current version does not allow programmers to declare global variables and refer across files (I don’t think the keyword “global” serves this purpose).

Given the above-stated background, answer all the following questions, using your operating system knowl-edge, and justify your answer.


2.1 (0.25 pts)

Assume we have the following program, as shown in listing 1, and have it executed as shown below in listing 2 with the result as shown in 3, explain what happened from clicking the enter button until you got the desired result.


2.2 (0.5 pts)

Provide one potential implementation for Julia to maintain variables in the external library.


2.3 (0.75 pts)

Provide one alternative design to use global variables in Julia.


3 (0.5 pt) Everything in Unix are file

Everything is a file is one of those essential design philosophies people are looking at when designing the Unix(-like) family operating systems. In other words, files we usually think of are files, but devices are files, sockets are files, processes are files, and everything are files. Please explain why IO, devices, sockets, and all such things can work like a file. Provide one abstractive design and justify.


4 (1 pts) Talkative processes

In many cases, processes need to talk to each other. In Linux practice, we call it Inter-Process Communication (IPC). IPC has many different approaches, and each of them has its specialty. Signal is one of the most commonly used and observed IPC mechanisms. Signal 11, SIGSEGV, a.k.a. Segmentation Fault, is the most commonly seen signal in system programming. We need a signal handler to service the signal, and many signals, by default, print a message and have the program quit. In kernel, a small piece of code will do some magic so that the process can immediately serve the signal when it was put back into the CPU and eventually continue after it if needed. Another common IPC model is for the kernel to maintain a buffer, where it can temporarily store the message inside the kernel space following a send() call, and pass the message to the destination process when the target called a recv(). Of course, the kernel might do different things based on the situation observed and requested. For example, when necessary, the kernel can hold a process in the block queue if the receiver or originator is not ready to read or write the message.

Based on the above information, answer the following questions. For each, please briefly justify.


4.1 (0.6 pts)

Using plain English, describe one possible implementation of the magic which have the process to serve the signal. You are NOT required to provide a detailed and specific register name, but a bonus will be given if you can correctly recognize and name it. If you find it helps, you may also draw a graph to explain your answer.


4.2 (0.4 pts)

Similar to multi-threading synchronization, the racing condition may also occur in buffered mode IPC. Please recognize one situation where such racing may occur and provide one possible solution.


5 (0.5 pt) The Segmentation Fault

I heard many programmers say they hate signal 11, which is the segmentation fault. Segmentation fault usually happens when the code attempts to access a memory location that is not accessible to the requesting process. Assume we have a specially designed operating system running on a toy computer with no such segmentation protection mechanism. Compare our toy and a modern OS which has a segmentation fault, discuss how these two systems might behave differently and their consequences. Which design do you think is better? Please justify your answer and provide TWO examples.


6 (0.5 pts) (Optional) Learning on a cluster of machines

Currently we have different machenism to perform federate learning. Assume you are now working on a machine learning task, which is too big for any computer to do on itselves. However, you do not have any prior knowledge about federated learning, but you still want to utilize several computers to do this job. If you are only allowed to use operating system knowledge, are you able to do this task? If yes, how? What challanges you are expected to face by doing this? How would you resolve them? By doing this what are the advantages and disadvantages? Please explain and justify your answer.


7 (0.5 pt) It is almost the end

This is almost the end of this assignment, and it is also reaching the end of the semester. We do sincerely thank all of you for your cooperation and for helping us to improve your learning experience. In this section, we kindly ask you to share your thought and feelings regarding your experience throughout the semester. We appreciate any criticism, comment, and suggestions you provide here, so we know where we can make it better in the future. If you would like and able to, please also go to the university evaluation system to submit your comments to the university.

Please DO NOT include your response to this section in the pdf. Instead, please use https://forms.gle/H3g96wffYmgS3SLr6 to complete a Google Form. When making this form, we asked Google to NOT record your email address. It is entirely anonymous, and no one can know which submission you made. To get this point, please provide a screenshot that shows you have submitted the form.

At the end of the semester, once again, thank you for choosing course 338. Good luck with your exams, enjoy your winter break, happy holiday season, and please stay healthy. If this is your final semester, congratulations on your graduation!