[Lazarus] thread safe

Malcom Haak insanemal at gmail.com
Tue Jun 28 04:54:20 CEST 2011


On Tue, Jun 28, 2011 at 9:41 AM, Andrew Brunner
<andrew.t.brunner at gmail.com>wrote:

> 2011/6/27 Malcom Haak <insanemal at gmail.com>:
> > Tell me then why any of what you have said is relevant. In fact in cases
> > this this the use of CriticalSections would be sensible and would not
> cause
> > 'tons of wait' as you have all your worker threads off doing things 99%
> of
> > the time.
>
> Firstly, I was referring to my example



> Thread 1:
> a=b+c
> a2=a+c2
> SignalEvent(E1)
>
> This will run in 1 thread.. if you use local variables this is fine. if you
were using global variables you are an idiot.


> Thread 2:
>  repeat
>  WaitForEvent(E1,120);
>    We can read anything now
>  until terminated or complete
>

This the prime example.  On a 6 core system a looks like one value to
> one core than it does to another core.  It's that simple.  No getting
> around this issue.
>
> OF WHAT? bad code? It would only look different if you are looking at
different parts of memory.. or you hadn't finished writing.


> While spinlocks can block a entrance - it cannot guarantee memory
> order / code execution order.  Therefore it is good practice to adopt
> interlocked assignments to guarantee memory is what it is.
>
> Also what the hell are you on about? You could use CriticalSections in your
example and it would work fine. The fact you have one Thread doing nothing
for ever is a tad silly and to me shows you have no idea what you are
doing.. but that could be just because of the exceedingly limited scope of
the example.


>
> Core X computes a=b+c
> Core X+Y computes a2
>
> Why would you spilt this into different threads??
If it is the same thread it does not matter if it moves CPU...
Your example is lacking in sanity.


> This is relatively new theory which required low-level CPU code to
> perform such locks.  This was never needed until the introduction of
> multi-core systems.  Of which I did extensive tests on AMD via
> FPC/Lazarus.
>
> Yeah your just sounding silly here. As per Reimar Grabowski's comment,
whats the difference between multi-core and Multi-processor?
I'll tell you... accessibility to people who don't know what they are on
about.

> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110628/2d38cfa2/attachment-0003.html>


More information about the Lazarus mailing list