- Need help understanding code segment - 1 Update
- [Cheesus Loves You] Muslim ISIS leader searches for truth, finds Jesus - 8 Updates
- Porting code generator to Android - 3 Updates
- C++ condition variable confusion - 10 Updates
Peabody <waybackNO584SPAM44@yahoo.com>: Mar 14 06:15PM -0500 I've written and compiled some very simple C programs, but never C++, and never anything this complicated and obscure. The code below is extracted from the TestReset.h source code file for Texas Instrument's BSL-Scripter.exe program that's used to do UART BSL flashing of newer MSP430 microcontrollers. Scripter is designed to be used with specialized hardware interfaces such as the "Rocket" and MSP-FET, both of which generate the special BSL invocation pattern on DTR and RTS. For reasons that are not clear, Scripter brings both lines low when it runs. I would like to at least get it to leave DTR high, or if possible actually generate the pattern itself so a generic USB-to- Serial adapter can be used as the hardware interface. Using a program called Agent Ransack, I searched all the source code files for occurrences pof any of the relevant labels that involve the DTR and RTS lines, and found that only TestReset.h contained any of them. Here's the relevant code section for RTS, which would be connected to the TEST pin of the MCU: #pragma once #include "stdafx.h" # define MSPBSL_ON_WIN # define BOOST_ASIO_OPTION_STORAGE DCB class TESTControl { private: uint16_t state; public: TESTControl(uint16_t initState) { state = initState; }; // constructor boost::system::error_code store(BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& error) const { if (state) { storage.fRtsControl = RTS_CONTROL_DISABLE; } else { storage.fRtsControl = RTS_CONTROL_ENABLE; } return error; }; // store boost::system::error_code load(BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& error) { if (storage.fRtsControl == RTS_CONTROL_ENABLE) { state = 0; } else { state = 1; } return error; }; }; I don't know anything about BOOST. It appears that something called "initState" is key to what's going on here, but I don't find that in any other source code file, or any occurrence of "TESTControl" either. Can someone explain what's going on here? Scripter does bring RTS low, which I believe is ENABLED, so I think that means initState is zero. But I don't know where that comes from. Also, I don't know what calls all this stuff. Any clarifications will be appreciated. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 14 03:27AM -0700 On Wednesday, March 13, 2019 at 3:49:37 PM UTC-4, Mr Flibble wrote: > [snip] Over 1,000 PhD scientists formally question Darwinian evolution. It doesn't seem plausible to them given the intricacy and variation of life, and life's internal processes. https://www.thenewamerican.com/tech/item/31694-over-1-000-scientists-openly-dissent-from-evolution-theory -----[ Begin ]----- ... And many of the scientists speaking out about this are prominent and highly respected. More than a dozen of the signatories, for instance, are members of various national academies of science, including those in the United States, Russia, Hungary, the Czech Republic, and other nations, as well as the Royal Society. More than a few come from America's most prestigious universities such as Harvard, MIT, Princeton, and Yale. Others come from prestigious foreign universities and research institutions such as the University of Cambridge, London's Natural History Museum, Moscow State University, Hong Kong University, University of Stellenbosch in South Africa, Institut de Paléontologie Humaine in France, Ben-Gurion University in Israel, and more. The experts speaking out also represent a broad array of scientific disciplines and fields. These include molecular biology, biochemistry, biology, entomology, computational quantum chemistry, microbiology, psychiatry, behavioral sciences, astrophysics, marine biology, cellular biology, physics, astronomy, math, geology, anthropology, and many more. Many medical doctors are raising questions, too. "As a biochemist I became skeptical about Darwinism when I was confronted with the EXTREME INTRICACY OF THE GENETIC CODE and its MANY most INTELLIGENT strategies to code, decode, and protect its information," explained Dr. Marcos Eberlin, founder of the Thomson Mass Spectrometry Laboratory and a member of the Brazilian National Academy of Sciences. ... -----[ End ]----- -- Rick C. Hodgin |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 14 03:34AM -0700 On Thursday, March 14, 2019 at 6:27:57 AM UTC-4, Rick C. Hodgin wrote: > National Academy of Sciences. > ... > -----[ End ]----- More: Neurosurgery Professor Dr. Michael Egnor at State University of New York, Stony Brook, argued that scientists "know intuitively that Darwinism can accomplish some things, but not others." "The question is what is that boundary? Does the information content in living things exceed that boundary? Darwinists have never faced those questions," he explained. "They've never asked scientifically, can random mutation and natural selection generate the information content in living things." Basically, Mark Armitage, a microscopist, found soft tissue in a dinosaur bone that was supposed to be around "65 million years old," strongly indicating that the dinosaur in question died much more recently. "Because no scientist can show how Darwin's mechanism can produce the complexity of life, every scientist should be skeptical," said biologist Douglas Axe, director of the Biologic Institute. "The fact that most won't admit to this exposes the unhealthy effect of peer pressure on scientific discourse." Truth is always victorious. It is invincible. -- Rick C. Hodgin |
fir <profesor.fir@gmail.com>: Mar 14 04:07AM -0700 W dniu czwartek, 14 marca 2019 11:34:44 UTC+1 użytkownik Rick C. Hodgin napisał: > Basically, Mark Armitage, a microscopist, found soft tissue in a dinosaur bone that was supposed to be around "65 million years old," strongly indicating that the dinosaur in question died much more recently. > "Because no scientist can show how Darwin's mechanism can produce the complexity of life, every scientist should be skeptical," said biologist Douglas Axe, director of the Biologic Institute. "The fact that most won't admit to this exposes the unhealthy effect of peer pressure on scientific discourse." > Truth is always victorious. It is invincible. youre idiot, if you wouldnt be one you would know that truth is no present here at all..stupidity of various levels is overwhelming..and you as imbecile sit in the deeper hole of it, talking your prionic cow head damaged cowshit and harming people wit your stupidness |
fir <profesor.fir@gmail.com>: Mar 14 04:08AM -0700 W dniu czwartek, 14 marca 2019 12:07:26 UTC+1 użytkownik fir napisał: > > "Because no scientist can show how Darwin's mechanism can produce the complexity of life, every scientist should be skeptical," said biologist Douglas Axe, director of the Biologic Institute. "The fact that most won't admit to this exposes the unhealthy effect of peer pressure on scientific discourse." > > Truth is always victorious. It is invincible. > youre idiot, if you wouldnt be one you would know that truth is no present here at all..stupidity of various levels is overwhelming..and you as imbecile sit in the deeper hole of it, talking your prionic cow head damaged cowshit and harming people wit your stupidness ps. if you go to jail for vandalistation take an additional month of imprisonmens specifically form me (^^) |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 14 05:05AM -0700 On Thursday, March 14, 2019 at 7:07:26 AM UTC-4, fir wrote: > present here at all..stupidity of various levels is overwhelming.. > and you as imbecile sit in the deeper hole of it, talking your > prionic cow head damaged .. and harming people wit your stupidness fir, you make these claims often. What are you basing them on? Have you read and studied the Bible to be able to say definitively, with first-hand knowledge, that it is untrue? I wasn't looking to be saved. But I was looking for the truth. I didn't think the Bible was true, but I wanted to get a true under- standing of the Bible so I could debunk it. I wanted to know fully accurately what it said so I could conclusively prove it to be false. When I set my sights on studying the Bible and in knowing the real truth about what it said, God opened up my understanding so I began to see, know, and understand things in a new way, a way I did not think was possible and would've argued actively against even as it was happening to me because I couldn't believe the change was real. It's the same for all people who come to Christ, fir. Until they are drawn from within, everybody thinks it's garbage, a crutch, some misguided internal need being filled by an invisible "sky daddy" or other such statement. It is the division of life and death in this world (spiritual life, spiritual death). Only those with the new life can understand what I am talking about, and those who are being drawn to the new life will be able to hear these words. The rest will not. You insult me because you are not being saved at present. The reason you are not being saved at present is because you aren't looking for the truth. You maintain the separation between yourself and God personally. It is not a limitation of God. It is your own internal state that keeps you separated from God. ==> Change that state, make a choice to come to know and understand ==> the truth ... and God will bring it to you, and you to it. As I tell you repeatedly, I pray you do seek the truth. You are a valuable creation of God, and I would like to see you thriving in eternity, restored to all God had intended for you before sin entered in and destroyed everything. -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 14 05:45PM On 14/03/2019 12:05, Rick C. Hodgin wrote: > valuable creation of God, and I would like to see you thriving in > eternity, restored to all God had intended for you before sin entered > in and destroyed everything. Nonsense. A) Your bible is false. B) Your god the existence of which is predicated on your bible being true is, given (A), also false. /Flibble -- "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 14 10:51AM -0700 On Thursday, March 14, 2019 at 1:45:25 PM UTC-4, Mr Flibble wrote: > [snip] The content which refutes your statement that evolution is scien- tific fact was given here and here: https://groups.google.com/d/msg/comp.lang.c++/E9OVNmULODg/BFrw81fRBgAJ https://groups.google.com/d/msg/comp.lang.c++/E9OVNmULODg/tXWtwbbRBgAJ The things you THINK you know are under question by PhD scien- tists. You've been lied to by the enemy spirit at work in this world in the leaders in science and the makers of public policy, Leigh. The truth is found in investigation and in seeking the truth. For you to continually regurgitate what you were told ... it does you no good because you're just repeating the lies you received. God gave YOU PERSONALLY faculties to examine this world for your- self. But if you refuse to do so, the liars have you. -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 14 08:54PM On 14/03/2019 17:51, Rick C. Hodgin wrote: > you no good because you're just repeating the lies you received. > God gave YOU PERSONALLY faculties to examine this world for your- > self. But if you refuse to do so, the liars have you. Nonsense. A) Your bible is false. B) Your god the existence of which is predicated on your bible being true is, given (A), also false. /Flibble -- "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
woodbrian77@gmail.com: Mar 13 06:56PM -0700 On Wednesday, March 13, 2019 at 2:58:09 AM UTC-5, David Brown wrote: > > https://www.reddit.com/r/cpp_questions/comments/b045qp/porting_code_generator_to_android/ > If I understand you correctly, you are trying to make the code generator > itself run on android? My code generator only runs on FreeBSD and I don't plan to change that at this time. But there's a front end (that I linked to in the reddit post) that I'm wanting to port to Android. > /Why/ ? No one would use Android as a host for > developing code. You cannot sanely use a pad or a telephone for C++ > programming. People don't do it now, and they will not do it in the future. Some people are programming on their phones: http://www.circuitbasics.com/programming-with-your-android-smartphone-the-tools-you-need/ I guess if you only have a small device available it could be helpful. If it was really difficult to port it, I'd probably skip it, but I don't think it will be that hard. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
Martijn van Buul <pino@dohd.org>: Mar 14 01:17PM * David Brown: > itself run on android? /Why/ ? No one would use Android as a host for > developing code. You cannot sanely use a pad or a telephone for C++ > programming. People don't do it now, and they will not do it in the future. Which is a crying shame, and cause for much frustration - along with its sibling statement "You cannot sanely use a Chromebook for C++ programming", this has caused me to abandon programming for these platforms. It may be pointless to develop on a phone - but my tablet had a very decent keyboard, and a reasonably fast CPU at the time. For ChromeOS, it is even worse. Google put PNaCl to rest, unfortunately, but while it was young and hip you had a technology which was *only* available on ChromeOS, but development could only be done cross-platform - unless you went through hacky hoops go get a chrooted Linux going, at the cost of very precious storage space and sub-par user experience. -- Martijn van Buul - pino@dohd.org |
David Brown <david.brown@hesbynett.no>: Mar 14 09:14PM +0100 On 14/03/2019 14:17, Martijn van Buul wrote: > this has caused me to abandon programming for these platforms. > It may be pointless to develop on a phone - but my tablet had a very decent > keyboard, and a reasonably fast CPU at the time. Very few tablets have a decent screen (for programming) or any kind of keyboard at all. I have difficulty imagining anyone choosing to use such a platform for serious development. (Occasional use for emergencies is understandable - I've used my mobile to ssh to my work computer and fix code a couple of times. But that was not development on the mobile - it was using the mobile as a terminal to access the development computer.) Chromebooks are another matter, and could be used as well (or as badly) as many other portables. Personally, I hate having to use a portable for programming - I am spoiled by having two large 2560 x 1600 screens. If I had a Chromebook and wanted to use it for programming, I'd wipe the ChromeOS and install Linux. |
johnbenny@nowhere.co.uk: Mar 14 12:00PM Hello all I'm trying to understand the condition variables with 2011 threads but I'm obviously missing something obvious. Can anyone see why the code below simply hangs and the thread never leaves the wait() called? My understanding is that wait() should exit immediately upon receiving a notification but this doesn't happen. #include <iostream> #include <thread> #include <mutex> #include <condition_variable> using namespace std; mutex mt; condition_variable cv; void func() { unique_lock<mutex> ul(mt); cout << "Thread waiting\n"; cv.wait(ul); cout << "Thread done\n"; } int main() { thread thr(func); cout << "notifying\n"; cv.notify_one(); thr.join(); return 0; } What the (probably stupid) mistake I'm making? |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 14 01:22PM +0100 > thr.join(); > return 0; > } The notification has to come after the thread has started waiting. Cheers!, - Alf |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 14 02:44PM +0200 > return 0; > } > What the (probably stupid) mistake I'm making? Before notifying, you need to raise a flag under the mutex lock, indicating that a notification is sent. This flag must be checked by the other thread, again under the mutex lock, *before* waiting, typically in a while loop to cope with spurious wakeups: unique_lock<mutex> ul(mt); while (!flag) { cout << "Thread waiting\n"; cv.wait(ul); } Basically, whenever you see in your code cv.notify*() without some variable change under a mutex lock, then it strongly smells for a data race. Even if your data is atomic, you still need to lock the mutex for synchronization. Ditto for cv.wait() without a data variable check between the mutex lock and wait. Another alternative is to use another wait() overload with a proper predicate which performs this simple loop for you. |
johnbenny@nowhere.co.uk: Mar 14 12:45PM On Thu, 14 Mar 2019 13:22:37 +0100 >> return 0; >> } >The notification has to come after the thread has started waiting. Ah, the notification isn't queued, I didn't know that. Is there a fullproof way of the main thread waiting until sub threads are ready? Setting a flag variable is subject to race conditions and so is calling sleep() unless you set it to sleep for 10 seconds or something to be absolutely sure the thread has reached wait()? |
johnbenny@nowhere.co.uk: Mar 14 12:52PM On Thu, 14 Mar 2019 14:44:29 +0200 > cout << "Thread waiting\n"; > cv.wait(ul); >} But its possible the main thread could set the flag and then call notify_one() before this thread executes and then the notify will still be lost and this thread will then still sit in wait() forever surely? |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 14 03:06PM +0200 > But its possible the main thread could set the flag and then call notify_one() > before this thread executes and then the notify will still be lost and this > thread will then still sit in wait() forever surely? That's why you check for the flag also *before* the waiting. |
scott@slp53.sl.home (Scott Lurndal): Mar 14 01:15PM >variable is subject to race conditions and so is calling sleep() unless you >set it to sleep for 10 seconds or something to be absolutely sure the thread >has reached wait()? cond wait needs an associated predicate, e.g.: /* * Wait for the unit reference count to become one. */ inline void c_file_card_unit::wait_for_delete(void) { pthread_mutex_lock(&cu_lock); while (cu_refcount > 1) { fprintf(stdout, "%4.4lu/%2.2lu Waiting for delete (refcnt=%lu)\n", cu_channel, cu_unit, cu_refcount); pthread_cond_wait(&cu_waiter, &cu_lock); } pthread_mutex_unlock(&cu_lock); } /* * Decrement the unit reference count. */ inline ulong c_file_card_unit::operator--(int) { ulong rval; pthread_mutex_lock(&cu_lock); rval = --cu_refcount; if (rval == 0) { pthread_cond_signal(&cu_waiter); } pthread_mutex_unlock(&cu_lock); return rval; } |
johnbenny@nowhere.co.uk: Mar 14 04:24PM On Thu, 14 Mar 2019 15:06:24 +0200 >> before this thread executes and then the notify will still be lost and this >> thread will then still sit in wait() forever surely? >That's why you check for the flag also *before* the waiting. I don't think this will work. It still does not guarantee that the child thread will arrive at wait() before the main thread has called notify_one(). |
Bonita Montero <Bonita.Montero@gmail.com>: Mar 14 06:12PM +0100 >> That's why you check for the flag also *before* the waiting. > I don't think this will work. It still does not guarantee that the child > thread will arrive at wait() before the main thread has called notify_one(). That's intended and this might result in a spurious wakeup of a thread. I.e. the wakeup might be consumed by another thread. Because of that the flag is checked in a loop to detect this kind of wakeups. |
Paavo Helde <myfirstname@osa.pri.ee>: Mar 14 08:48PM +0200 >> That's why you check for the flag also *before* the waiting. > I don't think this will work. It still does not guarantee that the child > thread will arrive at wait() before the main thread has called notify_one(). That's true, but this guarantee is not needed for anything. If the flag is already raised when the thread first comes around to lock the mutex, then it will know it has been already notified, and will not call wait() at all. Maybe you are thinking that thread synchronizations can be done by notify() and wait() only. Nope, for reliable synchronization you need the share a data state and communicate the data state (a single bit flag in this simple example). Mutexes, notifications and waits are just helpers for making this data sharing fast and reliable. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment