Saturday, March 18, 2017

Digest for comp.lang.c++@googlegroups.com - 25 updates in 13 topics

sangitachowdhary@gmail.com: Mar 18 06:08PM -0700

Hi,
 
I have one issue while using static variable. I have class dpst in my dynamic library, I am setting value for static variable in execute_before which is called inside library and in another function which is called from application I am reading its value. Unfortunately when I read value in updateShadowMemR from application it gives its value 0. I am not able to understand why? currAsync is class static variable which is read and set inside static function. Any help would be appreciated.

class dpst{
 
static Node * currAsync[MaxNumThreads];
public:

static void execute_before(THREADID threadid, void *arg1){. // called within a library
currAsync[threaid] = node;
}
 
static void updateShadowMemR(THREADID threadid, void *addr){. //called from application which uses this lib
std::cout<<"updateShadowMemR threadid "<<threadid<<" currAsync[threadid] "<<currAsync[threadid];
}
}
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 19 02:37AM +0100

> std::cout<<"updateShadowMemR threadid "<<threadid<<" currAsync[threadid] "<<currAsync[threadid];
> }
> }
 
Static variables are zero-initialized before anything else.
 
This means that if your variable is never assigned, you will read a zero.
 
And likely that is what happens: at the time `updateShadowMemR` is
executed, the variable, or at least the specific item in that array, has
not yet been assigned.
 
The possible causes include
 
• general bug in the application logic,
• the static initialization order fiasco,
• thread synchronization issue.
 
You can find out more about what's going on by using a debugger, such as
the one in Visual Studio if you're on Windows.
 
An alternative or supplement is to use trace output.
 
 
Cheers & hth.,
 
- Alf
sangitachowdhary@gmail.com: Mar 18 08:50PM -0700

On Saturday, March 18, 2017 at 9:37:30 PM UTC-4, Alf P. Steinbach wrote:
 
 
> An alternative or supplement is to use trace output.
 
> Cheers & hth.,
 
> - Alf
 
Thanks, I have been using trace output and its so weird that I can see it has been set but in another function its not
#ExecuteBefore currAsync[8648] 0x212b5d0 //in execute_before
#updateShadowMemW currAsync[8648] 0 //in updateShadowMemR
sangitachowdhary@gmail.com: Mar 18 08:52PM -0700


> Thanks, I have been using trace output and its so weird that I can see it has been set but in another function its not
> #ExecuteBefore currAsync[8648] 0x212b5d0 //in execute_before
> #updateShadowMemW currAsync[8648] 0 //in updateShadowMemR
 
nothing else has been done with this variable between these calls.
Ramine <toto@toto.net>: Mar 18 10:44PM -0400

Hello,
 
 
I have just read this about the C++11 Memory Model:
 
Some programming languages offer SC in multiprocessor environment. In
C++11, you can declare all shared variables as C++11 atomic types with
default memory ordering constraints. In Java, you can mark all shared
variables as volatile [1] [2].
 
Because the C++11 atomic types guarantee sequential consistency, the
outcome r1 = r2 = 0 is impossible. To achieve this, the compiler outputs
additional instructions behind the scenes – typically memory fences
and/or RMW operations. Those additional instructions may make the
implementation less efficient compared to one where the programmer has
dealt with memory ordering directly.
 
Read here:
 
https://people.cs.pitt.edu/~xianeizhang/notes/cpp11_mem.html
 
So, there is still a problem with C++, because so it is still error
prone if you forget C++11 atomic types to ensure sequential consistency
and it is less efficient with atomic types.
 
 
So i still prefer Delphi and FreePascal that don't reorder loads and stores.
 
 
 
Thank you,
Amine Moulay Ramdane.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 18 08:39PM -0700

On Saturday, March 18, 2017 at 10:44:35 PM UTC-4, Ramine wrote:
> Hello...
 
You are unique, Ramine. I have prayed for you.
 
Thank you,
Rick C. Hodgin
Ramine <toto@toto.net>: Mar 18 09:45PM -0400

