Event (synchronization primitive)
   HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, an event (also called event semaphore) is a type of
synchronization Synchronization is the coordination of events to operate a system in unison. For example, the conductor of an orchestra keeps the orchestra synchronized or ''in time''. Systems that operate with all parts in synchrony are said to be synchronou ...
mechanism that is used to indicate to waiting processes when a particular condition has become true. An event is an
abstract data type In computer science, an abstract data type (ADT) is a mathematical model for data types. An abstract data type is defined by its behavior (semantics) from the point of view of a ''user'', of the data, specifically in terms of possible values, pos ...
with a boolean state and the following operations: * wait - when executed, causes the suspension of the executing process until the state of the event is set to true. If the state is already set to true before wait was called, wait has no effect. * set - sets the event's state to true, release all waiting processes. * clear - sets the event's state to false. Different implementations of events may provide different subsets of these possible operations; for example, the implementation provided by
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
provides the operations wait (WaitForObject and related functions), set (SetEvent), and clear (ResetEvent). An option that may be specified during creation of the event object changes the behaviour of SetEvent so that only a single thread is released and the state is automatically returned to false after that thread is released. Events short of reset function, that is, those which can be completed only once, are known as
futures Futures may mean: Finance *Futures contract, a tradable financial derivatives contract *Futures exchange, a financial market where futures contracts are traded * ''Futures'' (magazine), an American finance magazine Music * ''Futures'' (album), a ...
.500 lines or less, "A Web Crawler With asyncio Coroutines" by A. Jesse Jiryu Davis and Guido van Rossum
says "implementation uses an asyncio.Event in place of the Future shown here. The difference is an Event can be reset, whereas a Future cannot transition from resolved back to pending."
Monitors Monitor or monitor may refer to: Places * Monitor, Alberta * Monitor, Indiana, town in the United States * Monitor, Kentucky * Monitor, Oregon, unincorporated community in the United States * Monitor, Washington * Monitor, Logan County, West ...
are, on the other hand, more general since they combine completion signaling with
mutex In computer science, a lock or mutex (from mutual exclusion) is a synchronization primitive: a mechanism that enforces limits on access to a resource when there are many threads of execution. A lock is designed to enforce a mutual exclusion concur ...
and do not let the producer and consumer to execute simultaneously in the monitor making it an event+
critical section In concurrent programming, concurrent accesses to shared resources can lead to unexpected or erroneous behavior, so parts of the program where the shared resource is accessed need to be protected in ways that avoid the concurrent access. One way to ...
.


References


External links


Event Objects
''Microsoft Developer Network''

Concurrency control
Synchronization primitive In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. ''Process synchronization'' refers to the idea that multiple processes are to join up or hands ...
Terms in science and technology {{compsci-stub