Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is it possible to port pthreads wrapper to windows?


Asked by Jasper McPherson on Dec 10, 2021 Windows



Windows does not support the pthreads standard natively, therefore the Pthreads-w32 project seeks to provide a portable and open-source wrapper implementation. It can also be used to port Unix software (which uses pthreads) with little or no modification to the Windows platform.
Next,
But there's the more-or-less port, POSIX Threads for Win32, to allow pthreads to be used for cross-platform development. I've not used it a lot, but have encountered it in open source projects which provide a MinGW build for Windows users. I say more or less as not all POSIX threads features are available in the port.
And, There is a pthread implementation that works on Windows but it’s big, and heavy. Most cross platform thread libraries were written when XP was still supported and widely used. Back then Windows threads didn’t natively support conditionals or read write locks. So these (winpthreads) write emulations for this behavior.
Consequently,
----------- Pthreads4w is an Open Source Software implementation of the Threads component of the POSIX 1003.1c 1995 Standard (or later) for Microsoft's Windows environment. Some functions from POSIX 1003.1b are also supported, including semaphores.
In fact,
To utilise the PThread interfaces, we must include the header pthread.h at the start of the CPP script. PThreads is a highly concrete multithreading system that is the UNIX system’s default standard.