Interview summary and interview summary for those years
The blog will be updated slowly. Review before looking for a job.
Position: Background Development, C/C ++, and JAVA Network
- HTTP1.1 and HTTP1.0 difference, refer to: http://blog.csdn.net/hguisu/article/details/8608888
Persistent connection-connection. Multiple requests can be sent over a tcp connection;
Host domain-use the Virtual host Technology to differentiate multiple applications on one host;
Added some request methods
- Header field parsing for HTTP: http://www.cnblogs.com/xcsn/p/4308228.html
- Formats of TCP, UDP, and IP Packets: http://blog.csdn.net/kernel_jim_wu/article/details/7447377
- Slow Start and fast retransmission of TCP: tcp has a Receiving Window for traffic control. Window 1 is a stop protocol, which is inefficient. If the window is too large, network congestion may occur. Therefore, congestion control relies on the congestion window (cwnd) for control. Slow Start is a bit similar to the start of the vehicle, specific to be elaborated, refer to: http://blog.csdn.net/loverooney/article/details/38323907
- Application scenarios of multicast protocol and multicast protocol: One-to-multiple-point, Saving network bandwidth; IP multicast is widely used in network audio and video. The dependency IP multicast address, which is a Class D address.
- Three handshakes and four handshakes of TCP connections: three handshakes: the client initiates a request (serial number)-the server responds to ack and gives its own serial number-the client responds to ack. Disconnect four waves: one end initiates a disconnect (FIN), and the other end responds to ack; then the write at one end is closed; the other end initiates a disconnect request (FIN), and the local end responds to ack. In this way, both parties close the connection. Because write is disabled at one end, but data may be sent at the other end, the connection may be closed at both ends, and four waves may occur.
- Time_wait status: When the tcp wave ends four times, the connected party closes the connection and enters the time_wait status (2 * MSL time) After receiving the FIN packet from the other party ), if the opposite FIN package is not received again within this time period, it indicates that ack has arrived successfully. Assume that, if there is no such status, but it is directly in the close status, the server does not receive ack and resends the FIN package. The RST package will be sent here, causing the server to receive an error in the rst package, it affects the program process. If there is no time_wait status, the old disconnect packet will interfere with the new connection when the new connection request comes over. Reference post: http://www.firefoxbug.com/index.php/archives/2795/
Programming
Operating System
- Elaborate on the system call-reference post: http://blog.csdn.net/chosen0ne/article/details/7721550
Key Point: switch from user to kernel through interruption. There are two important attributes of an interrupt: the interrupt number and the interrupt processing program. The interrupt number indicates different interruptions. The interrupt number is a scarce resource. The kernel maintains a system call table. The system call number can be used to identify the system call. This completes the function name conversion for the system call. Parameters are passed through registers. The stack used by processes running in user mode and kernel mode is different. Stack switching is performed by assigning values back and forth through registers (Stack pointer, % esp), and passing parameters in registers requires additional protection and recovery. It can be seen from the above that the system call is very time-consuming: 1. The system call is implemented through interruption, and stack switching needs to be completed; 2. Register passing parameters requires additional storage and recovery processes.
Difference between a process and a thread: A process is the basic unit for allocating resources (such as CPU and memory) and has an independent address space. A thread is an entity in a process. It shares the address space of a process and is a lightweight process. It is the basic unit for CPU scheduling and allocation, but each thread has its own stack space. Advantages of multi-threaded programming: (1) blocking of a single thread will lead to freezing and affect interaction; (2) giving full play to the computing power of a multi-core CPU; (3) simplifying the program structure, make the program easy to maintain; (4) the thread creation and switching overhead is smaller than that of the process. Reference: http://www.ruanyifeng.com/blog/2013/04/processes_and_threads.html http://www.nowcoder.com/discuss/1836? Type = & order = 0 & pos = 56 & page = 0
Communication between processes in linux: (1) communication between processes with kinship. The naming pipeline allows communication between unrelated processes, "|" in shell commands is a type of pipeline communication. The output of a command serves as the input of another process. (2) signal: various signals can be interrupted at any time during the program running, to process the signal, the kill command in Linux communicates with other processes through the signal. For example, kill-l can view the signal classification and kill-9 forcibly kills the corresponding process; (3) Message Queue: a process with sufficient permissions can add messages to the queue. A process with the read permission can read messages from the queue. Message Queue overcomes the disadvantages of signal carrying less information, and the pipeline can only carry non-formatted byte streams and limited buffer size. (4) shared memory: Very fast process communication mode, combined with semaphores, achieve synchronization and mutex between processes; (5) socket: the socket can allow processes on different hosts to communicate. It is important to also talk about it. See http://www.cppblog.com/jerryma/archive/2011/08/03/152348.aspx
Synchronization between threads: Because threads share memory, synchronization between threads is required. Synchronization Methods include mutex lock, condition variable, and read/write lock. Mutex lock is used to protect critical zones; condition variables are used to send signals and wait signals; read/write locks are improved based on mutex locks and become shared-exclusive, it is very suitable for applications where the frequency of reading data is much higher than the frequency of writing data. Reference: http://blog.csdn.net/hanchaoman/article/details/5628789
Orphan process: the parent process exits first, and the child process is adopted by the init process. The zombie process exits. The parent process does not obtain the status information of the child process, the sub-process status descriptor still exists in the system. daemon: Linux background service process, such as crond, is not controlled by the terminal. It is started when the system is started and terminated when the system is disabled.
Memory Allocation Policies: malloc, first fit, and best fit. Memory fragments are generated during the allocation, which can be merged after several free times. Http://blog.jqian.net/post/malloc.html implements a malloc: http://blog.codinglabs.org/articles/a-malloc-tutorial.html
Concurrent Programming
- Difference between sellect and epoll: the disadvantage of sellect is epoll. (1) Maximum concurrency limit; (2) inefficient, linear scanning of all fd sets; (3) kernel and user space data copying, using memory copy. Epoll: (1) no limit on the maximum number of connections; (2) only active connections; (3) shared memory http://blog.csdn.net/tianmohust/article/details/6677985
- Thread Pool: see nginx introduce thread pool to improve performance example: http://www.infoq.com/cn/articles/thread-pools-boost-performance-9x
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.