Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of common sense points about processes and threads

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

The difference and connection between process and procedure

1) the process is a movement of the program and its data on the computer, and it is a static concept. The running entity of the process is the program, and the process of separating the program has no meaning. From a static point of view, the process is composed of three parts: program, data and process mastery block (PCB). The program is a set of ordered instruction aggregation, which is a static concept.

2) the process is a process of execution of the program, which is created and perished statically, has a certain life cycle and exists temporarily, while the program is a collection of a group of codes that exists forever and can be kept temporarily.

3) A process can perform one or more programs, and a program can also form multiple processes. A process can create a process, and a program can form a new program.

4) there are differences between the composition of process and procedure. The composition of the process consists of programs, data and PCB.

Deadlock and Hunger

The completion of the number of signals with a waiting queue can lead to a situation in which two or more processes are waiting for an event that can only happen by one of these waiting processes. The thing here is the fulfillment of operation V (that is, the release of capital). When presented in such a form, these processes are called Deadlocked.

To clarify, consider that a piecemeal consists of two processes P0 and P1, each of which visits two signal quantities S and Q, both of which have an initial value of 1.

P0 () {While (1) {P (S); P (Q); / / … V (S); V (Q);}} p1 () {While (1) {P (Q); P (S); / / … V (Q); V (S);}}

It is assumed that process P0 fulfills P (S), and then process P1 performs P (Q). When process P0 fulfills P (Q), it must wait until process P1 fulfills V (Q). Similarly, when process P1 fulfills P (S), it must wait until process P0 fulfills V (S). Because neither of these V operations can be performed, procedure P0 and procedure P1 are deadlocked.

To say that a group of processes is deadlocked means that every process in the group waits for one thing, which can only happen by another process in the group. The secondary concern here is the acquisition and release of capital.

Another achievement associated with deadlock is Indefinite Blocking or Starvation, a condition in which the process waits indefinitely within the number of signals.

The secondary reason for hunger is that in a static piecemeal, for each type of piecemeal capital, the operation of piecemeal requirements must have an allocation strategy, and when multiple processes request a certain type of capital at the same time, the allocation strategy affirms the order of capital allocation to the process. Sometimes the strategy of capital allocation can be unfair, that is, it cannot guarantee the existence of the upper bound of waiting time. In this case, even if there is no deadlock in bits and pieces, some processes can wait for a long time. When waiting for time to have a clear impact on the promotion and echo of the process, it is said that the process is "hungry", and when the obligations imposed by the process of "hunger" to a certain level are no longer of practical significance, it is said that the process is "starved to death".

For example, when there are multiple processes that require printing documents, if the strategy of the piecemeal dispatch printer is to give priority to the shortest files, then the obligation to print long documents will be postponed for a limited period due to the arrival of short documents from time to time, resulting in eventual "starvation" and even "starvation to death".

"Hunger" does not mean that bits and pieces must be deadlocked, but at most one process is delayed for a limited period of time. The secondary differences between "hunger" and deadlock are:

The process of entering the "hunger" form can be only one, while the process of entering the deadlock form because of the waiting premise of reincarnation must be greater than or equal to two.

The process in the "hunger" form can be a stop process, such as the low priority process in the static priority adjustment algorithm, while the process in the deadlock form must be a congested process.

The task truth of the silver hand algorithm

The secondary idea of the silver hand algorithm is to prevent bits and pieces from entering the insecure form. Each time it stops capital distribution, it begins to reflect on whether there is enough capital to meet the request, if so, the predecessor bank dispatch, and stop the safety reflection on the new form after the distribution. If the new form is safe, the above-mentioned capital will be formally allocated, otherwise the above-mentioned capital will be rejected. In this way, it ensures that the bits and pieces have been in a safe form, thus preventing the occurrence of a deadlock.

Differences and connections between process synchronization and mutual exclusion

