1. Java initialization process:
1. Initialize static member variables and static code blocks in the parent class; 2. Initialize static member variables and static code blocks in subclasses; 3. Initialize common member variables and code blocks of the parent class, and then execute the constructor of the parent class. 4. Initialize the ordinary member variables and code blocks of the subclass, and then execute the constructor of the subclass;
2. Instance is a Binary Java operator that determines whether the object to its left is an instance of a class to its right (interface, abstract class, parent class)
3. Linux startup process file
After the core is loaded, /sbin/init starts the first program of the system. The main function is to prepare the operating environment of the software, including the system host name, network configuration, language processing, file system format, and the startup of other services.
/bin/sh Shell command used to explain scripts and run it after startup
/etc/sysvinit is a System V-style init system, derived, as the name suggests, from the System V family of UNIX. The running mode in SYSVINit describes the running mode of various reservations in the system.
/etc/inittab defines the runtime level at boot time and what to do when entering or switching to a runtime level.
1. The configuration file used to start the init process is /etc/inittab
/etc/sysvinit is used for system initialization
4. Run the Linux restart command
The shutdown -r now command is the same as the shutdown -r now command.
The shutdown command can safely shutdown or restart the Linux system by warning all logged-in users on the system before shutting down. The command also allows the user to specify a time parameter, either an exact time or a time period from now. The exact time is in hh:mm format, indicating hour or minute. A time range is indicated by + and minute. After this command is executed, the system automatically synchronizes data. The general format of the command is as follows: shutdown [option] [Time] [Warning] The meanings of the options are as follows:
- K does not actually shut down but just sends a warning message to all users
- R Immediately restart after shutdown
- H Does not restart after shutdown
- F Skip FSCK during fast shutdown restart
- N Fast shutdown without init program
- C To cancel the shutdown command, note that this command can only be used by super users. Example 1, the system shuts down after 10 minutes and restarts immediately :# shutdown -r +10 Example 2, the system shuts down immediately and does not restart :# shutdown -h now halt is the simplest shutdown command, which actually calls shutdown -h. When HALT is executed, the application process is killed and the kernel is stopped after the file system writes are complete. Some of the parameters of the halt command are as follows: [-f] forcibly shutdown or restart without shutdown [-i] shutdown all network interfaces before shutdown or restart [-p] poweroff is called when shutdown occurs, which is the default option
Reboot works in a similar way to HALT, which is a reboot, whereas HALT is a shutdown. The parameters are also similar to HALT. The reboot command deletes all processes when you restart the system, rather than terminating them smoothly. Therefore, using the reboot command can quickly shut down the system, but it can cause data loss if there are other users working on the system. Therefore, the reboot command is mainly used in single-user mode.
Init is the ancestor of all processes and its process number is always 1. Init is used to switch the running level of the system, and the switching is done immediately. The init 0 command is used to immediately change the system running level to 0, that is, shut down the system. The init 6 command is used to change the system running level to 6, that is, restart the system
5. Processes and process control blocks
Process refers to a certain independent function of the program about a data set of a movement. Simply put, a process is the execution process of a program that can be executed concurrently. It is the basic multi-program unit under the management of the control program. Process control block (PCB) is established by the system for each process, to record the corresponding process of the program and data storage, record the dynamic information of the process. A PCB is a sign that a process exists. The system senses the existence of the process according to the PCB and controls and manages the process according to the information in the PCB. When the process ends, the system recycles the corresponding PCB and the process dies. The process control block contains a series of information. The process name is the process identifier that uniquely identifies the corresponding process. The system identifies a process according to the process identifier. A process has only one process control block and cannot share the same process control block with other processes.
6. Compile basic concepts
Compilation: performs syntax check, allocates space for functions, compiles each function into binary code, and generates object files according to the specific object file format. Connect: the program in the various files compiled to generate the target file to connect, but also with the system to provide resources (such as function library) connected into a whole, to get executable files. Run: To execute a connected program. Relocation: The process of converting the logical address space of a program into the actual physical address space in memory, i.e. the modification of instructions and data in the target program at load time.
7. Programs can implement links in three ways (link times vary) :
1. Static linking 2. Dynamic linking (load time) 3. Dynamic linking (runtime)
8. If the recv function is invoked on a socket that establishes a TCP connection
<0 error =0 connection closed
0 Indicates the size of the received data
9. HTTP keep-alive
KeepAlive support is available in both HTTP1.0 and HTTP1.1 protocols. HTTP1.0 requires the “Connection: keep-alive” header to be added to the request. HTTP1.1 supports this header by default
When the keep-alive mode is used, the keep-alive function keeps the connection between the client and the server Alive. When a subsequent request to the server occurs, the keep-alive function avoids the establishment or re-establishment of the connection
You can enable keep-alive on the server when the keep-alive server is configured to support multi-static content to improve transmission efficiency. Dynamic request, occupied resources cannot be released, low efficiency.
10. Hard and soft links
LINUX hard links can’t link to directories because hard links to directories can introduce loops into directories, causing the system to fall into an infinite loop while the directory is traversed, which makes it impossible to locate access directories. Hard link: Creates a new file name for the original file, but essentially adds only one directory entry, and uses the same inode as the original, pointing to the area of the original file. The data area is shared by two names. Restrictions: The source file and link file must be in the same file system, and hard links cannot be created for directory files. Ln a b // create a link file for A. B can use ls -i to check that the two inodes are identical. Also note the connection count count. For files, count is the number of hard links. For directories, count-2 is the number of subfiles in a directory. Note: The permissions are exactly the same. If I read or write one of them, the other one will be updated. Deleting one of them, however, deletes only the directory entry, not the storage data. The use and operation of the other file is not affected at all. Unless count-1 results in 0, the data area is deleted. Function: Save space, two files can be updated synchronously, prevent important files from being deleted by mistake.
Soft links: also called symbolic links. The essence is to create a new file and save the path name of the source file. Therefore, the inode and the inode of the source file are different. There are no file system restrictions, no file and directory restrictions. Command: ln -s a b Note: The permissions of the generated file are different from those of the source file. Because soft link use is more flexible, may break the chain, can also be self-circular, often need to find the steps to increase the file operation and reduce efficiency. Use as little as possible and avoid cycles.