<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://groups.google.com/group/comp.programming.threads</id>
  <title type="text">comp.programming.threads Google Group</title>
  <subtitle type="text">
  All issues about multithreaded programming.
  </subtitle>
  <link href="/group/comp.programming.threads/feed/atom_v1_0_msgs.xml" rel="self" title="comp.programming.threads feed"/>
  <updated>2008-10-06T17:42:02Z</updated>
  <generator uri="http://groups.google.com" version="1.99">Google Groups</generator>
  <entry>
  <author>
  <name>Hallvard B Furuseth</name>
  <email>h.b.furus...@usit.uio.no</email>
  </author>
  <updated>2008-10-06T17:42:02Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/b86580f32b89bc47?show_docid=b86580f32b89bc47</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/b86580f32b89bc47?show_docid=b86580f32b89bc47"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  Safe both inside and outside a function; initialized at compile time. &lt;br&gt; If keeps that value I&#39;d insert a &amp;quot;const&amp;quot; there just to make that point &lt;br&gt; to myself, unless I need a non-const* pointer to it. &lt;br&gt; Or pthread_once() with a pthread_once_t variable. That&#39;s what they are &lt;br&gt; for.
  </summary>
  </entry>
  <entry>
  <author>
  <name>Anthony Williams</name>
  <email>anthony....@gmail.com</email>
  </author>
  <updated>2008-10-06T13:19:19Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/89ad0a6ddcd2970c?show_docid=89ad0a6ddcd2970c</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/89ad0a6ddcd2970c?show_docid=89ad0a6ddcd2970c"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  POD assignment in general is not atomic unless &lt;br&gt; sizeof(POD)==sizeof(int), even on platforms where plain ops on an int &lt;br&gt; are atomic (e.g. x86). &lt;br&gt; The lack of atomicity of the assignment is the only problem with &lt;br&gt; static initialization and threads. &lt;br&gt; This is not guaranteed to be safe prior to C++0x. If multiple threads
  </summary>
  </entry>
  <entry>
  <author>
  <name>Anthony Williams</name>
  <email>anthony....@gmail.com</email>
  </author>
  <updated>2008-10-06T13:13:37Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/b4c8a5749c90f2bc?show_docid=b4c8a5749c90f2bc</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/b4c8a5749c90f2bc?show_docid=b4c8a5749c90f2bc"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  Wrong. Initialization of a POD struct with an aggregate initializer &lt;br&gt; consisting only of constant expressions is static initialization and &lt;br&gt; must happen before the execution of the program begins. &lt;br&gt; This too is safe. &lt;br&gt; Totally agree here. Dynamic initialization is not safe. &lt;br&gt; Agree that this is still not safe: it&#39;s still dynamic initialization.
  </summary>
  </entry>
  <entry>
  <author>
  <name>David Schwartz</name>
  <email>dav...@webmaster.com</email>
  </author>
  <updated>2008-10-06T11:57:25Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/a8697d2f6063b6b8?show_docid=a8697d2f6063b6b8</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/a8697d2f6063b6b8?show_docid=a8697d2f6063b6b8"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  Simply make your code conditionally compile. Define a preprocessor &lt;br&gt; value that triggers this optimization. Ensure it is defined only on &lt;br&gt; platforms where this is known to be safe. You may wish to issue a &lt;br&gt; warning if you&#39;re running on a platform where it is not know to be &lt;br&gt; safe. The warning should get someone to check the platform.
  </summary>
  </entry>
  <entry>
  <author>
  <name>Dmitriy V&#39;jukov</name>
  <email>dvyu...@gmail.com</email>
  </author>
  <updated>2008-10-06T07:02:32Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/eb0cc5c0218b8570/f683e83b8b2e9551?show_docid=f683e83b8b2e9551</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/eb0cc5c0218b8570/f683e83b8b2e9551?show_docid=f683e83b8b2e9551"/>
  <title type="text">Re: supporting header-less blocks in memory allocators...</title>
  <summary type="html" xml:space="preserve">
  This should help: &lt;br&gt; void operator delete [](void* mem, std::size_t size) throw() &lt;br&gt; { &lt;br&gt; size = size * *(size_t*)mem + sizeof(size_t); &lt;br&gt; custom_allocator::deallocate(m em, size); &lt;br&gt; Dmitriy V&#39;jukov
  </summary>
  </entry>
  <entry>
  <author>
  <name>Chris M. Thomasson</name>
  <email>n...@spam.invalid</email>
  </author>
  <updated>2008-10-05T01:44:15Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/c519294cf0bbfc2e/387eec753fea0a85?show_docid=387eec753fea0a85</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/c519294cf0bbfc2e/387eec753fea0a85?show_docid=387eec753fea0a85"/>
  <title type="text">Re: want to kick the tires on a new multithreading tool?</title>
  <summary type="html" xml:space="preserve">
  [...] &lt;br&gt; Why switch from TBB?
  </summary>
  </entry>
  <entry>
  <author>
  <name>Chris M. Thomasson</name>
  <email>n...@spam.invalid</email>
  </author>
  <updated>2008-10-05T01:34:18Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/0f52138c6d818665?show_docid=0f52138c6d818665</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/0f52138c6d818665?show_docid=0f52138c6d818665"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  Yes; POSIX compliant compiler along with a POSIX library is the only way to &lt;br&gt; ensure correctness. &lt;br&gt; impl detail indeed.
  </summary>
  </entry>
  <entry>
  <author>
  <name>Brian Cole</name>
  <email>col...@gmail.com</email>
  </author>
  <updated>2008-10-04T21:50:23Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/b839b5106d430e4e?show_docid=b839b5106d430e4e</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/b839b5106d430e4e?show_docid=b839b5106d430e4e"/>
  <title type="text">POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  I know from previous posts on this list that function static &lt;br&gt; initialization is not thread safe. But in the case of initializing &lt;br&gt; plain old data (POD) from a re-entrant function that will return the &lt;br&gt; same value every time, the race condition appears to be &lt;br&gt; inconsequential. The assumption appears to be that POD assignment is
  </summary>
  </entry>
  <entry>
  <author>
  <name>Thomas Richter</name>
  <email>t...@math.tu-berlin.de</email>
  </author>
  <updated>2008-10-04T13:15:57Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/75a04f0b48751e7d?show_docid=75a04f0b48751e7d</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/75a04f0b48751e7d?show_docid=75a04f0b48751e7d"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  It&#39;s the matter of the compiler vendor to ensure that this works as &lt;br&gt; intended. Furthermore, as long as a variable has global static storage, &lt;br&gt; it might be initialized &amp;quot;at compile time&amp;quot; by placing the right data into &lt;br&gt; the data section of the executable, and at loading time, the problem &lt;br&gt; does not exist.
  </summary>
  </entry>
  <entry>
  <author>
  <name>Chris M. Thomasson</name>
  <email>n...@spam.invalid</email>
  </author>
  <updated>2008-10-04T11:51:49Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/8bd7945046a88564?show_docid=8bd7945046a88564</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/8bd7945046a88564?show_docid=8bd7945046a88564"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  [...] &lt;br&gt; do you think that: &lt;br&gt; PTHREAD_MUTEX_INITIALIZER &lt;br&gt; is busted?
  </summary>
  </entry>
  <entry>
  <author>
  <name>Thomas Richter</name>
  <email>t...@math.tu-berlin.de</email>
  </author>
  <updated>2008-10-04T09:02:01Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/2db2ca57e09633be?show_docid=2db2ca57e09633be</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/2db2ca57e09633be?show_docid=2db2ca57e09633be"/>
  <title type="text">Re: POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  All I know of. For example, &lt;br&gt; struct foo { &lt;br&gt; int a,b; &lt;br&gt; static struct foo f = {1,2}; &lt;br&gt; is a POD initialization, and if two threads run into this line of code, &lt;br&gt; it may happen that thread A initializes f.b while thread B is already &lt;br&gt; using f.b for something else, so no, this is definitely not safe. Even &lt;br&gt; if you return a copy of f from a function:
  </summary>
  </entry>
  <entry>
  <author>
  <name>Chris M. Thomasson</name>
  <email>n...@spam.invalid</email>
  </author>
  <updated>2008-10-04T05:41:41Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/eb0cc5c0218b8570/c17f35215d64929b?show_docid=c17f35215d64929b</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/eb0cc5c0218b8570/c17f35215d64929b?show_docid=c17f35215d64929b"/>
  <title type="text">Re: supporting header-less blocks in memory allocators...</title>
  <summary type="html" xml:space="preserve">
  Humm... What do you think about the following technique; here is a full &lt;br&gt; example program: &lt;br&gt; ______________________________ ______________________________ _____________ &lt;br&gt; static void* &lt;br&gt; thread_alloc_4(size_t size) { &lt;br&gt; void* const mem = malloc(size); &lt;br&gt; printf(&amp;quot;thread_alloc_4(%lu) -&amp;gt; %p\n&amp;quot;, &lt;br&gt; (unsigned long int)size, mem);
  </summary>
  </entry>
  <entry>
  <author>
  <name>Chris M. Thomasson</name>
  <email>n...@spam.invalid</email>
  </author>
  <updated>2008-10-04T05:19:59Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/eb0cc5c0218b8570/f721f3516acb02df?show_docid=f721f3516acb02df</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/eb0cc5c0218b8570/f721f3516acb02df?show_docid=f721f3516acb02df"/>
  <title type="text">Re: supporting header-less blocks in memory allocators...</title>
  <summary type="html" xml:space="preserve">
  Also, I don&#39;t think that your `object_t&#39; class needs to be a template at &lt;br&gt; all. Here is test code: &lt;br&gt; ______________________________ ______________________________ _____ &lt;br&gt; struct custom_allocator { &lt;br&gt; static void* allocate(std::size_t size) &lt;br&gt; throw(std::bad_alloc) { &lt;br&gt; void* const mem = std::malloc(size); &lt;br&gt; if (! mem) {
  </summary>
  </entry>
  <entry>
  <author>
  <name>Cilk</name>
  <email></email>
  </author>
  <updated>2008-10-04T01:13:15Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/c519294cf0bbfc2e/d849176d857c0a7e?show_docid=d849176d857c0a7e</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/c519294cf0bbfc2e/d849176d857c0a7e?show_docid=d849176d857c0a7e"/>
  <title type="text">want to kick the tires on a new multithreading tool?</title>
  <summary type="html" xml:space="preserve">
  We at Cilk Arts are soon (Jan &#39;09) going to release Cilk++ 1.0, with the &lt;br&gt; goal of delivering the easiest, quickest, and most reliable way to maximize &lt;br&gt; application performance on multicore processors. &lt;br&gt; We have an Early Visibility Program for folks interested in kicking the &lt;br&gt; tires on the alpha/beta versions of the product and multicore-enabling their
  </summary>
  </entry>
  <entry>
  <author>
  <name>Brian Cole</name>
  <email>col...@gmail.com</email>
  </author>
  <updated>2008-10-03T22:07:52Z</updated>
  <id>http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/1c92832f1c17b098?show_docid=1c92832f1c17b098</id>
  <link href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/97f15a078fc89e42/1c92832f1c17b098?show_docid=1c92832f1c17b098"/>
  <title type="text">POD function static initialization from function return, thread safe?</title>
  <summary type="html" xml:space="preserve">
  I know that static initialization is not considered threadsafe from &lt;br&gt; previous posts on this list. However, if a function static is POD &lt;br&gt; being initialized by a function call then the value should always be &lt;br&gt; initialized correctly, even if a inconsequential race condition &lt;br&gt; occurs. This assumes that POD assignments are atomic, what platforms
  </summary>
  </entry>
</feed>
