FACTOID # 46: Japan has 53 working nuclear reactors and is planning to build another 12.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Monitor (synchronization)

A monitor is an approach to synchronizing two or more computer tasks that use a shared resource, usually a hardware device or a set of variables. A task is an execution path through address space. In other words, a set of program instructions that is loaded in memory. ... Computer hardware is the physical part of a computer, including the digital circuitry, as distinguished from the computer software that executes within the hardware. ... In computer science and mathematics, a variable (sometimes called a pronumeral) is a symbol denoting a quantity or symbolic representation. ...


Invented by Per Brinch Hansen, first implemented in the Concurrent Pascal language and used to structure inter-process communication in the Solo Operating System. Per Brinch Hansen. ...

Contents

Mutual exclusion

A monitor consists of:

A monitor procedure takes the lock before doing anything else, and holds it until it either finishes or waits for a condition (explained below). If every procedure guarantees that the invariant is true before it releases the lock, then no task can ever find the resource in a state that might lead to a race condition. A procedure is a series of activities, tasks, steps, decisions, calculations and other processes, that when undertaken in the sequence laid down produces the described result, product or outcome. ... Mutual exclusion (often abbreviated to mutex) algorithms are used in concurrent programming to avoid the simultaneous use of un-shareable resources by pieces of computer code called critical sections. ... In computer science, optimising compilers and the methodology of design by contract pay close attention to invariant quantities in computer programs, where the set of transformations involved is the execution of the steps of the computer program. ... A race hazard (or race condition) is a flaw in a system or process where the output exhibits unexpected critical dependence on the relative timing of events. ...


As a simple example, consider a monitor for performing transactions on a bank account. For other uses, see Bank (disambiguation). ...

 monitor account { int balance := 0 function withdraw(int amount) { if amount < 0 then error "Amount may not be negative" else if balance < amount then error "Insufficient funds" else balance := balance - amount } function deposit(int amount) { if amount < 0 then error "Amount may not be negative" else balance := balance + amount } } 

The monitor invariant in this case simply says that the balance must reflect all past operations before another operation can begin. It is usually not stated in the code but may be mentioned in comments. There are however programming languages like Eiffel, which can check invariants. The lock is added by the compiler. This makes monitors safer and more reliable than approaches that require the programmer to insert locking and unlocking operations by hand, since the programmer can forget them. In computer science, optimising compilers and the methodology of design by contract pay close attention to invariant quantities in computer programs, where the set of transformations involved is the execution of the steps of the computer program. ... In computer programming, a comment is a programming language construct that provides a mechanism for embedding information in the source code that is (generally) ignored by compilers and interpreters but may be of use to people reading the program source, or other programming tools that process the source such as... Eiffel is an object-oriented programming language which emphasizes the production of robust software. ... This article is about the computing term. ...


Condition variables

To avoid entering a busy waiting state, processes must be able to signal each other about events of interest. Monitors provide this capability through condition variables. When a monitor function requires a particular condition to be true before it can proceed, it waits on an associated condition variable. By waiting, it gives up the lock and is removed from the set of runnable processes. Any process that subsequently causes the condition to be true may then use the condition variable to notify a process waiting for the condition. A process that has been notified regains the lock and can proceed. It has been suggested that this article or section be merged with Polling (computer science). ...


The following monitor uses condition variables to implement an interprocess communication channel that can store only one integer value at a time.

 monitor channel { int contents boolean full := false condition snd condition rcv function send(int sent) { if full then wait(rcv) contents := sent full := true notify(snd) } function receive() { var int received if not full then wait(snd) received := contents full := false notify(rcv) return received } } 

Note that since waiting on a condition forfeits the lock, the waiter must make sure the monitor invariant is satisfied before it waits. In the example above, the same is true for notifying.


In early monitor implementations, notifying a condition variable caused a waiting process to receive the lock and run immediately, thereby guaranteeing that the condition would still be true. Implementing this behavior is complicated and has a high overhead. It is also incompatible with schedulers that can interrupt a process arbitrarily. For these reasons, researchers have considered various other semantics for condition variables. Scheduler can refer to many things: A person working in broadcasting, who is scheduling the content of a radio or television channel. ...


In most modern implementations, notifying does not take control away from the running process, but merely makes some waiting process runnable. The notifying process continues to hold the lock until it leaves the monitor function. The side effects of this approach are that the notifying process does not have to set up the monitor invariant before notifying, and the waiting process must double-check the condition it was waiting for. Specifically, if a monitor function includes the expression if test then wait(cv), another process could enter the monitor after the notification and make the condition untrue again before the waiting process runs. The expression must be rewritten as while test do wait(cv) so that the condition is re-checked before the process continues.


Implementations also provide a "notifyAll" or "broadcast" operation that notifies every process waiting on a given condition. This operation is useful, for example, when several processes are waiting for different amounts of storage to become available. Releasing storage can enable any number of these processes to proceed, but the scheduler does not know which ones.


A sample implementation for a Condition Variable is as follows:

 conditionVariable{ int queueSize = 0; semaphore lock; semaphore waiting; wait(){ lock.acquire(); queueSize++; lock.release(); waiting.down(); } signal(){ lock.acquire(); if (queueSize > 0){ waiting.up(); } lock.release(); } } 

History

Per Brinch Hansen was the first to describe and implement monitors, basing them on ideas from C. A. R. Hoare. Hoare subsequently developed the theoretical framework and demonstrated their equivalence to semaphores (when using the original semantics). Per Brinch Hansen. ... Sir Charles Antony Richard Hoare (Tony Hoare or C.A.R. Hoare, born January 11, 1934) is a British computer scientist, probably best known for the development of Quicksort, the worlds most widely used sorting algorithm, in 1960. ... A semaphore is a protected variable (or abstract data type) and constitutes the classic method for restricting access to shared resources (e. ...


Programming languages that have supported monitors include

The title given to this article is incorrect due to technical limitations. ... This article or section does not cite its references or sources. ... Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. ... Mesa is a programming language developed at Xerox PARC that was used to program the Xerox Alto (one of the first personal computers with a graphical user interface), and later the Xerox Star workstations, and later the GlobalView desktop environment. ...

External links


  Results from FactBites:
 
Monitor - Wikipedia, the free encyclopedia (436 words)
A monitor is a type of ship based on the USS Monitor and built by several navies for coastal defence in the 1860s and 1870s.
Monitor is a British organisation that regulates the NHS Foundation Trusts.
Monitor lizards are a family of large tropical lizards (Varanidae).
Monitor (synchronization) - Wikipedia, the free encyclopedia (548 words)
A monitor is an approach to synchronizing two or more computer tasks that use a shared resource, usually a hardware device or a set of variables.
In early monitor implementations, notifying a condition variable caused a waiting process to receive the lock and run immediately, thereby guaranteeing that the condition would still be true.
C# does not have monitors as a feature of the language, although the.NET framework has a class that facilitates implementation of Java-style monitors by hand.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.