Windows build without POSIX threads [Alpha Patch Attached]

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Windows build without POSIX threads [Alpha Patch Attached]

Postby godlike » Sun May 31, 2015 10:47 am

Hi Julio,

For my project needs I wanted to remove the POSIX thread dependency from Newton and for the Windows build and use native Windows threads instead.

What I did is fairly simple. I've altered a couple of files add added an extra path for Windows threads.

What I am missing:
- Setting and getting thread priorities
- Removing the Pthreads-win32 from the build system
- Testing on Linux and MacOS

Julio, if you are interested I can continue working on it and create a git pull request for you to review. If no I will keep the changes for my project.

I've created a patch with what I have for now:
https://drive.google.com/file/d/0B5tJTl ... sp=sharing
User avatar
godlike
 
Posts: 58
Joined: Sun Mar 16, 2014 3:48 am

Re: Windows build without POSIX threads [Alpha Patch Attach

Postby Julio Jerez » Sun May 31, 2015 11:47 am

are you talking of C++ 11 interface? if not then why do you want to do that?
POSIX thread in windows is using the native windows thread. and it is a very thing wrapper with almost all functions in headers files.

in Linux and Max it uses the existing OS native thread interface, using the native APIs directly you have to implements the thread on each system, and every new system, that will turn the engine into a threading library and I do not want to do that.

In the future when C++ 11 is more standard I will provablis use the c++ thread, but for now that is not an options, there are some newton users that are using in consoles that do no support the c++ 11 standard yet.

you are welcome to make the change, and replace the dgTheard class, and not link pthreads.
that is what the build projects do for not windows system.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Windows build without POSIX threads [Alpha Patch Attach

Postby godlike » Sun May 31, 2015 3:12 pm

Thanks for the reply Julio.

My patch doesn't contain any C++11 libraries. Just plain calls to Windows API.

Pthread_win32 is indeed a thin wrapper but it contains more functionality than Newton really needs. Newton uses:
- 4 functions for thread manipulation (start, join, get priority, set priority)
- 4 functions for semaphores (create, destroy, post, wait)
- 4 functions for mutex (create, destroy, lock, unlock)

I only proposed that change because Pthread_win32 has more functionality that actually needed. Maybe it's an overkill to have a complete implementation of POSIX threads just for 12 functions on Windows.

All that unless I am missing something.
User avatar
godlike
 
Posts: 58
Joined: Sun Mar 16, 2014 3:48 am

Re: Windows build without POSIX threads [Alpha Patch Attach

Postby Julio Jerez » Sun May 31, 2015 3:49 pm

godlike wrote:My patch doesn't contain any C++11 libraries. Just plain calls to Windows API.

this is exactly what I do no want to do, for a few years, in the early day of Newton, I was using direct call to windows thread but that translated to writing many different Threading code for linux and OS10, an now with consoles I am glad I made the switch to POSIT threads. Going back would means to abandonee the cross platform support.

godlike wrote:Pthread_win32 is indeed a thin wrapper but it contains more functionality than Newton really needs. Newton uses:

but why does that Matters? linker link what the use from a libraries. The extra size in does no matters.
In my opinion going to specific OS Threads is a very wrong move.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Windows build without POSIX threads [Alpha Patch Attach

Postby godlike » Mon Jun 01, 2015 2:37 am

fair enough.
User avatar
godlike
 
Posts: 58
Joined: Sun Mar 16, 2014 3:48 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest