In computer science, an event (also called event semaphore) is a type of synchronization mechanism that is used to indicate to waiting processes when a particular condition has become true.

An event is an abstract data type with a boolean state and the following operations:

  • wait - when executed, causes the executing process to suspend until the event's state is set to true. If the state is already set to true 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 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 are similar in principle to the condition variables used in monitors, although the precise mechanism of use is somewhat different.

Event 同步机制的更多相关文章

  1. 多线程模块的同步机制event对象

    多线程模块的同步机制event对象 线程的核心特征就是他们能够以非确定的方式(即何时开始执行,何时被打断,何时恢复完全由操作系统来调度管理,这是用户和程序员无法确定的)独立执行的,如果程序中有其他线程 ...

  2. windows核心编程 - 线程同步机制

    线程同步机制 常用的线程同步机制有很多种,主要分为用户模式和内核对象两类:其中 用户模式包括:原子操作.关键代码段 内核对象包括:时间内核对象(Event).等待定时器内核对象(WaitableTim ...

  3. 分析.Net里线程同步机制

    我 们知道并行编程模型两种:一种是基于消息式的,第二种是基于共享内存式的. 前段时间项目中遇到了第二种 使用多线程开发并行程序共享资源的问题 ,今天以实际案例出发对.net里的共享内存式的线程同步机制 ...

  4. Linux内核同步机制--转发自蜗窝科技

    Linux内核同步机制之(一):原子操作 http://www.wowotech.net/linux_kenrel/atomic.html 一.源由 我们的程序逻辑经常遇到这样的操作序列: 1.读一个 ...

  5. Python多线程(2)——线程同步机制

    本文介绍Python中的线程同步对象,主要涉及 thread 和 threading 模块. threading 模块提供的线程同步原语包括:Lock.RLock.Condition.Event.Se ...

  6. 【转】C#异步编程及其同步机制

    C#异步编程及其同步机制 本篇文章涵盖一下几部分内容: 1. 什么是异步编程,为什么会需要异步编程 2. .NET下的异步编程及其发展 3. .NET线程同步机制及线程间数据封送 4. 异步模式 5. ...

  7. Innodb 锁系列1 同步机制

    同步机制 Innodb实现了不依赖于平台的mutex,rwlock. 1. 全局变量 对于mutex, rwlock,都有一个全局链表. 1. mutex全局链表:mutex_list 2. rwlo ...

  8. linux 同步机制之complete【转】

    转自: http://blog.csdn.net/wealoong/article/details/8490654 在Linux内核中,completion是一种简单的同步机制,标志"thi ...

  9. JavaScript事件循环(Event Loop)机制

    JavaScript 是单线程单并发语言 什么是单线程 主程序只有一个线程,即同一时间片断内其只能执行单个任务. 为什么选择单线程? JavaScript的主要用途是与用户互动,以及操作DOM.这决定 ...

随机推荐

  1. HDU2571:命运(简单dp)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2571 没什么好说的,不过要处理好边界. 代码如下: #include <iostream> # ...

  2. while小用

    1.使用while打印1 2 3 4 5 6  8 9 10 #!/usr/bin/env python #encoding: utf-8 num = 1 while num < 11: if ...

  3. 用Tchromium替换webbrowser

    用Tchromium替换webbrowser 用惯了EmbeddedWB,不想换,但是IE内核一直存在内存泄漏问题,没办法,只有寻找替代品了. 要把用习惯的EmbeddedWB换成完全不一样的TChr ...

  4. Eclipse 中安装Browse Deployment Location插件

    Browse Deployment Location 功能的插件名称为: Pivotal tc Server Integration for Eclipse  可在Eclippse的Eclipse M ...

  5. Resharper 快捷键

    编辑   Ctrl + Space 代码完成 Ctrl + Shift + Space代码完成 Ctrl + Alt + Space代码完成 Ctrl + P 显示参数信息 Alt + Insert ...

  6. CentOS6升级Apache-httpd2.4.29

    本文档解决AppacheHttp由版本2.2.x升级到版本2.4.29的问题,安装需要先进行依赖软件包的安装,请检查相应依赖软件包安装情况,如系统已经正确安装相应依赖软件包,可略过,本文所述版本升级不 ...

  7. Java结对编程之挑战出题

    Java结对编程之挑战出题 需求分析 需求 对于挑战出题来说最主要的就是要产生的式子并将重复的式子去掉. 设计思路 具体的思路: 思路一: 原先我打算用集合中的元素的不重复性进行去重,这种思路的好处就 ...

  8. tinyxml优化之一

    原文链接:http://www.cnblogs.com/zouzf/p/4154569.html 最近在搞XML解析优化,公司引擎用了tinyxml1和tinyxml2两个XML库,后者的效率比前者高 ...

  9. matplotlib之散点图

    环境:windows系统,anaconda3 64位,python 3.6 1.初认识 基本代码如下: import numpy as np import matplotlib.pyplot as p ...

  10. Pandas系列

    系列(Series)是能够保存任何类型的数据(整数,字符串,浮点数,Python对象等)的一维标记数组.轴标签统称为索引. pandas.Series Pandas系列可以使用以下构造函数创建 - p ...