Hello,
 
 
Bonita Montero is talking stupidity..
 
Because for her being a programmer is being a software engineer,
so it is like i have to prove to her that i can talk like a software
engineer and i can manage and implement large projects like a software
engineer, so she has a defect an she is not logical, because she don't
make a difference between a software technician and a software
engineer. I am like a software technician that has also invented many
synchronization algorithms etc. i am not a software engineer
that has to manage and implement large projects.
 
 
Thank you,
Amine Moulay Ramdane.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 19 03:00AM +0100

On 19-Mar-17 2:45 AM, Ramine wrote:
 
> [redacted] is talking stupidity..
 
You may have expected praise or at least technical discussion, for
providing your real-time software to the community.
 
Instead you're met with apparent hostility.
 
Why?
 
As I see it, one reason is because you post too frequently, in
individual new threads instead of one thread.
 
These frequent new threads are perceived as noise. They hide others'
messages. And just as with the noise of a fly that buzzes around your
head, the noise is annoying – more annoying the longer it goes on!
 
These folks who called you names and worse, they were desperate.
 
They wanted to stop that annoying noise.
 
 
Cheers & hth.,
 
- Alf
Jerry Stuckle <jstucklex@attglobal.net>: Mar 18 10:28PM -0400

On 3/18/2017 10:00 PM, Alf P. Steinbach wrote:
 
> They wanted to stop that annoying noise.
 
> Cheers & hth.,
 
> - Alf
 
The other point here is, Alf - his code is crap. He thinks he's
inventing great things. He isn't.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Ramine <toto@toto.net>: Mar 18 09:48PM -0400

Hello,
 
 
Bonita Montero is talking stupidity..
 
Because for her being a programmer is being a software engineer,
so it is like i have to prove to her that i can talk like a software
engineer and that i can manage and implement large projects like a
software engineer, so she has a defect and she is not logical, because
she doesn't make a difference between a software technician and a
software engineer. I am like a software technician that has also
invented many synchronization algorithms etc. i am not a software
engineer that has to manage and implement large projects.
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <toto@toto.net>: Mar 18 07:43PM -0400

Hello,
 
One last post here...
 
We have to be calm to think better now..
 
You have to know the prerequisites of political philosophy..
 
You have to know how to be tolerance to not create extremism and violence..
 
That's very important today, because today nationalism
is returning back with his weaknesses that is intolerance
toward others, so we have to be careful and know how to manage
ourselves and how to manage America and to not go into hating
others stupidly, life is still more difficult for many of us,
but when life is more difficult, we have the tendency to be
less tolerance, so to be smarter we have to discipline ourselves
and know how to make tolerance towards others, this is how we have
to manage smartly ourselves and this is especially important today.
 
 
This was my last post here in this forum.
 
Thank you,
Amine Moulay Ramdane.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 18 11:54PM

On 18/03/2017 23:43, Ramine wrote:
> and know how to make tolerance towards others, this is how we have
> to manage smartly ourselves and this is especially important today.
 
> This was my last post here in this forum.
 
You have said that this was your last post in this forum many many times
before and yet you keep coming back to post more crap. I really hope
you mean it this time.
 
/Flibble
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 18 05:08PM -0700

On Saturday, March 18, 2017 at 7:44:07 PM UTC-4, Ramine wrote:
> Hello,
 
> One last post here...
> We have to be calm to think better now..
 
If you truly believed that you would make it a reality for yourself
as well, Ramine. All you've demonstrated here in this forum is that
you are an uncontrolled hothead who has no interest in taking anyone's
advice except your own. Such a course of life is a recipe for total
disaster.
 
I pray you humble yourself and acknowledge that you are one of the
many on this planet, and that we must all work together if any of us
are to succeed. We all need each other. You need us, and we need
you ... but you exclude yourself from our interests by your own
actions.
 
