Common Operating System questions (answers for reference only)
1. What is interruption? What does the CPU do when it is interrupted?
Interruptions refer to any unusual or unexpected emergency handling event in the system during computer execution, this allows the CPU to temporarily interrupt the program being executed and switch to the corresponding event processing program. After the process is completed, the system returns the process of executing the new process that was originally interrupted or scheduled.
2. What must I do before the CPU enters the main () of the operating system after it is powered on?
After power-on, the CPU reset signal is triggered, causing CPU reset. Then, the CPU jumps to (0x00000000 for arm and 0xfffffff0 for x86) to execute the command. it mainly performs CPU initialization, determines the CPU working mode, and initializes mmu. Create a page table, initialize the lonely controller and interrupt vector table, initialize the input and output, initialize nandflash, load the OS TEXT area to the sdram, and then jump to the main ()
3. Perform simple operations on the physical layer Layer1, link layer Layer2, and network layer Layer3 tasks of iso osi.
Network Layer: data transmission destination addressing, and then select the best route for data transmission;
Link Layer: responsible for how data packets are transmitted over the network;
Physical Layer: establishes and terminates connections between devices and transmission media. In the communication process, resources can be effectively allocated among the shared users, and the signal is modulated or converted so that the digital signal definition in the User device can match the digital signal actually transmitted on the channel.
4. What is the role of makefile?
The source files in a project are not counted. They are stored in several directories by type, function, and module. makefile defines a series of rules to specify which files need to be compiled first, which files need post-compilation, which need to be re-compiled, or even perform more complex functional operations, because makefile is like a Shell script and can also execute operating system commands. The benefit of makefile is "automatic compilation". Once written, only one make command is required, and the entire project is fully automatically compiled, which greatly improves the efficiency of software development. Make is a command tool that explains commands in makefile. Generally, most ides use this command, such as make in Delphi and nmake in Visual C ++, GNU make in Linux. It can be seen that makefile is a compilation method in Engineering.
5. What is the command for displaying file names in UNIX folders? What is the command to display the file content on the screen?
Ls cat
Type tail
6. What are the attributes of Linux Files? (10 in total)
-Rw-r -- R-1
The first attribute indicates that the file is a [directory, file, or link file]. If it is [d], it is a directory. If it is [-], it is a file, if it is [l], the link file is used );
If it is [B], it indicates the interface device in the device file that can be stored;
If it is [c], it indicates the serial port device in the device file, such as the keyboard and mouse.
In the following attributes, the three are a group and are a combination of the three parameters [rwx], where [r] represents readable,
[W] indicates writable and [x] indicates executable:
The first group is [permissions of the owner ],
The second group is [same group permissions ];
The third group is [other permissions not for this group ].
7. commands commonly used in Linux
Show file directory command ls
Change the current directory command cd such as cd/home
Create a subdirectory mkdir xiong
Delete sub-directory commands such as rmdir/mnt/cdrom
Delete a file using the RM command, such as rm/ucdos. bat.
File copy command cp such as cp/ucdos/*/fox
Command for obtaining help information, such as man ls
Show file content less such as less mwm. lx
Redirection and pipeline type such as type readme> direct, append the file readme content to the text direct
8. How does a process communicate?
Pipeline communication, message communication, and Memory Sharing
9. segment and paging.
Pages are the physical unit of information, and pages are used to achieve discrete distribution, so as to reduce the external zero header of memory and improve memory utilization. Or, pages are only required by system management, instead of the user's needs.
Segment is the logical unit of information. It contains a set of relatively complete information. The purpose of segmentation is to better meet user needs. The page size is fixed and determined by the system. The logical address is divided into two parts: the page number and the address in the page, which are implemented by the machine hardware. Therefore, a system can only have one page size. The length of the segment is not fixed, which is determined by the program you write. Usually, the editing program is divided by the nature of the information when editing the source program.
The paging job address space is one dimension, that is, a single linear space. Programmers only need to use a memory character to represent an address. The address space of a segmented job is two-dimensional. When identifying an address, the programmer must provide both the segment name and the intra-segment address.
10. What are processes and threads? What is the difference?
A thread is an entity of a process. It is the basic unit for CPU scheduling and scheduling. It is smaller than a process and can run independently.
The thread itself basically does not have system resources, and only has a few resources (such as program counters, a set of registers and stacks) that are essential for running ), however, it can share all resources of a process with other threads of the same process. one thread can create and cancel another thread, and multiple threads in the same process can be concurrently executed.
11. How is the memory managed in Windows?
Window-operated memory can be divided into two layers: physical memory and virtual memory.
The physical memory is managed by the system and cannot be directly accessed by applications. The application only has one 2 GB address space, and the memory allocation is implemented through the heap, each process has its own default heap. After a heap is created, the corresponding size of the address block is retained through the Virtual Memory Operation (the actual memory is not occupied, and the system consumes a small amount ), when a memory block is allocated on the heap, the system finds an idle block in the heap address table. (If the block cannot be found and the heap creation attribute is extensible, the heap size is expanded) submit physical objects (physical memory or swap files on the hard disk) for all memory pages contained in the idle block ). Then you can access this part of the address. At the time of submission, the system will uniformly allocate the memory of all processes. If the physical memory is insufficient, the system tries to put some pages temporarily inaccessible to some processes into swap files to free up some physical memory. When the memory is released, only the page on the heap will be unsubmitted (the corresponding physical object will be removed) and the address space will be retained.
If you want to know whether an address is occupied or not, you only need to query the virtual memory-like VirtualQuery of this address. If it is submitted, you can access it. If only or not, a software exception occurs. In addition, you can set various attributes on some memory pages. If it is read-only, writing in the system will also cause software exceptions.
12. What is the content of the operating system? What is virtual memory? Does advantage management belong to the operating system?
13. process is a very important concept. What are the statuses of processes?
There are three basic statuses: ready (ready), running (running), and wait (waiting ).
14. Do you know how to keep the process synchronized?
The main methods for inter-process synchronization include memory barrier, mutex lock, semaphore and lock, pipe, message, and pipe.
15. How does one convert physical addresses to logical addresses in OS?
16. Perform paging management.
The address space of a user program is divided into several fixed-size areas, called "pages". Correspondingly, the memory space is divided into several physical blocks, and the page and block size are equal. Any page of the user program can be placed in any part of the memory to achieve discrete allocation.
17. What is a deadlock and what are its conditions? How can we avoid deadlocks?
A deadlock means that in two or more concurrent processes, if each process holds a certain resource and waits for other processes to release the resources they currently hold, otherwise it cannot push forward. at this time, each process occupies a certain amount of resources, but cannot push forward, said this group of processes have a deadlock. in layman's terms, it is a system state in which two or more processes are endless waiting for conditions that will never be established. the condition is
1. mutex: there is such a resource that can only be allocated to one execution thread at a time;
2. Hold: When the requested resource is occupied and execution is blocked, the resource owner not only does not need to release the resource, but can continue to request more resources;
3. Force Deprivation: the mutex resources obtained by the execution thread cannot be forcibly deprived. In other words, only the resource owner can release the resource;
4. loop wait: Several threads obtain mutually exclusive resources in different order, so that in the ring chain composed of multiple threads, each thread is waiting for the next thread to release its resources.
Avoid deadlocks: Access in order and minimize transactions
18. What is buffer overflow? What are the dangers? Why?
Buffer overflow refers to the data that exceeds the buffer's capacity overflow when the computer fills the buffer's data digits,
Hazard: In the current network and distributed system security, more than 50% of the widely used vulnerabilities are buffer overflow. The most famous example is the worm exploiting the fingerd vulnerability in 1988. In buffer overflow, stack overflow is the most dangerous because intruders can use stack overflow to change the address of the returned program when the function returns and redirect it to any address, one of the hazards is that a program crashes, causing a denial of service. The other is to jump to and execute a piece of malicious code, such as getting a shell and then doing whatever you want.
By writing content beyond its length to the buffer zone of the program, the buffer overflow is caused, and the stack of the program is destroyed, so that the program executes other commands in turn to achieve the purpose of attacks. The cause of buffer overflow is that the program does not carefully check user input parameters.
19. What is a critical section? How to resolve conflicts?
The program that accesses critical resources in each process is called a critical zone. Only one process is allowed to enter the critical zone at a time. Other processes are not allowed to enter the critical zone.
① If several processes require entering the idle critical section, only one process is allowed at a time.
② At any time, there must be no more than one process in the critical section. If a process has entered its own critical section, all other processes that attempt to enter the critical section must wait.
③ Processes entering the critical section should exit within a limited period of time so that other processes can enter their critical section in time.
④ If a process cannot enter its critical section, the CPU should be used out to avoid the process being "busy.
20. Explain the P and V Operations.
P is the request resource, V is the release resource
21. Features of interruption and polling.