<s>
In	O
computing	O
,	O
POSIX	B-Operating_System
Threads	I-Operating_System
,	O
commonly	O
known	O
as	O
pthreads	B-Operating_System
,	O
is	O
an	O
execution	B-Device
model	I-Device
that	O
exists	O
independently	O
from	O
a	O
programming	O
language	O
,	O
as	O
well	O
as	O
a	O
parallel	B-Operating_System
execution	I-Operating_System
model	I-Device
.	O
</s>
<s>
It	O
allows	O
a	O
program	B-Application
to	O
control	O
multiple	O
different	O
flows	O
of	O
work	O
that	O
overlap	O
in	O
time	O
.	O
</s>
<s>
Each	O
flow	O
of	O
work	O
is	O
referred	O
to	O
as	O
a	O
thread	B-Operating_System
,	O
and	O
creation	O
and	O
control	O
over	O
these	O
flows	O
is	O
achieved	O
by	O
making	O
calls	O
to	O
the	O
POSIX	B-Operating_System
Threads	I-Operating_System
API	B-General_Concept
.	O
</s>
<s>
POSIX	B-Operating_System
Threads	I-Operating_System
is	O
an	O
API	B-General_Concept
defined	O
by	O
the	O
Institute	O
of	O
Electrical	O
and	O
Electronics	O
Engineers	O
(	O
IEEE	O
)	O
standard	O
POSIX.1c	O
,	O
Threads	B-Operating_System
extensions	O
(	O
IEEE	O
Std	O
1003.1c-1995	O
)	O
.	O
</s>
<s>
Implementations	O
of	O
the	O
API	B-General_Concept
are	O
available	O
on	O
many	O
Unix-like	B-Operating_System
POSIX-conformant	O
operating	B-General_Concept
systems	I-General_Concept
such	O
as	O
FreeBSD	B-Operating_System
,	O
NetBSD	B-Device
,	O
OpenBSD	B-Operating_System
,	O
Linux	B-Application
,	O
macOS	B-Application
,	O
Android	B-Application
,	O
Solaris	B-Application
,	O
Redox	B-Operating_System
,	O
and	O
AUTOSAR	B-Application
Adaptive	O
,	O
typically	O
bundled	O
as	O
a	O
library	B-Library
libpthread	B-Operating_System
.	O
</s>
<s>
DR-DOS	B-Application
and	O
Microsoft	B-Application
Windows	I-Application
implementations	O
also	O
exist	O
:	O
within	O
the	O
SFU/SUA	O
subsystem	O
which	O
provides	O
a	O
native	O
implementation	O
of	O
a	O
number	O
of	O
POSIX	O
APIs	B-General_Concept
,	O
and	O
also	O
within	O
third-party	B-General_Concept
packages	O
such	O
as	O
pthreads-w32	O
,	O
which	O
implements	O
pthreads	B-Operating_System
on	O
top	O
of	O
existing	O
Windows	B-Library
API	I-Library
.	O
</s>
<s>
pthreads	B-Operating_System
defines	O
a	O
set	O
of	O
C	B-Language
programming	I-Language
language	I-Language
types	O
,	O
functions	O
and	O
constants	O
.	O
</s>
<s>
It	O
is	O
implemented	O
with	O
a	O
pthread.h	B-Operating_System
header	O
and	O
a	O
thread	B-Operating_System
library	B-Library
.	O
</s>
<s>
There	O
are	O
around	O
100	O
threads	B-Operating_System
procedures	O
,	O
all	O
prefixed	O
pthread_	O
and	O
they	O
can	O
be	O
categorized	O
into	O
four	O
groups	O
:	O
</s>
<s>
Thread	B-Operating_System
management	I-Operating_System
-	O
creating	O
,	O
joining	O
threads	B-Operating_System
etc	O
.	O
</s>
<s>
The	O
POSIX	O
semaphore	B-Operating_System
API	B-General_Concept
works	O
with	O
POSIX	B-Operating_System
threads	I-Operating_System
but	O
is	O
not	O
part	O
of	O
threads	B-Operating_System
standard	O
,	O
having	O
been	O
defined	O
in	O
the	O
POSIX.1b	O
,	O
Real-time	O
extensions	O
(	O
IEEE	O
Std	O
1003.1b-1993	O
)	O
standard	O
.	O
</s>
<s>
Consequently	O
,	O
the	O
semaphore	B-Operating_System
procedures	O
are	O
prefixed	O
by	O
sem_	O
instead	O
of	O
pthread_	O
.	O
</s>
<s>
An	O
example	O
illustrating	O
the	O
use	O
of	O
pthreads	B-Operating_System
in	O
C	B-Language
:	O
</s>
<s>
This	O
program	B-Application
creates	O
five	O
threads	B-Operating_System
,	O
each	O
executing	O
the	O
function	O
perform_work	O
that	O
prints	O
the	O
unique	O
number	O
of	O
this	O
thread	B-Operating_System
to	O
standard	O
output	O
.	O
</s>
<s>
If	O
a	O
programmer	O
wanted	O
the	O
threads	B-Operating_System
to	O
communicate	O
with	O
each	O
other	O
,	O
this	O
would	O
require	O
defining	O
a	O
variable	O
outside	O
of	O
the	O
scope	O
of	O
any	O
of	O
the	O
functions	O
,	O
making	O
it	O
a	O
global	O
variable	O
.	O
</s>
<s>
This	O
program	B-Application
can	O
be	O
compiled	O
using	O
the	O
gcc	B-Application
compiler	I-Application
with	O
the	O
following	O
command	O
:	O
</s>
<s>
Here	O
is	O
one	O
of	O
the	O
many	O
possible	O
outputs	O
from	O
running	O
this	O
program	B-Application
.	O
</s>
<s>
Windows	O
does	O
not	O
support	O
the	O
pthreads	B-Operating_System
standard	O
natively	O
,	O
therefore	O
the	O
Pthreads4w	O
project	O
seeks	O
to	O
provide	O
a	O
portable	O
and	O
open-source	O
wrapper	O
implementation	O
.	O
</s>
<s>
It	O
can	O
also	O
be	O
used	O
to	O
port	O
Unix	B-Application
software	O
(	O
which	O
uses	O
pthreads	B-Operating_System
)	O
with	O
little	O
or	O
no	O
modification	O
to	O
the	O
Windows	O
platform	O
.	O
</s>
<s>
Pthreads4w	O
version	O
3.0.0	O
or	O
later	O
,	O
released	O
under	O
the	O
Apache	O
Public	O
License	O
v2.0	O
,	O
is	O
compatible	O
with	O
64-bit	O
or	O
32-bit	B-Application
Windows	I-Application
systems	O
.	O
</s>
<s>
The	O
Mingw-w64	B-Application
project	O
also	O
contains	O
a	O
wrapper	O
implementation	O
of	O
pthreads	B-Operating_System
,	O
winpthreads	O
,	O
which	O
tries	O
to	O
use	O
more	O
native	O
system	B-Operating_System
calls	I-Operating_System
than	O
the	O
Pthreads4w	O
project	O
.	O
</s>
<s>
Interix	B-Operating_System
environment	O
subsystem	O
available	O
in	O
the	O
Windows	O
Services	O
for	O
UNIX/Subsystem	O
for	O
UNIX-based	O
Applications	O
package	O
provides	O
a	O
native	O
port	O
of	O
the	O
pthreads	B-Operating_System
API	B-General_Concept
,	O
i.e.	O
</s>
<s>
not	O
mapped	O
on	O
Win32	B-Library
API	I-Library
but	O
built	O
directly	O
on	O
the	O
operating	B-General_Concept
system	I-General_Concept
syscall	B-Operating_System
interface	O
.	O
</s>
