Prentice hall 2000 82 j f wakerly digital design

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rtup routine, which returns control to the operating system by calling exit. The same behavior occurs if the user omits the return statement. If main terminates with a call to exit, then exit eventually returns control to the operating system by calling exit. The net effect is the same in all three cases: when main has finished, control passes back to the operating system. B.8 Exceptional Control Flow Problem 8.1 Solution: [Pg. 408] In our example program in Figure 8.13, the parent and child execute disjoint sets of instructions. However, in this program, the parent and child execute non-disjoint sets of instructions, which is possible because the parent and child have identical code segments. This can be a difficult conceptual hurdle. So be sure you understand the solution to this problem. A. What is the output of the child process? The key idea here is that the child executes both printf statements. After the fork returns, it executes the printf in line 8. Then it falls out of the if statement and executes the printf in line 9. Here is the output produced by the child: printf1: x=2 printf2: x=1 B. What is the output of the parent process? The parent executes only the printf in line 9: printf2: x=0 Problem 8.2 Solution: [Pg. 408] This program has the same process hierarchy as the program in Figure...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online