The 11th week summary of the Design foundation of information security system

Source: Internet
Author: User

Eighth. Abnormal control Flow

Starting from power-up to the processor, the program counter assumes a sequence of values of A0,A1,... A (n-1), where each a (k) is the address of a corresponding instruction I (k), and each transition from a (k) to a (k+1) is called control transfer ; such a control transfer sequence is called the control flow of the processor.

Modern systems react to these situations by causing mutations in the control flow. In general, we refer to these mutations as abnormal control flows . Exception control flow occurs at all levels of the computer system

8.1 Exceptions

Exceptions are a form of exception control flow that is implemented by hardware and the operating system

An exception is a mutation in the control flow that responds to certain changes in the processor state

State changes are called events, and events are not necessarily related to the execution of the current instruction

When the processor detects that an event occurs, he makes an indirect procedure call (exception) through a jump table called an exception table , to an operating system subroutine ( exception handler ) specifically designed to handle such events.

(2) Category of exception: Interrupt, Trap, fault, abort

    • Interrupts: Interrupts occur asynchronously and are the result of a signal from an I/O device outside the processor. An exception handler for hardware interrupts is often called an interrupt handler

outlines the processing of an interrupt

The remaining exception types (traps, failures, terminations) occur synchronously , and are the result of executing the current instruction. We call this kind of instruction a fault order .

    • System calls to traps

Traps are intentional exceptions and are the result of executing an instruction. The most important use of traps is to provide a process-like interface between the user program and the kernel, called the system call

Request Service: Read file, create a new process (fork), load a new program (EXECVE), terminate the current process (exit)

    • Fault

The fault is caused by an error condition, and he may be able to be corrected by the fault handler

A classic failure case is a page fault, when the instruction references a virtual address, and the physical pages corresponding to that address are not in memory, and therefore must be removed from the disk when a failure occurs

    • Termination: termination is the result of unrecoverable fatal errors, usually some hardware errors

(3) Exceptions in the LINUX/IA32 system

    • LINUX/IA32 Failure and termination: Division error, general protection failure, missing pages, machine check

    • LINUX/IA32 system call: Linux provides hundreds of system calls that can be used when an application wants to request kernel services, including reading files, writing files, creating a new process

8.2 Process

The key abstraction that a process provides to a program:

    • A separate logical control flow that provides an illusion as if the program exclusively uses the processor
    • A private address space that provides an illusion as if the program exclusively uses the memory system

(1) Logic control flow

If you want to step into the program with the debugger we will see a series of program counter (PC) values that are unique to the instructions contained in the program's executable target file, or that contain instructions in a shared object that is dynamically linked to the program at run time

This PC is worth a sequence called a logical control flow , referred to as a logical flow

(2) Concurrent stream

The execution of one logical stream overlaps another stream in time: a concurrent stream . Concurrent runs

The general phenomenon of concurrent execution of multiple streams is called concurrency

The concept of a process and other processes running in turn is called multitasking

A process that executes a portion of his control flow is called a time slice .

Multi-tasking is also called time slicing .

A parallel stream is a true subset of concurrent streams, and if two streams are running concurrently on different processor cores or computers, then we call them parallel streams (parallel runs, parallel executions)

(3) Private address space

N-bit address machine: address space is a collection of 2^n possible addresses

A process that provides his own private address space for each program

Private: The memory byte associated with an address in this space cannot be read or written by another process

(4) User mode and kernel mode

(5) Context switch

The operating system kernel uses a higher-level exception control flow called context switching to achieve multitasking

8.4 Process Control

(1) Get process ID

(2) from the programmer's point of view, you can assume that the process is always in one of the following three states:

    • Run
    • Stop it
    • Termination: Three reasons: A signal is received, the default behavior of the signal is to terminate the process; return from the main program; Call the Exit function

(3) Recycling sub-process

A process that has been terminated but not yet recycled is called a zombie process.

8.5 signal

UNIX signaling: An exception in the form of a higher-level software that allows a process to interrupt other processes

A signal is a small message, he notifies the process system that a certain type of event has occurred

(1) Signal terminology

    • Send Signal
    • Receive signal

(2) Send signal

    • Process groups: Each process belongs to only one process group
    • Send a signal using the/bin/kill program
    • Send a signal from the keyboard
    • Send a signal using the Kill function
    • Send a signal with the alarm function

(3) Receiving signal

Each signal type has a pre-defined default behavior

    • Process termination
    • Process termination and dump memory
    • Process stops until the Sigcont signal is restarted
    • Process ignores this signal

(4) Signal processing problems

    • Pending signal is blocked
    • Pending signals are not queued for processing
    • System calls can be interrupted

You cannot use a signal to count events that occur in other processes

The 11th week summary of the Design foundation of information security system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.