I wish you well, Ramine. If you need help in achieving that inner
calm you are unable to achieve on your own, seek the Lord Jesus
Christ. He will teach you the way of peace, as it comes from Him
via the spirit, and not via the flesh. The flesh wars against us,
His Holy spirit brings peace to the flesh and focuses our interests
upon those things which are mutually helpful, entirely beneficial,
and uplifting and edifying for all. In short, His Holy Spirit seeks
to make ways that increase everybody, decrease nobody, and also mock
or belittle nobody. His is a spirit of love, and love in action.
 
Thank you,
Rick C. Hodgin
Ramine <toto@toto.net>: Mar 18 09:21PM -0400

Hello,
 
I want to clear something...
 
Bonita Montero is not logical.
 
Because when i have said that i am an experienced programmer, as you
have noticed i haven't said that i am a software engineer, have i said
that i am software engineer !? never ! never ! being an experienced
programmer is different, as i have invented many synchronization
algorithms and i am an experienced programmer in Delphi and Freepascal,
and i have also implemented my parallel compression library and my
parallel archiver etc etc. thus i can call myself an experienced
programmer, but Bonita Montero has assumed that i am not a programmer
because i am not implementing and managing larger projects ! this is
completly stupid, because implementing and managing larger projects
is the job of SOFTWARE ENGINEERS, this is why i think she is stupid !
 
So i am not a liar, because i am an experienced programmer too.
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <toto@toto.net>: Mar 18 09:19PM -0400

Hello,
 
I want clear something...
 
Bonita Montero is not logical.
 
Because when i have said that i am an experienced programmer, as you
have noticed i haven't said that i am a software engineer, have i said
that i am software engineer !? never ! never ! being an experienced
programmer is different, as i have invented many synchronization
algorithms and i am an experienced programmer in Delphi and Freepascal,
and i have also implemented my parallel compression library and my
parallel archiver etc etc. thus i can call myself an experienced
programmer, but Bonita Montero has assumed that i am not a programmer
because i am not implementing and managing larger projects ! this is
completly stupid, because implementing and managing larger projects
is the job of SOFTWARE ENGINEERS, this is why i think she is stupid !
 
So i am not a liar, because i am an experienced programmer too.
 
 
Thank you,
Amine Moulay Ramdane.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 19 02:07AM +0100

Usenet, with groups like this one, predates the World Wide Web.
 
There are well over 120 000 Usenet groups like comp.lang.c++, and they
have a supporting infra-structure that, unfortunately, is in disarray.
 
