VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云优惠活动

关于过程和线程的常识点汇总

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

Difference and contact between process and procedure

1) Process is a movement of program and its data in computer, and it is a static concept. The operational entity of a process is a program, and the process of separating programs has no significance. From the static point of view, the process is composed of three parts: program, data and process control block (PCB). The program is a set of ordered instruction aggregation, which is a static concept. 2) A process is a process of performing a program, which is created and destroyed statically, has a certain life cycle and exists temporarily; while a program is a collection of codes, which exists forever and can be kept temporarily. 3) A process can perform one or several procedures, and a procedure can also constitute multiple processes. A process can be created, while a process can be transformed into a new process. 4) The composition of process and procedure is different. The process consists of program, data and PCB.

Deadlock and hunger

The completion of a semaphore quantity with a waiting queue can lead to a situation in which two or more processes are waiting for a thing with a limited amount of time, and that thing can only happen by one of these waiting processes. The thing here is the fulfillment of V operation (i.e. the release of capital). When presented in such a form, these processes are called deadlocked. To clarify, consider that a fragment consists of two processes P0 and P1, each of which calls on two semaphores s 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); } }

Assume that process P0 performs P (s), then process P1 performs P (q). When process P0 performs P (q), it must wait until process P1 performs V (q). Similarly, when process P1 performs P (s), it must wait until process P0 performs V (s). Because these two V operations cannot be performed, then process P0 and process P1 are deadlocked. To say that a group of processes are in deadlock mode means that each process in the group is waiting for an event, 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 deadlocks is limited blocking or "starvation," the condition in which a process waits indefinitely within a semaphore. The secondary cause of hunger is: in a static fragmentary capital, for each kind of fragmentary capital, operating fragmentary demand affirms a distribution strategy. When multiple processes request a certain kind of capital at the same time, the distribution strategy affirms the second place of capital distribution to the process. Sometimes capital distribution strategy can be unjust, that is, it can not guarantee the existence of waiting time. In this situation, some processes can wait for a long time even if there is no deadlock. When waiting time has a clear impact on process promotion and response, it is called "starvation" of the process. When the "starvation" to a certain level of the process is no longer of practical significance, it is called "starvation". For exle, when there are multiple processes that need to print documents, if the strategy of distributing printers piecemeal is to give priority to the shortest documents, the printing obligation of long documents will be postponed for a limited period due to the source of short documents from time to time, leading to the final "hunger" or even "starvation". "Hunger" does not mean that fragmentary things are bound to die, but at most one process is delayed by a limited period of time. The secondary differences between "hunger" and deadlock are as follows:

There is only one process to enter the "hungry" form, but the process to enter the deadlock form due to the premise of reincarnation must be greater than or equal to two.

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

The task principle of the silver hand algorithm

The secondary thought of the silver inside hand algorithm is to prevent the pieces from entering the unsafe form. Each time it stops capital distribution, it begins to reflect on whether there is enough capital to meet the requirements of fragmentary. If there is, it will be distributed by the predecessors, and stop safety reflection on the new form after distribution. If the new form is safe, the above-mentioned capital will be officially distributed, otherwise, the above-mentioned capital will be rejected. In this way, it ensures that the pieces are always in a safe state, so as to prevent the occurrence of deadlock.

Difference and connection of process synchronization and mutual exclusion

The performance of concurrent processes will have mutual restriction relations: one is the competition between processes and the use of critical capital, which can only be used one by one. This phenomenon is called mutual exclusion, which is a kind of competitive relationship; the other is the collaborative completion of obligations between processes, waiting for the sound from another process on the symptom node, so as to be consistent, which is a kind of collaborative relationship.

The relationship between homework and process

Process is the user of fragmentary capital, and most of the fragmentary capital is distributed by process. The computer is used by users to complete a series of related obligations, which are usually called homework.

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

In batch processing, the batch homework can be submitted to the fragments through magnetic recording equipment or card machine, and the homework will be put into the output well of the disk as the backup homework by the process of spooling output. When one of the back-up tasks is selected for operation, a process (called the root process) is created for the task at first. This process will perform the lesson master speech instruction procedure to explain the lesson copy list of the lesson. In the running process, the parent process can create one or more child processes statically and perform the statements in the copy list. For exle, for a compiled statement, the procedure can create a subprocess to execute the compiler and stop the compilation of the user's source program. Similarly, a subprocess can continuously create a subprocess to accomplish a specified function. As a result, a lesson is statically transformed into a group of operational entities - process families. When the parent process encounters the "withdraw homework" statement in the homework copy, it changes the homework from the operation mode to the completion mode, and sends the homework and related consequences to the input well on the disk. The job termination process is used to input the job in the input well by printer, receive the capital occupied by taking over the job, delete the data structure related to the job, delete the information of the job in the disk input well, etc. After removing a course, you can appeal to the course adjustment process to stop the new course adjustment. At this point, the work of entering the piecemeal operation is completed.

2) The relationship between homework and process in time sharing

