Re: [Dev-C++] how to update data constantly?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jessica C. <jes...@gm...> - 2007-12-06 17:14:10
|
I don't understand this point. I think a cheaper form of semaphore (whatever for Win32 application or Unix application) is mutex. A critical section is a piece of code which access a shared resource (like data) of two threads. Can you pls do a bit more explanation about your issue? On Dec 6, 2007 5:43 AM, Per Westermark <pw...@ia...> wrote: > A cheaper form of mutex for Win32 applications are the critical > sections. In some situations a semaphore may be suitable. > > /pwm > > On Wed, 5 Dec 2007, Chris Miller wrote: > > > On Dec 5, 2007 1:10 PM, Jessica Chen <jes...@gm...> wrote: > > > My whole projects have two thread. > > > one thread is reading RS-232 communication port. > > > another thread is Win32 GUI to display the data got from RS-232 > > > communication port. > > > > > > The design I had is: > > > Buttons on Win32 GUI. > > > So when the button is clicked, the corresponding data is read from > RS232 > > > thread, and display in the GUI thread. > > > > > > BUT I want to have a constantly updated display. That is, there is NO > > > button to trigger the data update. > > > When the data of RS232 thread is updated, my display of GUI thread > need to > > > be updated. > > > What should I design? > > > > > > My consideration for the design is: > > > add a constant interval timer to trigger the data update. > > > but how to implement it? > > > and do you have any other good idea? > > > > A commonly used technique is to have the GUI thread check the reader > > thread every X miliseconds. This requires that you use a mutex to > > lock the data while it's being read, otherwise you might incur the > > wrath of undefined behavior when reading memory that's currently being > > written to. > > > > What if you had a dual-core CPU, and you managed to send a read > > request exactly when you sent a write request? Something tells me > > that's not possible because of the mutexes in the lower-level > > implementation, but it would be interesting to see which request the > > memory controller disregards. > > > > > > I'm not sure how to implement a mutex in a Win32 thread, however, > > pthreads is only a wrapper on top of Win32, so it can be done (I > > didn't notice any special code in the pthreads sources when I glossed > > over them). > > > > -- > > Registered Linux Addict #431495 > > http://profile.xfire.com/mrstalinman > > John 3:16! > > If Microsoft is the Wal*Mart of the Software World, then Linux is the > Home Depot > > > > > ------------------------------------------------------------------------- > > SF.Net email is sponsored by: The Future of Linux Business White Paper > > from Novell. From the desktop to the data center, Linux is going > > mainstream. Let it simplify your IT future. > > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > |