Eighth. Abnormal control Flow
ECF: (Exception control flow) mutation set
Smoothing: Instructions for sequential structures
Mutation: Jump, call, and return instructions, not on the same stack
Basic mechanism:ECF是操作系统用来实现I/O、进程和虚拟存器的基本机制 ECF是计算机系统中实现并发的基本机制
Abnormal
Mutation of control flow
Exception Number:
The system assigns unique nonnegative integers to each type of exception
Exception table:
When the system starts, the operating system initializes a bar transition so that the entry k contains the address of the handler for the exception K
Usage:
The index from the exception number to the exception table
Category:
Interrupt: The result of a signal from an I/O device outside the processor, returning to the next instruction
Traps: Traps are intentional exceptions, system calls
Fault: caused by an error condition, may be able to be corrected by the fault handling program
Termination: usually some hardware error
Assembly Common calls: Call
Different classes of interrupts or traps are implemented by assigning values to the arguments behind the call
Interrupt: Call 21H (standard output, referred to as iOS)
Trap: Call Function name
Process
Program runs in the context of a process
The key abstraction that a process provides to an application:
A separate logical control flow: Exclusive use of the processor
A private address space: Exclusive use of the memory system
Process Utilization CPU: SFCF,SRT,RR, and multi-and scheduling (common)
Multi-and scheduling features:
Process scheduling with time slice rotation
Concurrent streams
Run multiple streams at the same time
Parallel: two streams
Concurrent runsIn
different processor cores.or CONTROL permission bits on the computer: differentiate between user mode and kernel mode process Control
Each process has a unique positive process ID (PID)
pid_t getpid(void); 返回调用进程的PID
pid_t getppid(void); 返回父进程的PID(创建调用进程的进程)
Fork
格式:pid_t fork(void)
Call once, return two times
Exit
格式:void exit(int status);
Waitpid:
格式:pid_t waitpid(pid_t pid, int *status, int options);
The child process PID is returned successfully, and if Wnohang returns 0, the other error returns-1.
Wait
Wait (&status) is equivalent to Waitpid ( -1,&status,0).
pid_t wait(int *status);
Sleep
unsigned int sleep(unsigned int secs);
Pause
int pause(void);
EXECVE:
int execve(const char *filename, const char *argv[], const char *envp[]);
The difference between the fork function and the EXECVE function
The fork function is to create a new child process , a copy of the parent process, run the same program in the new child process, the parent process and the child process have the same file table, but the different PID
The EXECVE function loads and runs a new program in the context of the current process, overwrites the address space of the current process, but does not create a new process , has the same PID, inherits the file descriptor
Summarize
The content of this chapter is relatively more, many things still do not really understand, a lot of functions and the use of various parameters in the packaging and the role of the function are not very good grasp, but the general structure is very clear, plus the other courses complementary, some content can be achieved through, many computers also have a certain understanding
Resources:
Textbooks
Shang
---restore content ends---
Eighth. Abnormal control Flow