0

I have inherited a large body of c++ code in a linux shared object that I suspect is not re-entrant.

Is there any way to run this code in multiple threads spawned from the same process, by ensuring each thread loads its own copy of the dll and maintains its own memory space?

1 Answers1

0

Of course not. Threads use the same memory space. Processes have separate memory spaces. So you'd need to run multiple separate processes if your code is not re-entrant.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • Thank you for the clarification. So I can spawn multiple processes and load my dll separately? This question seemed to address that (http://stackoverflow.com/questions/13080093/execute-multiple-processes-from-a-master-process) –  Aug 27 '14 at 22:47
  • A DLL normally uses the address space of the calling thread / process, and only shares the code. If the code is not re-entrant then you'll need to fix the code or run separate processes, and perhaps fix the code to use shared memory with some type of synchronization. – rcgldr Aug 27 '14 at 23:18