[fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Krzysztof
Hi, I'm wondering if shared libraries (on Linux) support call exported function from multiple threads. I made small demo. Threads send JSON PChar into shared lib function which parse it and log in syslog. No global vars, everything locally in function. But even that I'm getting random errors

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Krzysztof wrote: Yes, I'm aware of cthreads and tested it too (without it also critical sections don't work) but it doesn't help with attached examples. Still same errors in logs Nevertheless, that should work. I've used it in multi-threaded apache modules. Michael.

Re: [fpc-pascal] Threading vs Parallelism ?

2017-03-30 Thread Mark Morgan Lloyd
On 30/03/17 08:00, Mark Morgan Lloyd wrote: Finally, I suggest that you look at least briefly at https://en.wikipedia.org/wiki/Vector_Pascal which appears to have some quite good stuff in it. Quoting from manual section 5.4. Future machines like the Larrabee will have considerably wider SIMD

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Krzysztof
Yes, I'm aware of cthreads and tested it too (without it also critical sections don't work) but it doesn't help with attached examples. Still same errors in logs ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Michael Van Canneyt wrote: On Thu, 30 Mar 2017, Krzysztof wrote: Yes, I'm aware of cthreads and tested it too (without it also critical sections don't work) but it doesn't help with attached examples. Still same errors in logs Nevertheless, that should work. I

Re: [fpc-pascal] Threading vs Parallelism ?

2017-03-30 Thread Mark Morgan Lloyd
On 29/03/17 22:30, fredvs wrote: @Karoly Balogh (Charlie/SGR) Perfect, I have now all the arguments to defend the "Dinosaur Threading"choice. Thanks. I'd second Charlie's point, and add that a very small change to a system's layout, e.g. a DIMM on a NUMA node going dodgy and being excluded

Re: [fpc-pascal] Something like TProcess.Environment for libraries ?

2017-03-30 Thread fredvs
Huh, sorry to come back with this but... Loadlibrary() for a sub-dependency works. ;-) For example: libopusfile.so has libopus.so as dependency. So, before to loadlibrary(libopusfile.so), do --> loadlibrary(libopus.so), keeping the original file-name. Example:

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Krzysztof wrote: 2017-03-30 15:19 GMT+02:00 Michael Van Canneyt Nevertheless, that should work. I've used it in multi-threaded apache modules. Well it doesn't work or fpjson module is not thread safe in this case. You can test it by

Re: [fpc-pascal] Threading vs Parallelism ?

2017-03-30 Thread Jon Foster
On 03/29/2017 01:15 PM, Michael Van Canneyt wrote: On Wed, 29 Mar 2017, Dimitrios Chr. Ioannidis via fpc-pascal wrote: Hi, On 29/3/2017 9:57 μμ, fredvs wrote: Hello. Some developers treat me as dinosaur because I use threads in place of doing parallelism. Huh, ok, but why parallelism

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Krzysztof
2017-03-30 15:19 GMT+02:00 Michael Van Canneyt > > > Nevertheless, that should work. > > I've used it in multi-threaded apache modules. > Well it doesn't work or fpjson module is not thread safe in this case. You can test it by yourself with attached demo (first post).

[fpc-pascal] Questions About Constructors

2017-03-30 Thread African Wild Dog
Hello, 1 - What happens if my constructor raise an exception? Is my destructor automatically called? 2 - Are the class fields automatically initialized to Default(T) just like in Delphi? Regards ___ fpc-pascal maillist -

Re: [fpc-pascal] Critical Section and Recursive Calls

2017-03-30 Thread Mattias Gaertner
On Thu, 30 Mar 2017 03:36:02 -0300 African Wild Dog wrote: > Hello, > > I'm writing a function protected by a critical section which can have > recursive calls under certain conditions. > > Using the TCriticalSection class, after my thread acquires a critical >

Re: [fpc-pascal] Questions About Constructors

2017-03-30 Thread Mattias Gaertner
On Thu, 30 Mar 2017 03:47:59 -0300 African Wild Dog wrote: > Hello, > > 1 - What happens if my constructor raise an exception? Is my destructor > automatically called? Yes. > 2 - Are the class fields automatically initialized to Default(T) just like > in Delphi?

Re: [fpc-pascal] Questions About Constructors

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, African Wild Dog wrote: Hello, 1 - What happens if my constructor raise an exception? Is my destructor automatically called? Yes. 2 - Are the class fields automatically initialized to Default(T) just like in Delphi? Yes. The're zeroed out when the memory for the

[fpc-pascal] Error on closing application when using a library.

2017-03-30 Thread fredvs
Hello. One of my application use libgcc_s_dw2-1.dll. Sadly, on Wndows 10 I've got "Runtime Error!", when closing the program. The dll is working but this appends if libgcc_s_dw2-1.dll is static or dynamically loaded. This is the message after closing the error-panel: Microsoft Visual C++

Re: [fpc-pascal] Delphi RTTI vs Free Pascal RTTI

2017-03-30 Thread African Wild Dog
2017-03-25 5:40 GMT-03:00 Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: > Am 24.03.2017 19:55 schrieb "Michael Van Canneyt" >: > > > > > > > > On Fri, 24 Mar 2017, African Wild Dog wrote: > > > >> Hello, > >> > >> I need to write a code compatilble with

[fpc-pascal] Critical Section and Recursive Calls

2017-03-30 Thread African Wild Dog
Hello, I'm writing a function protected by a critical section which can have recursive calls under certain conditions. Using the TCriticalSection class, after my thread acquires a critical section, if my thread make 6 additional calls to TCriticalSection.Enter, to release the critical section my