Homework2 Process

  1. Assume you are calling fork in one thread of a multi-thread process in Linux. How many threads will there be in the child process? What problem may exist in the forked child process? Why Linux have to design fork operation of a multi-thread process like that?
  2. vfork is a system call similar to fork. Use man vfork to learn more about vfork. Why does vfork perform better than fork in applications consuming a huge amount of memory even when fork already applied the COW policy for memory copying? Try to optimize the performance of fork for such applications without compromising its semantic refers to the idea of vfork.
  3. In an operating system where a single process contains multiple threads like ChCore, a context switch is usually done at the granularity of thread. However, context switch between threads belonging to the same process can be faster than that between threads belonging to different processes. Why?
  4. In ChCore, the page table mapping has been changed during the context switch. However, after the page table changed, the ChCore kernel, which also uses virtual memory address in its code, can still run correctly and get the correct address of its variables and codes. Why?
  5. For user-level threads like coroutine, since all coroutines belong to the same thread, only one coroutine can be running at the same time. How can coroutine benefit the performance with the same amount of computing resources? What kind of applications can benefit from coroutine most?
  6. Now, Assume you are going to create an operating system specialized for the scenario where only one single web server application is running in the OS. The web server requires: 1) Low waiting and processing latency for every user request. 2) Code handling requests from different users can not access each other's memory. How are you going to design the semantic of process/thread in your OS and the program logic of the web server? What should be stored in PCB/TCB, and how is context switch done in your OS?

Please submit your answers on the OC platiform before 2020.04.08 23:59.