Front-end written test questions (operating system/data structure, etc.)

1. Operating system

1. True or False

  • When multiple processes operate on the same file, the consistency of the file should be considered
  • Data can be transferred and shared between different processes through files

Shared data must be initialized, otherwise the Microsoft compiler will put uninitialized data into the .BSS segment, which will cause the sharing behavior between multiple processes to fail

  • The operating system will allocate independent data segments and program segments to each process, but the processes are invisible to each other, data cannot be transferred through global variables, and the address spaces between processes are independent. Global variables can only be shared between threads in the same process
  • A process also cannot access the physical memory space of another process.

2. The reassembly of IP datagram fragments usually occurs (on the destination host)

When an IP datagram is encapsulated into a frame of the link layer, the total length of the datagram (that is, the header area plus the data part) must not exceed the MTU value of the lower data link layer, otherwise it cannot be transmitted. Therefore, we need to fragment the IP packet. In the header of the IP datagram, the fields related to the fragmentation of the IP datagram are - total length, identification, flag and bit offset. The fragmentation is completed by the router at the network layer
After the destination host receives all the fragments, the process of reassembling and restoring the fragments is called IP datagram reassembly . The IP protocol stipulates that only the final destination host can reassemble fragments. After the destination host receives all the subpackets of the data packets, it restores the original data packets according to the information stored in the header of the data packets. This is the reassembly process of the data packet.

3. After the introduction of multi-programming technology, the utilization rate of the processor (greatly improved)

Multiprogramming refers to storing multiple user jobs in the main memory at the same time, so that they are all between the start point and the start point of execution, and these programs share computer system resources.
2) Macroscopically parallel: several programs entering the system at the same time are in the process of running, that is, they have started their respective operations one after another, but none of them have finished running.
3) Microscopically serial: From a microscopic point of view, multi-programs in the memory occupy the CPU in turn or time-sharing.
The main advantages of multi-programming are:
(1) Improve CPU utilization. In a multi-program environment, multiple programs share computer resources. When a program is waiting for I/O operations, the CPU can execute other programs, which greatly improves CPU utilization.
(2) Improve the utilization rate of equipment. In a multi-program environment, multiple programs share system equipment, greatly improving the utilization of system equipment.
(3) Improve the throughput of the system. In a multi-programming environment, the waiting time of the program is reduced and the throughput of the system is improved.

4. Which of the following statements about the TCP protocol is correct

  • The party that both communication parties actively close enters the TIME_WAIT state

The passive party enters the LAST_ACK state, and the active party enters the TIME_WAIT state.

  • The TIME_WAIT state will last for 2 MSL

The purpose of continuing 2MSL is to retransmit the ACK, so that the passive close party can receive it.
Assuming that the client initiates an interrupt request, the state experienced by the client during the entire process
insert image description here

The process experienced by the server side is as follows
insert image description here

5. True or False

  • In the computer, the speed of the arithmetic unit to access the register is the fastest (CPU accesses the memory)

Comparing the completion time of each step in the instruction execution process, it is pointed out that the speed of reading/writing registers is the fastest among all steps.
Usually, the time taken to fetch an instruction and execute it is called an instruction cycle. Different instructions have different functions, so the execution steps included are different. Regardless of the step of instruction decoding, whether it is a simple instruction or a complex instruction, the execution steps contained in it can always be decomposed into the following four basic operations, that is, the function of each instruction is always composed of the following four basic operation functions become.
(1) Read the content of a storage unit and load it into a given register.
(2) Store a data from a register into a given storage unit.
(3) Send a data from a register to another register or ALU input.
(4) Carry out some kind of arithmetic operation or logic operation, and send the result to a certain register.

  • While waiting for an interrupt, the CPU can handle other tasks

In the description of option B, the word "interrupt" is rather vague, and there are two different understandings, one is "interrupt request" and the other is "end of interrupt processing".
If understood as the former, the meaning of option B is "the CPU cannot process other tasks while waiting for the interrupt request", which is obviously wrong. In the process of executing the program, the CPU always actively detects the "interrupt request signal" before executing an instruction and fetching the next instruction. If an interrupt request is found, it executes an "interrupt implicit instruction" to respond to the interrupt request. .
If it is understood as the latter, the meaning of option B is "the CPU cannot process other tasks while waiting for the end of the interrupt processing", which is also wrong.
After the CPU responds to the interrupt request, it will jump to an interrupt service routine to execute for interrupt processing. Different interrupt types have different interrupt service routines for different interrupt processing. Some interrupt processing is very simple, such as "the printer is out of paper", the interrupt service program only needs to display a message on the screen; It is necessary to start the peripherals for I/O. Usually, after issuing the command to start the peripherals, an interrupt return is performed to return to another process code that was originally suspended to execute.

  • The same piece of code does not necessarily take the same time to run each time

