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:49:09
|
Hey, Chris, I think you really don't need to consider if it is dual-core or not. Just think it as one processor when you write code. The requests write or read, either one won't be disregards by memory controller. The OS will arrange this. I mean, low level software controls the sequence, not hardware itself. I used to use 4-core processor (a kind of SOC, system on a chip). Its OS provides me the interface of which I (users) can control the each core of the processor. So I(user) can decide which one I want to process first, either write request or read request. Thanks, Jessica --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. On Dec 5, 2007 5:32 PM, Chris Miller <lor...@gm...> 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 > |