ThomsonTang / techbook.thomsontang.com

output the card notes from technical books.
0 stars 0 forks source link

Exceptional Control Flow: Exceptions and Processes #5

Open ThomsonTang opened 7 years ago

ThomsonTang commented 7 years ago

Exception Control Flow

Control Flow

Processors do only one thing:

  • From startup to shutdown, a CPU simply reads and executes(interprets) a sequence of instructions, one at a time.
  • This sequence is the CPU’s control flow (or flow of control)

image

Altering the Control Flow

There are tow mechanisms for changing control flow, both react to changes in Program state:

But this is insufficient for a useful system, it’s difficult to react to changes in System state:

System needs mechanisms for “exceptional control flow”

Exceptional Control Flow

Exceptions

image

Exception Handing

Exceptions can be difficult to understand because handing then involves close cooperation between hardware and software.

image

Classes of Exceptions

Exception can be divided into four classes: interrupts, traps, faults, and aborts.

Asynchronous Exceptions (Interrupts)

Synchronous Exceptions

ThomsonTang commented 7 years ago

Processes

Definition

When we run a program on a modern system, we are presented with the illusion that our program is the only one currently running in the system. Our program appears to have exclusive use of both the processor and the memory. The processor appears to execute the instructions in our program, one after the other, without interruption. Finally, the code and data of our program appear to be the only objects in the system’s memory. These illusions are provided to us by the notion of a process.

A process is an instance of a running program.

Process provides each program with two key abstractions:

How are these illusions maintained?

Concurrent Processes

A logical flow whose execution overlaps in time with another flow is called a concurrent flow, and the two flows are said to run concurrently. The general phenomenon of multiple flows executing concurrently is know as concurrency. The notation of a process taking turns with other processes is also known as multitasking. Each time period that a process executes a portion of its flow is called a time slice. Thus, multitasking is also referred to as time slicing.

User View of Concurrent Processes

Private Address Space

A process provides each program with its own private address space. This space is private in the sense that a byte of memory associated with a particular address in the space cannot in general be read or written by any other process.

Although the contents of the memory associated with each private address space is different in general, each such space has the same general organization.

image

Context Switching