In the time-sharing system, there are great differences between the submission and organization of homework and the batch disposal of homework. The time-sharing and fragmentary users output the edicts one by one and submit their homework steps. Each output of a (or a group of) edict directly corresponds to a (or several) process outside the fragment. At the time of startup, fragmentary sets up a process (called terminal process) for each terminal equipment, which performs the instructions of the edict, and the instructions of the edict are read in from the terminal equipment to perform each edict output by the user. For each terminal edict, a sub process can be created to perform it in detail. If the later terminal edict is a backstage edict, it can be handled in parallel with the next terminal edict. In the process of operation, each subprocess can create the offspring process according to the needs. After the corresponding process of terminal edict is completed, the function of the edict also ends. At the end of the user's access to the computer, the user will complete the access process after a login order. The time-sharing and fragmentary homework is a user's interaction process on the computer. We can think that the creation of the terminal process is the beginning of the interaction homework, and the end of the user's interaction homework is the end of the operation of the logout edict. The process of the command instruction program plays the role of mastering the speech instruction program in batch processing, except that the command instruction program accepts the command from the user terminal.

3) Submit batch assignments interactively

In the operation of supporting interaction and batch processing at the same time, people can use the interactive method to prepare the relevant procedures, data and homework master copy. For exle, we can compile a weather forecast program by using the full screen editing command provided by interactive fragmentary supply, turn the program into executable file by compiling and disassembling command, and stop the program debugging by debugging command. After the success of debugging, users should do the following tasks every day: prepare the original weather data, run the weather forecast to perform the document processing the original data, print out the consequences, etc. At this time, use the full screen editing command provided by interactive fragmentary supply to compile the homework to be submitted, such as windows fragmentary bat files and Linux fragmentary sh files. Then submit the homework to the piecemeal homework queue with a homework submission edict. There is a special course adjustment process to select the course from the course team. It creates a parent process for the selected course to operate the instruction procedure of the edict, indicating that the implementation of the edict in the copy document is mastered.


过程与程序的差别与联络

1) 过程是程序及其数据在盘算机上的一次运转运动,是一个静态的概念。过程的运转实体是程序,分开程序的过程没有存在的意义。从静态角度看,过程是由程序、数据和过程掌握块(PCB)三局部构成的。而程序是一组有序的指令聚集,是一种静态的概念。2) 过程是程序的一次履行进程,它是静态地创立和灭亡的,具有必定的生命周期,是临时存在的;而程序则是一组代码的聚集,它是永世存在的,可临时保管。3) 一个过程可以履行一个或几个程序,一个程序也可以组成多个过程。过程可创立过程,而程序弗成能构成新的程序。4) 过程与程序的构成分歧。过程的构成包含程序、数据和PCB。

死锁与饥饿

具有等候队列的旌旗灯号量的完成能够招致如许的状况:两个或多个过程有限地等候一个事情,而该事情只能由这些等候过程之一来发生。这里的事情是V操作的履行(即释放资本)。当呈现如许的形态时,这些过程称为死锁(Deadlocked)。为了加以阐明,思索到一个零碎由两个过程P0和P1构成,每一个过程都拜访两个旌旗灯号量S和Q,这两个旌旗灯号量的初值均为1。

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

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

假定过程P0履行P(S),接着过程P1履行P(Q)。当过程P0履行P(Q)时,它必需等候直到过程P1履行V(Q)。相似地,当过程P1履行P(S),它必需等候直到过程P0履行V(S)。因为这两个V操作都不克不及履行,那么过程P0和过程P1就死锁了。说一组过程处于死锁形态是指:组内的每一个过程都等候一个事情,而该事情只能够由组内的另一个过程发生。这里所关怀的次要是事情是资本的获取和释放。与死锁相干的另一个成绩是有限期壅塞(Indefinite Blocking)或“饥饿” (Starvation),即过程在旌旗灯号量内无量等候的状况。发生饥饿的次要缘由是:在一个静态零碎中,关于每类零碎资本,操作零碎需求肯定一个分派战略,当多个过程同时请求某类资本时,由分派战略肯定资本分派给过程的次第。有时资本分派战略能够是不公道的,即不克不及包管等候工夫上界的存在。在这种状况下,即便零碎没有发作死锁,某些过程也能够会长工夫等候。当等候工夫给过程推动和呼应带来分明影响时,称发作了过程“饥饿”,当“饥饿”到必定水平的过程所付与的义务即便完成也不再具有实践意义时称该过程被“饿死”。例如,当有多个过程需求打印文件时,假如零碎分派打印机的战略是最短文件优先,那么长文件的打印义务将因为短文件的源源不时到来而被有限期推延,招致最终的“饥饿”乃至“饿死”。“饥饿”并不表现零碎必定死锁,但至多有一个过程的履行被有限期推延。“饥饿”与死锁的次要差异有:

进入“饥饿”形态的过程可以只要一个,而因为轮回等候前提而进入死锁形态的过程却必需大于或等于两个。