The performance of concurrent processes will restrict each other: one is the competitive use of critical capital between processes, which can only be used one by one, which is called mutual exclusion, which is a competitive relationship; the other is the collaborative completion of obligations between processes. Waiting for a message from another process at the critical point, in order to be consistent, is a cooperative relationship.

The relationship between homework and process

The process is the user of piecemeal capital, and most of the piecemeal capital is allocated by the process as a unit. On the other hand, users use the computer to complete a series of related obligations, which are usually called homework.

1) the relationship between homework and process in batch disposal (process organization)

Batch disposal of bits and pieces can be done by magnetic recording equipment or card machine to submit batch homework to the bits and pieces, by the piecemeal SPOOLing output process to put the homework into the disk output well as backup homework. The homework adjustment program (which usually operates as an independent process) when you choose a backup lesson to run, start by creating a process for that lesson (called the root process of the lesson). This process will perform the homework to master the verbal description procedure to explain the homework imitation list of the homework. In the running process, the parent process can statically create one or more child processes to execute the statements in the imitation order. For example, for a compiled statement, the process can create a subprocedure to execute the compiler to stop compiling the user's source program. Similarly, a subprocess can continue to create a subprocess to perform a specified function. As a result, a homework is statically transformed into a group of running entities-the process family. When the parent process encounters the sentence of "withdraw homework" in the homework imitation list, it changes the homework from the running form to the completed form, and sends the homework and related consequences to the input well on the disk. The homework termination process is responsible for inputting the homework in the input well by printer, receiving the capital occupied by taking over the homework, deleting the data structure related to the homework, deleting the information of the homework in the disk input well, and so on. After removing a piece of homework from the homework termination process, you can plead with the homework adjustment process to stop the new homework assignment. At this point, all the homework that goes into piecemeal operation is over.

2) the relationship between homework and process in time-sharing.

In the time-sharing bits and pieces, the method of submission and organization of homework is very different from that of batch disposal. Time-sharing users submit their homework steps by outputting edicts one by one and dealing with them in bits and pieces. Every time a decree (or group of edicts) is output, it corresponds directly to one (or several) processes on the outside. At piecemeal startup, piecemeal sets up a process for each terminal device (called the terminal process), which performs the edict instruction program, which reads from the terminal equipment into the edict instruction to perform each edict output by the user. With regard to each terminal decree, a sub-process can be created to implement it in detail. If the future terminal edict is a background edict, it can be dealt with in parallel with the next terminal edict. In the process of operation, each sub-process can create descendant processes according to the needs. After the process corresponding to the terminal edict is completed, the function of the edict is also disposed of. At the end of the user's boarding this time, the user has completed the boarding process after a logout order.

Time-sharing homework is a computer interaction process for users. It can be considered that the creation of the terminal process is the beginning of an interactive lesson, and the completion of the operation of the imperial order represents the termination of the user interactive homework.

The process of the imperial edict program plays the role of mastering the verbal instruction program in handling bits and pieces, but the imperial edict program accepts the imperial order from the user terminal.

3) submit homework batches interactively

In the operation bits and pieces that support interaction and batch processing at the same time, people can use interactive methods to prepare procedures, data and homework mastery sheets for batch homework. For example, you can use the full-screen compilation edict of interactive piecemeal supply to compile a self-compiled weather forecast program, use compilation and disassembly edict to turn the program into executable files, and use debugging edict to stop program debugging. After the success of debugging, users have to do the following tasks every day: prepare the original meteorological data, run the weather forecast to perform the document to dispose of the original data, print the consequences, and so on. At this time, use the full-screen compilation order of interactive piecemeal supply to compile the homework to be submitted to master single files, such as Windows fragmentary BAT files and Linux piecemeal sh files. Then submit the homework to the piecemeal homework queue with a homework submission order. There is a special homework adjustment process that serves as a choice of homework from the homework queue, creating a parent process operation instruction procedure for the selected homework, explaining the performance of the imperial order in the homework mastery document.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report