473,799 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is event autoreset operation atomic?

Hi all,

I have a named autoreset event (EventWaitHandl e) and two applications one
waits on the event and one sets the evet. Application A calls Set method and
free a thread in application B. What I want to know is when Set method
returns can I assume event is certainly reset?

Is this ordering always true :

1- Application A calls Set method (No doubt)
2- Application B gets out of lock (2 or 3 or uncertain)
3- Set method returns (2 or 3 or uncertain)
4- Event is certainly reset now (?)

Thanks in advance.
Aug 17 '06 #1
5 1959
Hello Vadym,
Does Set method return before or after thread B released?

Thanks.

"Vadym Stetsyak" <va*****@ukr.ne twrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Hello, Kürþat!

KIs this ordering always true :

K1- Application A calls Set method (No doubt)
K2- Application B gets out of lock (2 or 3 or uncertain)
K3- Set method returns (2 or 3 or uncertain)
K4- Event is certainly reset now (?)

Set method uses win32 SetEvent. In case of an auto-reset event docs say:
"The state of an auto-reset event object remains signaled until a single
waiting thread is released, at which time the system automatically sets
the state to nonsignaled. If no threads are waiting, the event object's
state remains signaled."

That is the order above will look like
1 - App A calls Set method
2 - App B thread is released & event is put to non-singnaled state
3 - Event is reset until next Set call

So, event becomes reset when waiting thread is released...

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Aug 17 '06 #2
Hello, Kursat!

AFAIK Set can exit before or after thread release.

Why do you care if its atomic?

IMO Set changes event object's state atomically, so there is no need to worry
about Set method itself.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Aug 17 '06 #3
Hi Vadym,

I try to set up a synchronization logic like this :

Thread A :
evt.Set (); // Release Thread B.
evt.WaitOne (); // Wait Thread B to complete.
// Thread B complete its job, go on

Thread B :
evt.WaitOne (); // Wait Thread A
doSomething ();
evt.Set (); // Job is done, release Thread A.

Initially Thread B waits Thread A to signal event. When Thread A signals
event, Thread B does something and Thread A waits on same event. After
Thread B completes its job it signals event and releases Thread A. Thus
Thread A knows when Thread B completes. This logic runs correctly only if
the event is certainly reset just after Set returns.

This is like SignalAndWait but only one WaitHandle used.
"Vadym Stetsyak" <va*****@ukr.ne twrote in message
news:uY******** ******@TK2MSFTN GP02.phx.gbl...
Hello, Kursat!

AFAIK Set can exit before or after thread release.

Why do you care if its atomic?

IMO Set changes event object's state atomically, so there is no need to
worry
about Set method itself.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Aug 17 '06 #4
Hello, Kursat!

[skipped]

KInitially Thread B waits Thread A to signal event. When Thread A signals
Kevent, Thread B does something and Thread A waits on same event. After
KThread B completes its job it signals event and releases Thread A. Thus
KThread A knows when Thread B completes. This logic runs correctly only
Kif the event is certainly reset just after Set returns.

Logic you've set up is correct Do you observe other results?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Aug 17 '06 #5
Hello Vadym,
It seems correct but observations are not enough to decide because, you
know, threads have random behaviors. So I think I must be sure about it
before use.

Thank you for your help.
"Vadym Stetsyak" <va*****@ukr.ne twrote in message
news:uH******** ******@TK2MSFTN GP06.phx.gbl...
Hello, Kursat!

[skipped]

KInitially Thread B waits Thread A to signal event. When Thread A
signals
Kevent, Thread B does something and Thread A waits on same event. After
KThread B completes its job it signals event and releases Thread A. Thus
KThread A knows when Thread B completes. This logic runs correctly only
Kif the event is certainly reset just after Set returns.

Logic you've set up is correct Do you observe other results?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Aug 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5277
by: Paul Moore | last post by:
I can't find anything which spells this out in the manuals. I guess that, at some level, the answer is "a single bytecode operation", but I'm not sure that explains it for me. This thought was triggered by a comment on the Python Cookbook site, which basically said that it was OK to do tss = {} ... id = thread.get_ident() tss = {}
18
2891
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
1
1837
by: Kashish | last post by:
Is file<<"Some string"<<endl is an atomic operation. where file is an ofstream object. If we output a string in ofstream and we provide endl after that,Can we make sure the whole string will be put in file at a time or the string can appear in parts.String lenfth is no more than 50 chars. I have 2 processes on different solaris boxes (NFS) running in parallel.one process writing lines to the file and other process reading lines from...
3
4508
by: Zeng | last post by:
Hello, Is the assignment operation atomic? That is if one thread assigns to static variable an object and another uses the object assigned to the variable, would it be safe? Thanks! zeng
12
4144
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. However in vb.net you get continual messages (even setting the system modal property). Firstly, are these two assumptions right and if so what is the approved
0
1662
by: qiangdi_he | last post by:
Hi, Pals, I am using WaitAny( ) to wait for the events triggered by a timer. But it seems like that when the timer's interval elapsed, and the event was set, but WaitAny is still waiting there. Basically, I want the statusBar's text change every 2 seconds. But since the WaitAny( ) doesn't stop, the statusBar's text changes every 10 seconds which is not what I want.
4
11133
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts the default of True. The Elapsed event handler updates the dialog box with how long before it will close, acting as a timer itself. The dialog has a time to close property which is checked every time the Elapsed event fires. The problem I have...
7
3607
by: Joe HM | last post by:
Hello - I was wondering if there is a simple way of ensuring that some statements are executed as an "atomic operation". Here is what I am dealing with in a GUI ... Dim mAppDomain As AppDomain The following sets the mAppDomain in a function ... mAppDomain = AppDomain.CreateDomain(lFullPathAssembly)
1
4525
by: spacehopper_man | last post by:
no "rename" operation in C# !!! - this has been covered in this group before, but I can't find any good answers. what I am trying to do is refresh the content in a file with minimum performance impact on any read operations to that file - a common task right.... in the unix world the way to do this is to create a temporary file with
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.