quiz1 solution

Quiz1 solution - ID 103 P1 ID100 C1 ID104 P2 ID102 C2 ID105 P3 ID101 C3 ID106 P4 ID103 C4 ID107 Figure Fork Result Consequently the print result

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Solution for Quiz1 System call fork() is used to create processes. It takes no arguments and returns a process ID. The purpose of fork() is to create a new process, which becomes the child process of the caller. After a new child process is created, both processes will execute the next instruction following the fork() system call. If fork() returns a negative value, the creation of a child process was unsuccessful. fork() returns a zero to the newly created child process. fork() returns a positive value, the process ID of the child process, to the parent. Since we assume all fork calls are successful. The last two cases applied. Initial Process ID: 100 Parent ID:100 root Parent ID: 100 Child ID: 101 Parent2 ID: 101 Child1 ID: 102 Parent1 ID: 100 Child2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ID: 103 P1 ID100 C1 ID104 P2 ID102 C2 ID105 P3 ID101 C3 ID106 P4 ID103 C4 ID107 Figure: Fork Result Consequently, the print result would be: A: 101, 0, 0 Tier1: Parent A: 0, 0, 0 Tier1: Child B: 101, 0, 0 Tier2: Parent1 B: 101, 102, 0 Tier2: Child1 B: 0, 0, 0 Tier2: Parent2 B: 0, 103, 0 Tier2: Child2 C: 101, 102, 104 Tier3: Parent1 C: 101, 102, 0 Tier3: Child1 C: 101, 0, 105 Tier3: Parent2 C: 101, 0, 0 Tier3: Child2 C: 0, 103, 106 Tier3: Parent3 C: 0, 103, 0 Tier3: Child3 C: 0, 0, 107 Tier4: Parent4 C: 0, 0, 0 Tier4: Child4 Notice: Since processes maybe execute randomly, and the process id is also assigned randomly, so above is not the only right answer. However, your answer will be graded using the principle described above....
View Full Document

This test prep was uploaded on 04/18/2008 for the course CS 4323 taught by Professor Dr.li during the Fall '07 term at Oklahoma State.

Page1 / 2

Quiz1 solution - ID 103 P1 ID100 C1 ID104 P2 ID102 C2 ID105 P3 ID101 C3 ID106 P4 ID103 C4 ID107 Figure Fork Result Consequently the print result

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online