递归转化成非递归过程
As we all know that a procedure is a set of instruction written separately which can be used any time in the code when required. A normal procedure execution includes calling of the procedure, shifting the control of the processor to the procedure, and then returning the control to the calling program. This can be well understood as follows:
众所周知,过程是一组单独编写的指令,可在需要时随时在代码中使用。 正常的过程执行包括调用过程,将处理器的控制权移交给该过程,然后将控制权返回给调用程序。 可以很好地理解如下:
Apart from this, we have two special types of procedures: Recursive Procedures and Re-entrant procedures...
除此之外,我们有两种特殊类型的过程: 递归过程和重入过程 ...
1)递归程序 (1) Recursive procedures)
A recursive procedure is a procedure which calls itself. This results in the procedure call to be generated from within the procedures again and again. This can be understood as follows:
递归过程是一个调用自身的过程。 这导致从过程内部一次又一次地生成过程调用。 这可以理解为:
Image reference: https://images.app.goo.gl/kyJgWtWnF5faQfTe7
图片参考:https://images.app.goo.gl/kyJgWtWnF5faQfTe7
The recursive procedures keep on executing until the termination condition is reached. The recursive procedures are very effective to use and to implement but they take a large amount of stack space and the linking of the procedure within the procedure takes more time as well as puts extra load on the processor.
递归过程将继续执行,直到达到终止条件为止。 递归过程非常有效地使用和实施,但是它们占用了大量的堆栈空间,并且过程中的过程链接需要花费更多的时间,并且会给处理器带来额外的负担。
2)重入程序 (2) Re-entrant procedures)
The re-entrant procedure is a very special kind of procedure. In such kind of procedure, procedure 1 is called the mainline program, then procedure 2 is called form procedure 1 and then again procedure 1 is called form procedure 2. This can be well understood from the following diagram:
重入过程是一种非常特殊的过程。 在这种过程中,过程1称为主线程序,然后过程2称为表单过程1,然后过程1又称为表单过程2。这可以从下图中很好地理解:
Image reference: https://images.app.goo.gl/HKw5j6K6HQk79ki29
图片参考:https://images.app.goo.gl/HKw5j6K6HQk79ki29
This is called a re-entrant procedure because a procedure is re-entering into itself form another procedure which is also present inside its own body. The re-entrant procedure occurs in the following three conditions: when the procedure is undergoing recursion, when multi-threading is being implemented inside a program or when some interruption is being generated. Like the recursive procedures, it is important to have a termination condition for the procedures in the re-entrant procedures also, else we can face machine halts due to infinite procedure calls.
这称为重入过程,因为一个过程从另一个过程重新进入自身,该另一个过程也存在于其自身内部。 重入过程在以下三种情况下发生:当过程进行递归时,在程序内部实现多线程时或在生成某些中断时。 像递归过程一样,在重入过程中也要有一个终止条件,这一点也很重要,否则由于无限的过程调用,我们可能会遇到机器暂停的情况。
翻译自: https://www.includehelp.com/embedded-system/recursive-and-re-entrant-procedures-in-8086-microprocessor.aspx
递归转化成非递归过程