【Operating System】 Question and Answer

Q1: What is the operating system and the role of the operating system

  • The operating system is a set of programs that controls and manages the hardware and software resources of the entire computer system, rationally organizes and schedules the work of the computer and the allocation of resources, and thus provides a convenient interface and environment for users and other software. It is the most basic system software in the computer system.
  • Basic features include: concurrency, sharing, virtual, asynchronous
  • For computer systems, the operating system is a collection of programs that manage all system resources; for users, the operating system provides an interface to call computer resources

 

 

Q2: Concept of management and vision

 

  • The management state is also called privileged state, core state, and system state. The operating system is running in managed mode
  • Eye state is also called user mode, user programs can only run in user mode
  • If the user program executes the privileged instruction in the state, the hardware will be interrupted, the operating system will gain control, and the privileged instruction is prohibited; when the user needs to call system resources, the service request must be made to the operating system through the system call method The system is completed.

 

 

Q3: program, process, thread connection and the difference and connection between process and thread

 

Differences and connections between programs and processes

 

  • A program is a set of ordered instructions. It is a static concept. A program consists of a set of instructions and is stored in memory in a binary manner.
  • A process is a running activity of a program and its data on a computer. It is a dynamic concept. The running entity of the process is a program, and the process of the leaving program is meaningless. The process is composed of three parts: program, data and process control block (PCB). The process has a life cycle, the process can also create a process, these are not in the program.

 

Differences and connections between processes and threads

 

  • A process is a basic unit of system resource allocation in an operating system. In an operating system without a thread mechanism, a process is also a basic unit for scheduling operation of a processor.
  • In an operating system that uses a threading mechanism, threads are the basic unit of processor scheduling. A process can be composed of one or more threads, and each thread shares resources in the process.
  • The process is introduced to better execute multiple programs concurrently, improve resource utilization and system throughput, and increase the degree of concurrency;
  • The introduction of threads is to reduce the space-time overhead paid by programs during concurrent execution and improve the concurrent performance of the operating system.

 

Q4: Three states of the process

 

  • A process is a running activity of a computer program and its data on a computer. It is a basic unit of resource allocation by the system and is a dynamic concept. Therefore, it has a life cycle and is divided into a ready state, a running state, and a blocking state
  • The ready state means that the process obtains all the resources it needs and waits for the processor. As long as it is allocated to the processor, it can be executed
  • Running state means the process is running on the processor
  • The blocking state is that the process is waiting for an event to occur, such as waiting for the allocation of a resource, even if the processor is now idle, it cannot schedule the process in the blocking state.
  • In addition, there is a creation state and an end state

 

 

Q5: The concept of deadlock and the method of deadlock in the operating system

 

  • Because there are some inalienable resources in the system, when two or more processes occupy their own resources and request each other's resources, no process will be able to move forward, which is deadlock.
  • There are 4 necessary conditions for deadlock, which are the mutually exclusive condition, the non-deprivation condition, the request and hold condition and the loop wait condition
    • The mutually exclusive condition means that the resources required by the process to be allocated are exclusive, that is, it can only be used by one process at a time.
    • Inalienable means that the resource cannot be forcibly taken away before the process finishes using it
    • Request and keep means that the process owns the resources it originally owns and wants other resources
    • The loop wait condition refers to the existence of a loop waiting chain of process resources
  • Ways to avoid deadlock
    • Deadlock processing strategies include prevention of deadlock, avoidance of deadlock and detection and release of deadlock
    • The prevention of deadlock is to establish the necessary conditions to destroy the necessary conditions of the deadlock, so that the deadlock cannot occur
    • The avoidance of deadlock is to use some algorithms to prevent the system from entering an unsafe state when dynamically allocating resources, thereby avoiding deadlock
    • Deadlock detection and release means that no money is taken when the deadlock occurs, and only the system detects if a deadlock occurs, and if a deadlock occurs, then measures are taken to remove it

 

Q6: The concept of semaphore

 

  • The semaphore is proposed to solve the problem of synchronization and mutual exclusion. There are only two kinds of wait () and signal (), namely P operation and V operation.

 

Q7: Concept of synchronization and mutual exclusion

 

  • Synchronization: It is necessary to coordinate the working order between processes at certain locations and wait for the constraint relationship generated by the transfer of information (in short, the resources that a process needs to use are the result of the previous process running, so the process needs to If it happens, the previous process must run to end)
  • Mutual exclusion: When a process enters the critical section and uses critical resources, other resources must wait and cannot enter the critical section.

 

Q8: PV primitive

 

  • A primitive refers to a sequence of operations that perform a certain function and are indivisible and uninterrupted, and can usually be completed by hardware.
  • P operation, which means that the process requests a resource. When the resource has been allocated, the block primitive is called to block
  • V operation, which means that the process releases a resource, so that the number of resources that can be allocated in the system is increased by 1  

 

Q9: What are the scheduling algorithms?

 

  • Processor scheduling is to allocate the processor, select a process from the ready queue according to the scheduling algorithm and allocate the processor to achieve concurrent execution of the process
  • The scheduling algorithm includes
    • First come first serve
    • Short job priority (shortest completion time)
    • Priority scheduling algorithm
    • High response ratio priority scheduling
    • Time slice rotation scheduling
    • Multi-level feedback queue scheduling

 

Q10: What are the page replacement algorithms?

  • When the process is running, if the page it visits is not in memory, it needs to be transferred into memory, and when there is no free space in the memory, a page of program or data needs to be called out from the memory.
  • The algorithm for selecting the page to be called is the page replacement algorithm. Commonly used are the best replacement algorithm OPT, first-in first-out algorithm FIFO, the most recent unused replacement algorithm LRU, clock replacement algorithm
    • OPT: The selected elimination page is a page that will not be used in the future, or a page that will no longer be visited in the longest time, so as to obtain the lowest page fault rate. But in fact which process will be scheduled in the future is unknown, so this algorithm cannot be implemented and can only be used to evaluate other algorithms
    • FIFO: Prioritize the elimination of the earliest page in memory. The FIFO algorithm will generate an abnormal phenomenon that the number of allocated physical blocks increases and the number of page faults also increases, which becomes a Belady anomaly
    • LRU: Select the pages that have not been visited for the longest time to be eliminated
    • Clock algorithm: An additional bit is associated with each frame. The pointer cycles through the additional bits of each frame and replaces frames that meet certain conditions.

 

Q11: The difference between hard and soft links

 

  • Soft links are similar to shortcuts, that is, deleting shortcuts does not affect the source file, and deleting the source file through the soft link will not find the source file. Save the path name of the shared file
  • The hard link is the index node of the shared file. When the reference count value is not 0, you cannot delete the shared file.
  • Suppose the pointer of F1 points to the index node, and the index node points to the corresponding file
  • The soft link F2 points to F1, and its reference count value is consistent with F1. Deleting the source file is not visible to F2. Only when the source file is accessed through F2 and the file does not exist, the soft link F2 is directly deleted.
  • The hard link F3 directly points to the index node of the file, the reference count value is +1, and delete F1, you can still access the source file through F3.
Published 16 original articles · Likes0 · Visits 454

Guess you like

Origin blog.csdn.net/weixin_43951831/article/details/104970521