xiv Contents 8 Exceptional Control Flow 721 8.1 Exceptions 723 8.1.1 Exception Handling 724 8.1.2 Classes of Exceptions 726 8.1.3 Exceptions in Linux/x86-64 Systems 729 8.2 Processes 732 8.2.1 Logical Controt Flow 732 8.2.2 Concurrent Flows 733 8.2.3 Private Address Space 734 8.2.4 User and Kernel Modes 734 8.2.5 Context Switches 736 83 System Call Error Handling 737 8.4 Process Control 738 8.4.1 Obtaining Process IDs 739 8.4.2 Creating and Terminating Processes 739 8.4.3 Reaping Child Processes 743 8.4.4 Putting Processes to Sleep 749 8.4.5 Loading and Running Programs 750 8.4.6 Using fork and execve to Run Programs 753 8.5 Signals 756 8.5.1 Signal Terminology 758 8.5.2 Sending Signals 759 8.5.3 Receiving Signals 762 8.5.4 Blocking and Unblocking Signals 764 8.5.5 Writing Signal Handlers 766 9 8.5.6 Synchronizing Flows to Avoid Nasty.Concurrency Bugs 776 8.5.7 Explicitly Waiting for Signals 778 8.6 Nonlocal Jumps 781 8.7 Tools for Manipulating Processes 786 8.8 Summary 787 Bibliographic Notes 787 Homework Problems 788 Solutions to Practice Problems 795 9 Virtual Memory 801 9.1 Physical and Virtual Addressing 803 9.2 Address Spaces 804xiv Contents 8 Exceptional Control Flow" 721 8.1 8.2 8:3 8.4 8.5 8.6 8.7 8.8 9 Exceptions 723 8.1.1 Exception Handling 724 8.1.2 Classes of Exceptions 726 8.1.3 Exceptions in Linux/x86-64 Systems Processes 732 8·.2.1 Logical ControfFlow 732 8.2.2 Concurrent Flows 733 8.2.3 Private Address Space 734 8.2.4 User and Kernel Modes 734 8.2.5 Context Switches 736 System Call Error Handling 737 Process Control 738 8.4.1 Obtaining Process IDs 739 729 8.4.2 Creating and Terminating Processes 739 8.4.3 Reaping Child Processes 743 8.4.4 Putting Processes to Sleep 749 , 8.4.5 Loading and Running Programs 750 8.4.6 Using fork and execve to Run Programs 753 Signals 756 8.5.1 Signal Terminology 758 8.5.2 Sending Signals 759 8.5.3 Receiving Signals 762 8.5.4 Blocking and Unblocking Signals 764 8.5.5 Writing Signal Handlers 766 11 8.5.6 Synchronizing Flows to Avoid Nasty. Concurrency Bugs 8.5.7 Explicitly Waiting fat Signals 778 Nonlocal Jumps 781 Tools for Manipula\ing Processes. 786 Summary 787 , Bibliographic Notes 787 Homework Problems 788 Solutions to Practice Problems 795 Virtual Memory 801 9.1 Physical and Virtual Addressing 8Q3 9.2 Address Spaces 804 776