>________________________________
> From: Carl Poirier <[email protected]>
>To: Marco Serantoni <[email protected]>
>Cc: Kicad Developers <[email protected]>
>Sent: Wednesday, January 22, 2014 3:51 AM
>Subject: Re: [Kicad-developers] Net names and net codes
>
>
>
>There are some things in the code that don't like being multithreaded. If I
>parallelize the for loop in RN_DATA::Recalculate( int aNet ), I get a
>segfault. It does not happen if I put a lock to the call updateNet( i ), but
>obviously there is no increase in performance. I'm trying to find out what's
>the problem now.
>
>
>
This sounds to me like data is being altered by different threads and possibly
there is some memory reallocation happening (growing arrays, etc). Locks are
only needed when there is contention somewhere and of course locks should only
be held for as short as needed. Another pitfall with threading is that some
variables may need to be declared 'volatile' if they can be altered in another
thread while one function is executing. For example, let's say the variable
'bool someX' can be altered in 2 threads; something like this can happen:
1. FunctionA starts, and runs a loop while(!someX) { ... }
2. FunctionB sets 'someX' to 'true'
3. FunctionA continues to run the loop, which is not the intended behavior
Of course similar things can happen when using shared memory and forked
processes.
Threading has other problems to watch out for - for example, are there any
static variables in functions? If so then you simply cannot thread those
functions without locks.
- Cirilo
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help : https://help.launchpad.net/ListHelp