Computer operating system knowledge notes Part III

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/kuokuo666/article/details/99006452

OS (Operating System)

Processes, threads and processor scheduling
  • ① process synchronization and thread
    • Because multiple processes can execute concurrently, so there must be resource sharing and mutual cooperation issues between processes. If you do not take the initiative to adjust the process, there will not be reproduced executed .
    • A group of processes in order to coordinate their advance rate, in some places need to wait for each other or wake, mutual restraint between this process will be referred to as a process synchronization .
    • Rule synchronization mechanism should be followed : let into idle, busy waiting, waiting is limited, so that the right to wait. Limited waiting for: the process requires access to critical areas, ensure access to critical zone for a limited time, to avoid death and so on. Let the right to wait: The process can not enter the critical section, should immediately release the processor, and so avoid busy.
    • Semaphore mechanism : the use of PV operation to process the semaphores, process synchronization tools to solve problems. By the number of resources, and the resources to apply the specific action of the release of resources, the resources to achieve the operation and results of visualization.
    • The tube mechanism : the benefits of the tube mechanism is that all processes are using this mechanism to obtain critical resources, need to consider how to solve the inherent conflict critical resources centrally.
    • Thread : A thread is a lightweight process, a process can have multiple threads, the thread is the smallest unit of program execution. Independent threads can not execute . Threads share the process resources of the same process, so that when a thread crashes occur, this process will crash. But the resources between the various processes are independent, so when a process crashes, will not affect other processes. Therefore, the process is more robust than the thread . Creating and switching between threads does not cause the thread process creation, switching and revocation, so the overhead significantly smaller threads .
  • ② deadlock
    • Deadlock : The above two processes ask for the release of resources has led to the phenomenon of possession can not continue to run down each other. Examples: the box has a drawer and bread. A process of trying to remove the bread from the box in a drawer. B that the process wants to open a drawer to take bread in a drawer. A process requests a box, success! B process requests a drawer, success! But then, the process A to wait for the process to release the drawer B, B A process needs to process the release of the box, forming a deadlock.
    • Causes deadlock : competition can not seize resources, processes running order propelled unreasonable, competition can consume resources. Four necessary condition deadlock: mutually exclusive conditions, holding request condition, not deprivation, circular wait condition.

Guess you like

Origin blog.csdn.net/kuokuo666/article/details/99006452