{"action":"opened","issue":{"url":"https://api.github.com/repos/SystemProgrammingatNTU/SP16Issues/issues/21","repository_url":"https://api.github.com/repos/SystemProgrammingatNTU/SP16Issues","labels_url":"https://api.github.com/repos/SystemProgrammingatNTU/SP16Issues/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/SystemProgrammingatNTU/SP16Issues/issues/21/comments","events_url":"https://api.github.com/repos/SystemProgrammingatNTU/SP16Issues/issues/21/events","html_url":"https://github.com/SystemProgrammingatNTU/SP16Issues/issues/21","id":197653121,"number":21,"title":"Quiz 5 solutions","user":{"login":"cchao","id":2056471,"avatar_url":"https://avatars.githubusercontent.com/u/2056471?v=3","gravatar_id":"","url":"https://api.github.com/users/cchao","html_url":"https://github.com/cchao","followers_url":"https://api.github.com/users/cchao/followers","following_url":"https://api.github.com/users/cchao/following{/other_user}","gists_url":"https://api.github.com/users/cchao/gists{/gist_id}","starred_url":"https://api.github.com/users/cchao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cchao/subscriptions","organizations_url":"https://api.github.com/users/cchao/orgs","repos_url":"https://api.github.com/users/cchao/repos","events_url":"https://api.github.com/users/cchao/events{/privacy}","received_events_url":"https://api.github.com/users/cchao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-27T06:21:16Z","updated_at":"2016-12-27T06:21:16Z","closed_at":null,"body":"## Problem 1\r\nWhat are zombie processes? Will the following process create any zombie process? Why?\r\n\r\n```c\r\n#include <unistd.h>\r\nint main() {\r\n  if (fork()) sleep(100);\r\n  return 0;\r\n}\r\n```\r\n\r\n1. See [8.5 in the textbook](https://books.google.com.tw/books?id=kCTMFpEcIOwC&pg=PA237&dq=UNIX+System+terminology,+a+process+that+has+terminated,+but+whose+parent+has+not+yet+waited+for+it,+is+called+a+zombie.&hl=zh-TW&sa=X&ved=0ahUKEwji-P3S3JPRAhWOq5QKHUwFCooQ6AEIGjAA#v=onepage&q=UNIX%20System%20terminology%2C%20a%20process%20that%20has%20terminated%2C%20but%20whose%20parent%20has%20not%20yet%20waited%20for%20it%2C%20is%20called%20a%20zombie.&f=false)\r\n\r\n2. Yes. By the definition of zombie process, the child process will not be waited by the parent process while the parent process is sleeping.\r\n\r\n* Many people confuse zombies with [orphans](https://en.wikipedia.org/wiki/Orphan_process).\r\n* You can do an experiment on the workstations.\r\n\r\n## Problem 2\r\nA `fork()` is often followed by an `exec()`. Modern implementation of `fork()` usually uses a technique called\r\ncopy-on-write (COW). Please explain what is COW and its advantages.\r\n\r\nSee [8.3 in the textbook](https://books.google.com.tw/books?id=kCTMFpEcIOwC&pg=PA229&dq=Modern+implementations+don%E2%80%99t+perform+a+complete+copy+of+the+parent%E2%80%99s+data,+stack,+and+heap,+since+a+fork+is+often+followed+by+an+exec.+Instead,+a+technique+called+copy-on-write+(COW)+is+used.&hl=zh-TW&sa=X&redir_esc=y#v=onepage&q=Modern%20implementations%20don%E2%80%99t%20perform%20a%20complete%20copy%20of%20the%20parent%E2%80%99s%20data%2C%20stack%2C%20and%20heap%2C%20since%20a%20fork%20is%20often%20followed%20by%20an%20exec.%20Instead%2C%20a%20technique%20called%20copy-on-write%20(COW)%20is%20used.&f=false)"}}
{"actor":{"display_login":"cchao"}}