A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by philip_bennefall » Thu Dec 25, 2014 7:39 am
Hi all,
I am new to this library and am trying to figure out whether the core depends on Pthreads-win32. My reason for asking this is because I cannot use LGPL licensed code, while the Zlib license is just fine. Is there such a dependency, and if so, can it be removed?
Thanks in advance for any information on this.
Kind regards,
Philip Bennefall
-
philip_bennefall
-
- Posts: 3
- Joined: Thu Dec 25, 2014 7:34 am
by Julio Jerez » Thu Dec 25, 2014 10:14 am
The core depend on pThread yes.
On windows it use the opans source version,
on other platform it simple assume the system instalation
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by philip_bennefall » Thu Dec 25, 2014 2:25 pm
Thank you for the quick response!
This does create some problems for me, because the LGPL and the Zlib license are incompatible and so the whole project might as well be under LGPL when viewed from a Windows only user perspective. Can this be resolved somehow? boost.thread/std::thread/tinythread++ spring to mind.
Kind regards,
Philip Bennefall
-
philip_bennefall
-
- Posts: 3
- Joined: Thu Dec 25, 2014 7:34 am
by Julio Jerez » Fri Dec 26, 2014 2:37 pm
pthread is the standard for multithreading programing on Linux, Unix, OSX, BSD
I am not going to change the interface just because Microsoft does not want to adhere to the standard every one else uses, that's too much maintenance work for me for not real benefit.
I believe there is a conversion floating around that does not uses windows thread instead of the opn source version of pThread.
it is in fact quit eassy to mak eteh change to any other thread library, all you nee to do is to implement the method of this class
- Code: Select all
class dgThread
{
public:
class dgCriticalSection
{
public:
dgCriticalSection();
~dgCriticalSection();
void Lock();
void Unlock();
private:
#if (defined (DG_USE_THREAD_EMULATION) || !defined (DG_USE_MUTEX_CRITICAL_SECTION))
dgInt32 m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
};
class dgSemaphore
{
public:
dgSemaphore ();
~dgSemaphore ();
void Wait();
void Release();
private:
#ifdef DG_USE_THREAD_EMULATION
dgInt32 m_sem;
#else
#if defined (_MACOSX_VER) || defined (IOS) || defined (__APPLE__)
sem_t* m_sem;
dgInt32 m_nameId;
#else
sem_t m_sem;
#endif
#endif
friend class dgThread;
};
dgThread ();
dgThread (const char* const name, dgInt32 id);
virtual ~dgThread ();
virtual void Execute (dgInt32 threadId) = 0;
bool StillBusy() const;
void SuspendExecution (dgSemaphore& mutex);
void SuspendExecution (dgInt32 count, dgSemaphore* const mutexes);
dgInt32 GetPriority() const;
void SetPriority(int priority);
protected:
void Init ();
void Init (const char* const name, dgInt32 id);
void Close ();
static void* dgThreadSystemCallback(void* threadData);
pthread_t m_handle;
dgInt32 m_id;
dgInt32 m_terminate;
dgInt32 m_threadRunning;
char m_name[32];
};
In fact on that file ../newton-dynamics\coreLibrary_300\source\core\dgThread.h
there this define
// define DG_USE_THREAD_EMULATION
the if you uncomment, will run the engine emulation the multithreaded code and does no required pthread or any threads at all.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by philip_bennefall » Fri Dec 26, 2014 4:39 pm
Thanks for the detailed description. I did see the thread emulation stuff, but am not sure what kinds of ramifications it has. Does it make all processing run in the application thread? Are there any other side effects to disabling threads?
As for threading implementations, hopefully this will become less of a problem in the near future given the introduction of std::thread in C++11. That is implemented on top of pthreads in most Unix environments, and on top of Microsoft's threading subsystem on Windows.
Kind regards,
Philip Bennefall
-
philip_bennefall
-
- Posts: 3
- Joined: Thu Dec 25, 2014 7:34 am
by Julio Jerez » Fri Dec 26, 2014 8:22 pm
The thread emulation runs the engine on the main thread.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests