Describe the causes and solutions of deadlocks

Updated on technology 2024-05-06
9 answers
  1. Anonymous users2024-02-09

    Causes. 1. Competing resources cause process deadlocks.

    When the number of resources shared by multiple processes in the system, such as printers and public queues, is insufficient to meet the needs of each process, it will cause the competition of the processes for resources and cause deadlocks.

    2. Deprivable and inalienable resources.

    The resources in the system can be divided into two categories, one is the deprivable resource, which means that after a process obtains such a resource, the resource can be deprived by other processes or systems.

    3. Competition is inalienable resources.

    The inalienable resources configured in the system, because their number cannot meet the needs of the operation of the processes, will make the process in the process of running, due to the competition for these resources and impasse.

    Resolution. 1. Deadlock prevention.

    This is a simpler and intuitive way to prevent in advance. The method is to prevent a deadlock from occurring by setting certain constraints to break one or more of the four necessary conditions for a deadlock. Deadlock prevention is an easy method to implement and has been widely used.

    However, because the imposed constraints are often too strict, they can lead to reduced system resource utilization and system throughput.

    2. Deadlock avoidance.

    The system dynamically checks the resource requests that can be met by each system issued by the process, and decides whether to allocate resources according to the inspection results. If a deadlock is likely to occur in the system after allocation, it is not allocated, otherwise it is assigned. This is a dynamic strategy that guarantees that the system does not enter a deadlock state.

    3. Deadlock detection and release.

    Detect first: This method does not require any prior restrictive measures or to check whether the system has entered the disturbance zone, and allows the system to deadlock during operation. However, the detection mechanism set up by the system can detect the occurrence of deadlocks in a timely manner, and accurately determine the processes and resources related to deadlocks.

  2. Anonymous users2024-02-08

    Causes of deadlocks: mutex, possession and waiting, non-deprivation, cyclic waiting.

    Ways to solve deadlocks: Prevent deadlocks, avoid deadlocks, detect and remove deadlocks.

  3. Anonymous users2024-02-07

    Deadlock. It is the source eggplant process that competes for mutually exclusive resources, resulting in at least two programs not working properly.

    Deadlocks create four conditions: mutually exclusive resources, request and hold, loop waiting, and inalienable dispersion.

    Deadlock prevention: Destroying one or more of the condition's Mutually exclusive resource --- spooling techniques Requesting and holding--- allocating resources statically or allocating resources at once Loop waiting --- orderly allocation Inalienable --- deprivable.

    Deadlock Avoidance: Banker's Algorithm.

    Prevent the system from entering an unsafe state.

    1.Deadlock prevention: Deadlocks are prevented by setting some restrictions to destroy one or more of the conditions necessary to produce a deadlock.

    2.Deadlock avoidance: In the process of resource allocation, use a method to avoid the system from entering an unsafe state, so as to avoid deadlocks.

    3.Deadlock detection: Deadlocks are allowed, but after being detected by the system, some measures are taken to remove the deadlocks.

    4.Deadlock release: When a deadlock is detected, appropriate measures are taken to free the process from the deadlock state.

  4. Anonymous users2024-02-06

    What is a deadlock? What are the causes and necessary conditions for deadlocks to occur are as follows:

    1) A set of processes, each process is indefinitely waiting for resources occupied by another process in the group of processes, so that it can never get resources, this phenomenon is called process deadlock, this group of processes is called deadlock process.

    2) The root cause: limited resources and improper operation.

    3) Necessary conditions: mutually exclusive conditions, non-preemptive judgment seepage parts, possession and application conditions, cyclic waiting conditions.

    The canonical definition of a deadlock is that every process in a collection is waiting for an event that can only be raised by other processes in the collection, then the group of processes is deadlocked.

    Deadlock Impulsion: A situation in which two or more processes in the executor are permanently blocked (waiting), and each process is waiting for resources that are occupied and clogged by other processes. For example, if process A locks record 1 and waits for record 2, and process B locks record 2 and waits for record 1, then both processes have a deadlock.

    In the computer spine system, if the system's resource allocation strategy is not appropriate, it is more common that the program written by the programmer has errors, etc., which will lead to the phenomenon of deadlock in the process due to improper competition for resources.

    In two or more tasks, if each task locks a resource that the other tasks are trying to lock, the tasks are permanently blocked, resulting in a deadlock. For example: Transaction A acquires a shared lock on line 1. Transaction B acquires a shared lock on line 2.

    The exclusive lock is blocked before waiting for transaction B to complete and release the shared lock it holds on line 2.

    The exclusive lock is blocked before waiting for transaction A to complete and release the shared lock it holds on line 1.

  5. Anonymous users2024-02-05

    Deadlock prevention means that the system predetermines some resource allocation policies, the process applies for resources according to the regulations, and the system allocates them according to the predetermined policies, so as to prevent the occurrence of deadlocks.

    The deadlock avoidance is that the system tests the resource allocation when the process makes a resource request, and only allocates resources to the process when the system can ensure the security of the system, so that the system is always in a safe state, so as to avoid deadlocks.

  6. Anonymous users2024-02-04

    What is the difference between "blocking" and "preventing"? The difference between the two of them is:

    Prevention refers to making something not happen, such as preventing the spread of disease, preventing people from gossiping, preventing themselves from dozing, etc., "prevention" is broader in scope, the object can be a certain behavior, or a certain state, the means can be direct or indirect, and the timing can be immediate or advanced.

    Blocking refers to making an action unable to achieve the goal or cause consequences, such as preventing two people from fighting, preventing mosquitoes from entering, etc., the scope of application of "blocking" is relatively narrow, the object is generally a dynamic thing, the means are generally to stop it directly, and the timing is generally when this dynamic process is happening.

    Hope mine is helpful to you!

  7. Anonymous users2024-02-03

    A deadlock is a stalemate caused by multiple processes competing for resources, and without external forces, these processes will never move forward. The causes of deadlocks boil down to two things:

    competing for resources; The order in which the process proceeds is illegal. When the four necessary conditions are met at the same time, a deadlock will occur.

    A mutually exclusive condition that a resource can only be occupied by one royal rental process for a period of time.

    Request and hold conditions mean that a process has maintained at least one resource and has put forward a new resource request, and the resource is occupied by another process, and the request process blocks the waiter, but does not release the resources already held.

  8. Anonymous users2024-02-02

    Which item is not the basic way to solve the deadlock, choose A. According to the query of relevant information, this is the real question of the auto mechanic assessment, the complete question is Xunzhi which is not the basic method to solve the deadlock, A terminates a deadlock process, B terminates all deadlock processes, C grabs resources from the deadlock process, D grabs resources from non-deadlock processes, and selects A. Mu is sensitive.

  9. Anonymous users2024-02-01

    The so-called deadlock refers to a deadlock caused by the competition for resources in the operation of multiple processes, when the process is in this deadlock state, guessing, without external forces, they will no longer be able to move forward. So let's take an example to describe that if there is a thread A at this time, it gets the lock in the order that it locks A first and then obtains lock B, and at the same time there is another thread B that gets the lock in the order of first locking B and then locking A. As shown in the figure below:

    It can be boiled down to the following two points:

    a.competing for resources;

    b.The order of progress between processes is illegal.

    Necessary conditions for a deadlock to occur:

    1. Obtain locks in a definite order.

    If multiple locks must be acquired, the order in which the locks are acquired before different threads need to be considered in the design. Following the example above, the timing diagram of two threads getting locks is like spike or judgment:

    If you change the timing of obtaining the lock to :

    Then a deadlock will never happen. For two specific locks, developers can try to obtain two locks in the order of the hashcode value of the lock object, so that the locks will always get locks in a specific order, and deadlocks will not occur. The problem becomes more complicated, if there are multiple threads at this time, are competing for different locks, simply sort according to the hashcode of the lock object (simply sort according to the hashcode order will appear "loop waiting"), it may not be able to meet the requirements, at this time the developer can use the banker algorithm, all the locks are obtained in a specific order, which can also prevent the occurrence of deadlocks, the algorithm will not be repeated here, if you are interested, you can learn about it yourself.

    2. Give up after overtime.

    When using the built-in lock provided by the synchronized keyword, as long as the thread does not acquire the lock, then it will wait forever, but the lock interface provides the Boolean trylock(long time, timeunit unit) throws interruptedException method, which can wait for the lock for a fixed duration, so the thread can get the lock after the lock timeout. Actively release all previously acquired locks. In this way, deadlocks can also be avoided very effectively. Following the previous example, the timing diagram is as follows:

    When a process deadlock is found, it should be immediately freed from the deadlock state, and the methods commonly used are:

