kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #12023
Re: Net names and net codes
>________________________________
> From: Carl Poirier <carl.poirier.2@xxxxxxxxx>
>To: Marco Serantoni <marco.serantoni@xxxxxxxxx>
>Cc: Kicad Developers <kicad-developers@xxxxxxxxxxxxxxxxxxx>
>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
Follow ups
References
-
Net names and net codes
From: Maciej Sumiński, 2014-01-08
-
Re: Net names and net codes
From: jp charras, 2014-01-08
-
Re: Net names and net codes
From: Tomasz Wlostowski, 2014-01-09
-
Re: Net names and net codes
From: Maciej Sumiński, 2014-01-10
-
Re: Net names and net codes
From: Vesa Solonen, 2014-01-10
-
Re: Net names and net codes
From: Maciej Sumiński, 2014-01-13
-
Re: Net names and net codes
From: Vesa Solonen, 2014-01-13
-
Re: Net names and net codes
From: Marco Serantoni, 2014-01-14
-
Re: Net names and net codes
From: Maciej Sumiński, 2014-01-14
-
Re: Net names and net codes
From: Marco Serantoni, 2014-01-14
-
Re: Net names and net codes
From: Carl Poirier, 2014-01-15
-
Re: Net names and net codes
From: Carl Poirier, 2014-01-21