处于“饥饿”形态的过程可所以一个停当过程,如静态优先权调剂算法时的低优先权过程,而处于死锁形态的过程则肯定是壅塞过程。

银里手算法的任务道理

银里手算法的次要思惟是防止零碎进入不平安形态。在每次停止资本分派时,它起首反省零碎能否有足够的资本知足请求,假如有,则先辈行分派,并对分派后的新形态停止平安性反省。假如新形态平安,则正式分派上述资本,不然就回绝分派上述资本。如许,它包管零碎一直处于平安形态,从而防止死锁景象的发作。

过程同步、互斥的差别和联络

并发过程的履行会发生互相制约的关系:一种是过程之间竞争运用临界资本,只能让它们逐一运用,这种景象称为互斥,是一种竞争关系;另一种是过程之间协同完成义务,在症结点上等候另一个过程发来的音讯,以便协统一致,是一种协作关系。

功课和过程的关系

过程是零碎资本的运用者,零碎的资本大局部多是以过程为单元分派的。而用户运用盘算机是为了完成一串相干的义务,平日把用户请求盘算机完成的这一串义务称为功课。

1) 批处置零碎中功课与过程的关系(过程组织)

批处置零碎中的可以经过磁记载装备或卡片机向零碎提交批功课,由零碎的SPOOLing 输出过程将功课放入磁盘的输出井中,作为后备功课。功课调剂程序(普通也作为自力的过程运转)每中选择一道后备功课运转时,起首为该功课创立一个过程(称为该功课的根过程)。该过程将履行功课掌握言语说明程序说明该功课的功课仿单。父过程在运转进程中可以静态地创立一个或多个子过程,履行仿单中的语句。例如,对一条编译的语句,该过程可以创立一个子过程履行编译程序对用户源程序停止编译。相似地,子过程也可以持续创立子过程去完成指定的功用。因而,一个功课就静态地转换成了一组运转实体——过程族。当父过程碰到功课仿单中的“撤出功课”的语句时,将该功课从运转形态改动为完成形态,将功课及相干后果送入磁盘上的输入井。功课终止过程担任将输入井中的功课应用打印机输入,收受接管功课所占用的资本,删除功课有关数据构造,删除功课在磁盘输入井中的信息,等等。功课终止过程除去一道功课后,可向功课调剂过程恳求停止新的功课调剂。至此,一道进入零碎运转的功课全体完毕。

2) 分时零碎中功课与过程的关系

在分时零碎中,功课的提交办法、组织方式均与批处置功课有很大差别。分时零碎的用户经过敕令言语逐条地与零碎应对式地输出敕令,提交功课步。每输出一条(或一组)敕令,便直接在零碎外部对应一个(或若干个)过程。在零碎启动时,零碎为每一个终端装备树立一个过程(称为终端过程),该过程履行敕令说明程序,敕令说明程序从终端装备读入敕令说明履行用户输出的每一条敕令。关于每一条终端敕令,可以创立一个子过程去详细履行。若以后的终端敕令是一条后台敕令,则可以和下一条终端敕令并行处置。各子过程在运转进程中完整可以依据需求创立子孙过程。终端敕令所对应的过程完毕后,敕令的功用也响应处置终了。用户本次上机终了,用户经过一条登出敕令即完毕上机进程。分时零碎的功课就是用户的一次上机交互进程,可以以为终端过程的创立是一个交互功课的开端,登出敕令运转完毕代表用户交互功课的终止。敕令说明程序流程饰演着批处置零碎中功课掌握言语说明程序的脚色,只不外敕令说明程序是从用户终端接纳敕令。

3) 交互地提交批功课

在同时支撑交互和批处置的操作零碎中,人们可以用交互的方法预备好批功课的有关程序、数据及功课掌握仿单。比方,可用交互式零碎供给的全屏幕编纂敕令编纂好自编的一个气象预告程序,用编译及拆卸敕令将程序酿成可履行文件,用调试敕令停止程序调试。在调试胜利后,用户天天都要做如下任务:预备原始气象数据,运转气象预告履行文件处置原始数据,把后果打印出来等。这时,用交互零碎供给的全屏幕编纂敕令编纂好将要提交的功课掌握仿单文件,如Windows零碎的BAT文件和Linux零碎的sh文件。然后用一条功课提交敕令将功课提交给零碎功课队列中。零碎有专门的功课调剂过程担任从功课队列当选择功课,为被拔取的功课创立一个父过程运转敕令说明程序,说明履行功课掌握仿单文件中的敕令。

--------------------------------------------------------------
主机参考,收集国内外VPSVPS测评主机测评云服务器虚拟主机独立服务器,国内外服务器高性价比建站主机相关优惠信息@zhujicankao.com
详细介绍和测评国外VPS主机,云服务器,国外服务器,国外主机的相关优惠信息,商家背景,网络带宽等等,也是目前国内最好的主机云服务器VPS参考测评资讯优惠信息分享平台

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:关于过程和线程的常识点汇总 https://zhujicankao.com/14023.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 关于过程和线程的常识点汇总
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!