Blocking (computing)
Encyclopedia
Blocking occurs when a subroutine
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

 does not return until it either completes its task or fails with an error or exception. A process that is blocked is one that waits for some event
Event (computing)
In computing an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program. Typically events are handled synchronous with the program flow, that is, the program has one or more dedicated places where events are handled...

, such as a resource
Resource (computer science)
A resource, or system resource, is any physical or virtual component of limited availability within a computer system. Every device connected to a computer system is a resource. Every internal system component is a resource...

 becoming available or the completion of an I/O
I/O
I/O may refer to:* Input/output, a system of communication for information processing systems* Input-output model, an economic model of flow prediction between sectors...

 operation.

In a multitasking
Computer multitasking
In computing, multitasking is a method where multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is actively executing instructions for...

 computer system, individual tasks, or threads of execution, must share the resources of the system. These resources might be:
  • the CPU
  • network
  • memory
  • disk


When one task is using a resource, it is generally not possible, or desirable, for another task to access it. The techniques of mutual exclusion
Mutual exclusion
Mutual exclusion algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections. A critical section is a piece of code in which a process or thread accesses a common resource...

 are used to prevent this concurrent use. When the other task is blocked, it is unable to execute until the first task has finished using the shared resource.

Programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

s and scheduling algorithms are designed to minimize this blocking, and to prevent the case of deadlock
Deadlock
A deadlock is a situation where in two or more competing actions are each waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like the "chicken or the egg"...

, where two or more tasks are blocked, waiting for a resource that the other holds.

In a hypothetical two-state
Process states
In a multitasking computer system, processes may occupy a variety of states. These distinct states may not actually be recognized as such by the operating system kernel, however they are a useful abstraction for the understanding of processes....

 (running and not-running) model, processes would go onto the ready queue before being dispatched for execution. In the absence of a blocked state, if priority is measured by holdup time, blocked processes would erroneously get scheduled despite having nothing to operate on. This is undesirable due to inefficient processor usage. Hence the efficient use of resources makes a case for a blocked queue in which processes line up until the event dependency resolves.

Once the event fires, the process is advanced from blocked state to an imminent one, such as runnable.

See also

  • Non-blocking synchronization
    Non-blocking synchronization
    In computer science, a non-blocking algorithm ensures that threads competing for a shared resource do not have their execution indefinitely postponed by mutual exclusion...

  • Concurrent computing
    Concurrent computing
    Concurrent computing is a form of computing in which programs are designed as collections of interacting computational processes that may be executed in parallel...

  • Race condition
  • Deadlock
    Deadlock
    A deadlock is a situation where in two or more competing actions are each waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like the "chicken or the egg"...

  • Scheduling (computing)
    Scheduling (computing)
    In computer science, a scheduling is the method by which threads, processes or data flows are given access to system resources . This is usually done to load balance a system effectively or achieve a target quality of service...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK