Commit c19e36e

mo khan <mo@mokhan.ca>
2021-04-18 21:31:19
Answer question with a bunch of words
1 parent 911e80d
Changed files (1)
doc/assignment3.md
@@ -79,6 +79,68 @@ Your answer for each question should be about 150 words. (100 marks total)
 1. Explain the distinction between a demand-paging system and a paging system with swapping. (8 marks)
 1. How does the second-chance algorithm for page replacement differ from the FIFO page replacement algorithm? (8 marks)
 1. Explain how copy-on-write operates. (8 marks)
+
+> Process creation using the `fork()` system call may initially bypass the need
+> for demand paging by using a technique similar to page sharing. This
+> technique provides for rapid process creation and minimizes the number of new
+> pages that must be allocated to the newly created process.
+
+```plaintext
+   process1        memory        process2
+  ----------     |--------|     ----------
+  |        |     |        |     |        |
+  |--------|     |--------|     |--------|
+  |        |---> | page A | <---|        |
+  |--------|     |--------|     |--------|
+  |        |---> | page B | <---|        |
+  |--------|     |--------|     |--------|
+  |        |---> | page C | <---|        |
+  |--------|     |--------|     |--------|
+  |        |     |        |     |        |
+  |        |     |        |     |        |
+  |        |     |        |     |        |
+  ----------     |--------|     ----------
+
+   process1        memory        process2
+  ----------     |--------|     ----------
+  |        |     |        |     |        |
+  |--------|     |--------|     |--------|
+  |        |---> | page A | <---|        |
+  |--------|     |--------|     |--------|
+  |        |---> | page B | <---|        |
+  |--------|     |--------|     |--------|
+  |        |---| | page C | <---|        |
+  |--------|   | |--------|     |--------|
+  |        |   | |--------|     |        |
+  |        |   ->| page C1|     |        |
+  |        |     |--------|     |        |
+  ----------     |--------|     ----------
+```
+
+> Recall that the `fork()` system call creates a child process that is a duplicate
+> of its parent. Traditionally, `fork()` worked by creating a copy of the parent's
+> address space for the child, duplicating the pages belonging to the parent.
+> However, considering that many child processes invoke the `exec()` system call
+> immediately after creation, the copying of the parent's address space may be
+> unnecessary. Instead, we can use a technique known as `copy-on-write`, which
+> works by allowing the parent and child processes initially to share the same
+> pages. These shared pages are marked as copy-on-write pages, meaning that if
+> either process writes to a shared page, a copy of the shared page is created.
+
+> For example, assume that the child process attempts to modify a page containing
+> portions of the stack, with the pages set to be copy-on-write. The operating
+> system will create a copy of this page, mapping it to the address space of the
+> child process. The child process will then modify its copied page and not the
+> page belonging to the parent process. Obviously, when the copy-on-write
+> technique is used, only the pages that are modified by either process are
+> copied; all unmodified pages can be shared by the parent and child processes.
+
+> Note, too, that only pages that can be modified need be marked as
+> copy-on-write. Pages that cannot be modified (pages containing executable
+> code) can be shared by the parent and child. Copy-on-write is a common
+> technique used in several operating systems, including Windows XP, Linux, and
+> Solaris.
+
 1. If you were creating an operating system to handle files, what are the six basic file operations that you should implement? (8 marks)
 1. To create a new file, an application program calls on the logical file system. Describe the steps the logical file system takes to create a file. (8 marks)
 1. How is a hash table superior to a simple linear list structure? What issue must be handled by hash table implementation? (8 marks)