Because the word "certainly" is mentioned, it can be judged quickly that it is wrong. However, for the understanding of the knowledge points mentioned in option C, there are still many contents worthy of detailed discussion.
The first is how to understand the "running time of program code" and "the same piece of code".
When the operating system schedules the processor, it often allows multiple programs (more precisely, processes) to use the processor in turn for a period of time. Therefore, during the execution of a user program, there may be other user programs at the same time. And the operating system program is executing, so the execution time of a certain program that the user feels is not its real execution time. The execution time perceived by the user is usually divided into the following two parts: CPU time and other time. CPU time refers to the time the CPU spends on program execution, and it includes the following two parts:
(1) User CPU time, which refers to the time actually used to run user program code;
(2) System CPU time, which refers to the time required to execute user programs The amount of time the CPU spends running operating system programs.
Other time refers to the time waiting for I/O operations to complete or the time the CPU spends executing other user programs.
The performance evaluation of a computer system mainly considers the CPU performance. System performance and CPU performance are not equivalent, and there are some differences between the two. System performance refers to the response time of the system, which is also related to other parts outside the CPU; while CPU performance refers to the user CPU time, which only includes the time for the CPU to run the user program code.
Therefore, the "running time of the program code" can be understood as the sum of the execution time of each instruction in the program code, and can also be understood as the total execution time felt by the user during the running of the program code (including the operating system code and other codes interspersed in it) program code runtime). If it is understood as the latter, it is likely that the total execution time felt by the user may be different because of the difference in each running environment. Therefore, option C is wrong.
If it is understood as the former, then it depends on what the "same piece of code" in the option means to determine whether option C is correct. If the code in the "same piece of code" refers to a static sequence of instructions in the executable file (such as a sequence of instructions executed in a loop), then it may be because the value of the variable is different each time the code is executed (such as the loop termination condition The value of the variable is different), resulting in a different number of instructions executed by the program during execution (the number of loop executions is different), thus making the total time of instruction execution different each time the code is run. Therefore, option C is wrong.
Obviously, only the "running time of the program code" can be understood as the sum of the execution time of each instruction in the program code, and the "same piece of code" can be understood as the execution time of each instruction in the program code. The sequence of instructions executed is exactly the same, then option C is correct. Obviously, this interpretation of the description of option C is a bit far-fetched.

  • A soft interrupt is an interrupt triggered by software

The "soft interrupt" should specifically refer to the "int n" instruction in the Intel architecture. After executing this instruction, the CPU will enter the interrupt vector table (real address mode) or interrupt descriptor table (protected mode) according to the interrupt type number n. , take out the corresponding interrupt service routine to execute, and then return to the next instruction after the "int n" instruction to execute. Therefore, the execution of the "int n" command is equivalent to causing an "interruption" event to the current program. Here, the "int n" command is obviously pre-arranged in the software and is a software-triggered event. Therefore, the description of option D is correct.

2. Data structure

1. If the push sequence of a stack is ABCDE, then the impossible pop sequence is ()

ECDBA
DCEAB

2. The information in the TCP header message related to the connection establishment is ()

TCP: Status control code (Code, Control Flag)
flag field (U, A, P, R, S, F): occupies 6 bits. The meaning of each bit is as follows:
URG (urgent pointer field value is valid): urgent bit (urgent), when URG=1, it indicates that the urgent pointer field is valid, which means that the packet is an urgent packet. It tells the system that there is urgent data in this segment and should be transmitted as soon as possible (equivalent to high-priority data), and the Urgent Pointer field in the above figure will also be enabled.
ACK (means response): Acknowledgment bit (Acknowledge). The acknowledgment number field is only valid when ACK=1, which means that this packet is an acknowledgment packet. When ACK=0, the acknowledgment number is invalid.
PSH (indicates that there is DATA data transmission): (Push function) If it is 1, it means that the other party is required to send other corresponding packets in the buffer immediately, without waiting for the buffer to be full before sending.
RST (indicating connection reset): reset bit (Reset), when RST=1, it indicates that there is a serious error in the TCP connection (such as due to a host crash or other reasons), the connection must be released, and then the transport connection must be re-established.
SYN (indicates connection establishment): Synchronous bit (Synchronous), SYN is set to 1, it means that this is a connection request or connection acceptance message, usually the packet with the SYN flag means "active" to connect to the other party. .
FIN (indicates closing the connection): Termination bit (Final), used to release a connection. When FIN=1, it indicates that the data of the sending end of this message segment has been sent, and it is required to release the transport connection.

3. True or False

  • In the time slice round-robin scheduling algorithm, the shorter the time slice, the higher the CPU utilization

The shorter the time slice, it means that other processes or threads get the CPU. At this time, an interrupt is required, and the CPU cannot process other tasks.

  • The higher the priority process, the more CPU time it will take up.

The higher the priority, the more likely it is to get the CPU, but the job itself requires less CPU time.

  • When traversing a large two-dimensional array int a[x][y], the processing time of traversing x first or y first is the same

Because it is stored in row order, it is relatively faster to traverse x first and then traverse y, which involves prefetch operations.

  • Using cache can improve CPU utilization

The existence of the cache is to solve the speed mismatch. When the register is read quickly, the CPU will not finish the work and wait for the register to read the data.

4. Set a set of initial keyword record keywords as (19, 15, 12, 18, 21, 36, 45, 10), then the result after a quick sort with 19 benchmark records is ()

  • 10,15,12,18,19,36,45,21

The minimum depth of a binary tree with 1000 nodes is ( ) (the depth of the first level is 1)

**Which part of the IP address 205.140.36.68 represents the network number (205.140.36) 68 is the host number
insert image description here

Guess you like

Origin blog.csdn.net/qq_59079803/article/details/124977938