Related questions
5 answers2024-05-06

In the work, everyone will encounter a lot of problems, in the face of problems, how we should solve them, how to deal with them, how to make the problems small, and finally make the problems disappear, these are worth it. Sometimes, problems and difficulties are not the cause of life's difficulties, but the determining factor is often your attitude towards difficulties, and the different perspectives of viewing difficulties cause different results after difficulties, and most people are distressed because of their negative and negative emotions in the face of difficulties, rather than the difficulties themselves. This negative feeling makes them stagnant and ends up having trouble thinking about problems and solving problems. >>>More

19 answers2024-05-06

Generally speaking, when a baby swears, it may be because he does not get enough love, or that there is something in his heart that cannot be expressed well. Of course, there are some babies who say a lot of dirty words all day long, and he may have Trektorism. >>>More

5 answers2024-05-06

1. The voltage of the power supply is not enough.

Solution: Maintain a normal supply voltage. >>>More

13 answers2024-05-06

In fact, bad breath can be a reflection of internal organ imbalance, or a symptom of oral diseases such as tooth decay and sinusitis. Liver fever type: bad breath and kidney yin deficiency Spontaneous bad breath can be roughly divided into three types: >>>More

12 answers2024-05-06

In your case, it is social phobia, commonly known as "phobia of seeing people", and you have to ask an authority figure what to do. >>>More