Video knowledge Summary 1. Pointers and declarations
The declaration of a variable in the C language is divided into two parts: type and declarator
The simplest declaration is a variable, such as a float f
Differences between pointer arrays, array pointers, pointer functions, function pointers
Array of pointers: arrays of pointers, elements in arrays are pointers; int *daytab[13]
Array pointer: Array pointer is pointer, pointer to an array with a fixed type and number of elements, such as: Int (*DAYTAB1) [13]
Pointer function: pointer function is a function; The return value of a function is a pointer type, such as: int *comp ()
function pointers: Function pointers are pointers, pointers to functions, function names are function pointers, such as: Int (*COMP1) ()
Type recognition method: Right-left method
1. Starting with the variable name, right and left, alternately looking outward, write on the paper: "Variable is"
2. If you encounter the left parenthesis to the right, write down on the paper: "Function, parameter is" and use the same method to handle each parameter in parentheses--write on the paper: "Back"
3. If you encounter square brackets to the right, write on the paper: "Array, length {square brackets}, Element type"
4. If right side parenthesis is encountered, do nothing
5. If you encounter * on the left, write on the paper: "Pointer, point to"
6. If any type is encountered on the left, write down the corresponding type name on the paper
2. Signal Processing
Signal is one of the oldest methods of process communication used in Unix
A signal is a simulation of the interrupt mechanism at the software level, it is a more complex mode of communication, used to notify the process that an event occurred, a process received a signal with the processor received an interrupt request effect can be said to be the same
View signal with KILL-L, see signal number and macro definition name
Use man 7 signal to see the condition of the signal, the default processing action
Signal life cycle: signal generation, signal registration, signal logoff, signal processing
Signal generation
Generated by the user, such as: CTRL + C generates SIGINT signals, etc., can be stty-a to see which keys can generate signals
Generated by hardware, such as: the current process executed the instruction divided by 0
Sent by a process, such as: You can send a signal to a specified process using the command kill-signal designator PID under the shell process.
Generated by the kernel, such as: Alarm clock timeout generates SIGALRM signal.
Three ways to handle the signal:
Ignore signal
Default handling: Default handling by operating system settings
Custom signal Processing: customizable signal processing functions
Capturing signals
Each time the signal function sets a specific signal processing function (non-sig_ign), it only takes effect once, and each time the process responds to processing the signal, the signal processing function is reverted to the default processing mode
The difference between signal and sigaction
Signal problem: Do not know the cause of the signal is sent, the signal processing process can not safely block other signals
Sigaction problem: When the signal handler is called, the new signal screen word created by the system automatically includes the signal being delivered. This ensures that when a given signal is processed, if the signal occurs again, it will be blocked until the end of the processing of the previous signal; The response function is set to be valid and not reset
The implementation of sleep () should be divided into three steps:
Register a signal signal (sigalrm,handler).
Call the alarm () function.
Pause () suspends the process.
20145234 Huangfei "Information Security system Design Fundamentals" 12th Week Study Summary (ii)