Busy waiting

Busy-wait ( also English called busy waiting ) denotes an activity of a computer program, showing the time until a condition is met actively bridged by execution of instructions, which do not alter the state of the program.

Implementation

Busy-wait by means of repeated instructions to be executed, it is checked with those of whether the condition is met, implemented:

While (condition b is not satisfied) {     do nothing; } Busy-wait apparently uses processor capacity for immediate, repeated checking whether the condition is met. In its pure form, no further actions are carried out the review.

Applications

Time bridging

Waiting is active often employed to bridge a period of a given length. The length of the bridging period has been adjusted to account for the execution time of one iteration of the loop by the programmer in a number of iterations to by running:

Int i = 0; while (i < num_iterationen ) {     i = i ​​1; } Modern programming using a hardware timer to wait for a certain period of time; active wait will only be used if no such timer available or to be waited period is very short.

Synchronization

More often than currently active bridging wait for synchronization of the activities of parallel / working components of a computing system is employed. The components are either only software components (processes or threads ) or to software and hardware components that cooperate with each other. In synchronization situations, the order in which the actions of the components executed, controlled, because any parallel or crossed in time execution of the actions is undesirable.

Common is the use of active waiting for synchronization in the following situations:

  • Status inquiry

While (condition b is not satisfied) {     wait for some time; } This variation of active waiting is also known as busy waiting or slow lazy polling. However, a prerequisite for a beneficial use that with the help of an operating system or a runtime environment the vacant processor capacity is used to run another program from the processor. A disadvantage of the option is in addition to the still existing, albeit reduced waste of processor capacity that is often waited longer than necessary because the condition is tested again after the expiration of the waiting period. Query a lock

Shared by A and B variable: lock Interpretation of the value: 0 disabled, not 0 open Initialization: lock = 0         Process A Process B     ......     while (lock == 0) { ...       ; lock = 1;     } ...     Action a ... Since the variable lock prevents the process / thread A is the action a continuing unchecked by B, the variable spinlock (lock ) is called. Since the change of variable by repeated ( rotating ) queries is detected, it is also called a spinlock. Spinlocks are a fundamental concept of process synchronization. see also

  • Software brake
38821
de