The /tone/ in technical Usenet groups used originally to be technical
and with little mercy on those who tried to treat the groups as social
arenas. Courtesy as the default was common, but it was not uncommon to
e.g. respond with just "RTFM", which means, Read The Fucking Manual, to
an equally rude request for basic information (that's rude because it
asks others to do one's work). M.I.T., the Massachusetts Institute of
Technology, still maintains its old RFTM site,
 
<url: ftp://rtfm.mit.edu/pub/>
 
I think that as a long as M.I.T. maintains a site called Read The
Fucking Manual, as they do, even if the contents are just archaic stale
information, all cannot be lost – there are apparently still folks with
intelligence, direction, and a sense of humor.
 
• • •
 
The common rules for behavior in groups is called netiquette.
 
General netiquette is dicussed in RFC 1855, available at e.g.
 
<url: https://tools.ietf.org/html/rfc1855>
 
An RFC, a "Request For Comments", is akin to a standard for some aspect
of the Internet. Many RFCs are treated as effectively standards, e.g.
the ones governing e-mail protocols and the like. But the intent was
that the RFCs should evolve, via comments and discussion, into formally
adopted Internet standards, ISs .
 
Netiquette specifically for this group, comp.lang.c++, was part of the
C++ FAQ Lite maintained by Marhshall Cline via community input, where
the community was comp.lang.c++. That FAQ has since evolved into the C++
Super FAQ maintained by Cline, Stroustrup, Alexandrescu and Sutter, at
<url: https://isocpp.org/faq>, but that version lacks the clc++
netiquette part. The original is however still available from
 
<url: http://www.dietmar-kuehl.de/mirror/c++-faq/how-to-post.html>
 
and from a host of mirrors, including translations to other languages.
 
The netiquette part has many individual FAQs (frequently asked
questions), but I reproduce here as particularly relevant, the item
about how to post a question about code that doesn't work:
 
<FAQ 5.8 question about code that doesn't work>
Key guidelines:
 
• Post compile'able code: avoid ellipses, such as void f() { ... }
• Post complete code: put in all necessary #includes and declarations of
needed types and functions
• Post minimal code: just enough to demonstrate the problem; skip I/O
and calls to libraries if possible
• Post one compilation unit: if possible, combine Foo.h into Foo.cpp
• Post the tools you used: compiler name, version number, operating
system, etc
• Post the tool options you used: libraries, exact compiler and linker
options, etc
• Post the exact messages you received; differentiate between compiler,
linker, and runtime messages
• Make sure main() has a return type of int, not void!
</FAQ 5.8 question about code that doesn't work>
 
• • •
 
Seen through a service like Google Groups the 120 000+ Usenet groups may
appear to be hosted by Google, and may appear to be just like other
Google groups. But a Usenet group isn't hosted on any particular server.
Instead Usenet is based on a distributed model where Usenet servers,
called NNTP servers, forward new postings to each other.
 
This means that
 
• A posting does not always appear instantaneously to someone else.
It may have to be forwarded through a lot of servers. Takes time.
 
• Others may not always have available the preceding postings.
Please quote what's relevant (and only that) of what you respond to.
 
• Postings can't in practice be deleted.
There is a mechanism for deletion but deletion in a distributed
forwarding system is difficult and error-prone, unreliable.
 
Postings are archived by various third parties. Originally there was
only one really big archive-it-all archive, called Deja News. That was
bought by Google. Google changed it into Google Groups, which is partly
a web interface to Usenet, and partly a discussion site that includes
non-Usenet Google groups. One can't easily see whether a group is a
Google group, hosted by Google, or a Usenet group, mirrored by Google.
 
For the Usenet groups it's possible to request, via a message's headers,
that it should not be archived forever, but only a certain short period.
And e.g. Google Groups honors that by deleting the message after the
specified time.
 
Still, if others quote the message, those quoted parts will live on.
 
• • •
 
Usenet groups, but not pure Google groups, can also be accessed via a
/newsreader/ program.
 
On great advantage of a newsreader is that it typically supports
filtering. That is, you don't need to see, at all, the postings in a
certain thread, or the postings of a certain someone, or the postings
that include certain words; whatever.
 
I.e., newsreader = more comfort and higher signal/noise ratio.
 
You need an account at a Usenet server, those servers that propagate
Usenet messages.
 
Eternal September is one free such server, the one I use.
 
Mozilla Thunderbird is one free newsreader. The Opera web browser is
another. There is a list in Wikipedia,
 
<url: https://en.wikipedia.org/wiki/List_of_Usenet_newsreaders>
 
• • •
 
Finally, comp.lang.c++ lacks a /charter/.
 
Other newsgroups generally did have charters.
 
The now defunct moderated sister group to this one,
comp.lang.c++.moderated, did have a charter, but googling it I did not
find it. As I recall that charter defined as off-topic postings about
how to use any particular API: a flood of Windows API postings in
comp.lang.c++ was a main reason that the moderated group was created.
The FAQ Lite stated that any posting in comp.lang.c++ should be
answerable with reference only to the official ISO C++ standard.
 
However, in 2017, with very high traffic not a problem, I think
comp.lang.c++ should be far more inclusive. That's just my personal
opinion, of course, but I state it as possibly a point of discussion.
 
 
Cheers!,
 
- Alf
Ramine <toto@toto.net>: Mar 18 08:07PM -0400

Hello,
 
 
This is my last post here on this forum of C++.
 
 
Thank you,
Amine Moulay Ramadane.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 18 05:16PM -0700

On Saturday, March 18, 2017 at 8:07:48 PM UTC-4, Ramine wrote:
> Hello,
> This is my last post here on this forum of C++.
 
Words mean nothing, Ramine. You demonstrate the things you pursue
not by your words, but by your actions, and your actions are that
which we all take exception to.
 
Bring your actions into proper alignment with acceptable behavior,
and others will begin to respond positively to you. Keep on the
path you're on and you'll encounter resistance, shunning, excited
responses from people, leading to isolation, self-delusion and un-
ending loneliness.
 
There is another way, but you must be the one who chooses to walk
its path.
 
Thank you,
Rick C. Hodgin
Ramine <toto@toto.net>: Mar 18 08:05PM -0400

Hello,
 
 
About me again...
 
I have read quickly many posts here, and i have noticed
that many of you are experienced programmers, and since
i am not stupid, i have asked myself what is that you are doing
mostly ? and here how i have answered this question: I think
that in softwere engineering we first have to program in C++ or/and
Object Pascal or/and Java, but after that we begin to learn how to
manage bigger projects by learning the V&V methods and by learning
extreme programming and agile and design by contracts etc. and i think
that this methodologies look like guidelines of ISO that we have to
follow to be able to simplify complexity and to make bigger projects,
this what i have noticed here , you are often doing for example
meta-programming with templates, and using templates etc. to succeed in
the goal of managing successfully larger projects.. i have notice it
here on this forum of C++, but my interest is not managing larger
projects as has thought falsely Bonita Montero, but i have invented many
synchroniation algorithms and i have invented softwares to do
parallel programming like my threadpools that scales well,
and i have invented my parallel compression library and my
parallel archiver etc. to also show you that i was interested
in parallel programming and synchronization algorithms.
 
 
Thank you,
Amine Moulay Ramdane.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 18 05:13PM -0700

On Saturday, March 18, 2017 at 8:05:48 PM UTC-4, Ramine wrote:
> About me again...
 
Until you make your life about other people, your life will have no
meaning, Ramine. It's not about you. It's about your place in the
community of people around you. It's about your unique and special
skills and talents given to benefit the community.
 
When you learn that simple lesson, you'll be on the right path.
 
I urge you to apologize to everyone here, Ramine. You owe it to
each of them. They are real people with real value and merit and
many of them come here to help other people gain knowledge and
experience so they can have better lives. You have offended them
greatly by your tirade. An apology would be a first step toward
reconciliation.
 
Thank you,
Rick C. Hodgin
Ramine <toto@toto.net>: Mar 18 07:40PM -0400

Hello,
 
One last post here...
 
We have to be calm to think better now..
 
You have to know the prerequisites of political philosophy..
 
You have to know how to be tolerance to not create extremism an violence..
 
That's very important today, because today nationalism
is returning back with his weaknesses that is intolerance
toward others, so we have to be careful and know how to manage
ourselves and how to manage America and to not go into hating
others stupidly, life is still more difficult for many of us,
but when life is more difficult, we have the tendency to be
less tolerance, so to be smarter we have to discipline ourselves
and know how to make tolerance towards others, this is how we have
to manage smartly ourselves and this is especially important today.
 
 
This was my last post here in this forum.
 
Thank you,
Amine Moulay Ramdane.
Jerry Stuckle <jstucklex@attglobal.net>: Mar 18 07:26PM -0400

On 3/18/2017 5:44 PM, Ramine wrote:
> before knowing.
 
> Thank you,
> Amine Moulay Ramdane.
 
You are a sexist pig, Ramine. And a very stoopid one, also.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Mar 18 07:24PM -0400

On 3/18/2017 6:11 PM, Ramine wrote:
>> rock would hire you.
 
> You are defending this Bonita Montero because she is female , but she is
> stupid !
 
No, I am defending here because she is right. And she's a lot more
intelligent than you are - that is quite obvious.
 
> Because she has made a big mistake that shows that she is not
> qualified to do real-time and safe-critical system programming
 
She's a hell of a lot more qualified to do ANY programming then you are.
 
> when i have studied to get a diploma in Microelectronics, and this
> why i have started to invent many synchronization algorithms ,
> and i have started to give code for real-time programming..
 
You've called yourself "an experienced programmer". And she did not
call you a "software engineer".
 
 
> https://sites.google.com/site/aminer68/c-synchronization-objects-library
 
> Thank you,
> Amine Moulay Ramdane.
 
It was crap in the original language, and it's even worse in C++. Any
student out of my advanced C++ class could do better. And they wouldn't
have to keep posting "fixes" because they'd get it right.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Mar 18 07:25PM -0400

On 3/18/2017 6:14 PM, Ramine wrote:
 
 
> Read again, i correct:
 
<Bullshit snipped>
 
No need to correct. You've already shown how stoopid you are. Calling
you an idiot would be an insult to idiots.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
"Chris M. Thomasson" <invalid@invalid.invalid>: Mar 18 04:24PM -0700

On 3/17/2017 12:52 AM, kushal bhattacharya wrote:
> thing in lock.it works for some steps but after that when i removing elements
> in later steps i get segmentation fault .What could be the probable reasons
> for this kind of issues ?
 
Fwiw, here is a quick and dirty little program I wrote that uses a c++
deque as a dynamic queue for a single producer, multiple consumer setup.
Here is the code:
_____________________________________
#include <cstdio>
#include <deque>
#include <condition_variable>
#include <mutex>
#include <memory>
#include <string>
#include <thread>
#include <algorithm>
#include <cassert>
 
 
template<typename T>
struct queue
{
typedef std::deque<T> raw_queue_t;
 
raw_queue_t m_queue;
std::condition_variable m_cond;
std::mutex m_mutex;
 
void push(T const& obj)
{
{
std::unique_lock<std::mutex> lock(m_mutex);
m_queue.push_back(obj);
}
 
m_cond.notify_one();
}
 
T pop()
{
T front;
 
{
std::unique_lock<std::mutex> lock(m_mutex);
while (! m_queue.size()) m_cond.wait(lock);
front = m_queue.front();
m_queue.pop_front();
}
 
return front;
}
};
 
 
typedef queue<unsigned int> string_queue_t;
#define CONSUMERS 5
#define N 1000
 
 
void producer(string_queue_t& queue)
{
std::printf("producer::queue::(%p) - enter\n", (void*)&queue);
 
for (unsigned int i = 0; i < N; ++i)
{
queue.push(i + 1);
std::this_thread::yield(); // just for some spice
}
 
for (unsigned int i = 0; i < CONSUMERS; ++i)
{
queue.push(0);
std::this_thread::yield(); // just for some spice
}
 
std::printf("producer::queue::(%p) - exit\n", (void*)&queue);
}
 
 
void consumer(unsigned int id, string_queue_t& queue)
{
std::printf("consumer(%u)::queue::(%p) - enter\n", id, (void*)&queue);
 
unsigned int prev = 0;
 
for (;;)
{
unsigned int msg = queue.pop();
 
std::printf("consumer(%u)::msg::(%u)\n", id, msg);
 
if (msg == 0) break;
 
assert(msg > prev); // validate fifo nature
 
prev = msg;
}
 
std::printf("consumer::queue::(%p) - exit\n", (void*)&queue);
}
 
 
int main(void)
{
{
string_queue_t queue;
 
std::thread consumers[CONSUMERS];
 
for (unsigned int i = 0; i < CONSUMERS; ++i)
{
consumers[i] = std::thread(consumer, i, std::ref(queue));
}
 
std::thread producer_thread(producer, std::ref(queue));
 
producer_thread.join();
 
for (unsigned int i = 0; i < CONSUMERS; ++i)
{
consumers[i].join();
}
}
 
std::printf("\nComplete, hit <ENTER> to exit...\n");
std::fflush(stdout);
std::getchar();
 
return 0;
}
_____________________________________
 
 
Can you run it?
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: