Thread overview
Even the experts get threading wrong
Aug 06, 2008
Walter Bright
Aug 07, 2008
dennis luehring
Aug 07, 2008
Walter Bright
Aug 07, 2008
dennis luehring
Aug 07, 2008
dennis luehring
August 06, 2008
http://www.ddj.com/cpp/209903274
August 07, 2008
Walter Bright schrieb:
> http://www.ddj.com/cpp/209903274

the problem is that even with such articles and detailed descriptions of the "problem" poeple tends to think that these types of errors do not touch their multithreaded development - because "the others have problems not i" and only a few people have seen multithreading errors
they are the very same as the aliens in the x-files tv-serie

aliens => multithreading race condititons
*the unknown
*the hidden
*in contact with the government

fox mulder => the expert doing threading
*known that aliens do exists
*try to catch them
*try to prevent others from being catched
*always telling dana that "the truth is out there"

dana scully => newbie to experienced developer
*got a feeling that aliens maybe could exist
*thinks that fox mulder is not an rational thinking guy
*not willing to see the truth

...
August 07, 2008
dennis luehring wrote:
> Walter Bright schrieb:
>> http://www.ddj.com/cpp/209903274
> 
> the problem is that even with such articles and detailed descriptions of the "problem" poeple tends to think that these types of errors do not touch their multithreaded development - because "the others have problems not i" and only a few people have seen multithreading errors
> they are the very same as the aliens in the x-files tv-serie

Yes. There are two serious problems with multithreaded programming:

1. The programmers who are confident they understand the problem, but do not. Their code may actually work for a long time before a problem shows up.

2. There's just no reliable way to look at a piece of code and determine if it has multithreading problems. Exhaustive testing is ineffective.

The D threading model aims to help by making certain kinds of subtle bugs impossible to express, and by narrowing the scope of where other types of errors may reside.

For example, the common double checked locking bug is impossible to express in D without subverting the type system.
August 07, 2008
> Yes. There are two serious problems with multithreaded programming:

100% ack

and the others try to fix their known-misunderstanding - by using large amounts of sychronization code - killing the speed of every algorithm downto a single thread solution - on an multicore system :-)

> For example, the common double checked locking bug is impossible to express in D without subverting the type system.

thats sound good to me

are there any plans of direct intergration of thread-creation/control ability into the language? aspects of corn concurreny programming?
http://cornlanguage.com/tutorial/index.html#5concr

and what about exceptions?
how to travel through the thread worlds

ciao dennis
August 07, 2008
from the corn tutorial:

 Corn programming language is finally also an concurrent language (if not to say: it is mainly parallel language). It provides many different kinds of concurrency, from starting alone threads, internally catching messages by selector class, executing one code in concurrently way in the same context of variables, up to mixing everything together. It also offers many synchronization methods for accessing the same resources, by independent threads.

The first, and the simplest example is to divide one thread into two threads working concurrently with the same variables. Syntax of that construction is a block of instructions with special char ( # ) :

{# ...thread 1... ; ...thread 2... ; ... }

Examples of usage:


    let x = ... ,
        y = ... ,
	z = ...
    in {
	...
	{# { x = y } ; { x = z } };   // x will be either y or z
	x = {# y ; z };               // x will be either y or z

	{# { x = 1 ; y = x; };
	   { x = 2 };
	};                            // x will be either 1 or 2; y will be x or 1

	{# { x = y }; { y = x } };    // try to guess the result :)

	iftrue {# true; false } {
	    // 50% chance to be here
	}
	else {
	    // 50% chance to be here
	};

	x = y.message(# {x = y},{ x = z } );
	    // params will be prepared concurrently
	    // so, the possibilities are: (y,z),(y,y),(z,z),but never (z,y)
    }

The above instructions make concurrently worked threads, and wait for their execution. There is also instructions to make threads, but not waiting for them.