Questions tagged [pthreads]

Pthreads (POSIX Threads) is a standardised C-based API for creating and manipulating threads. It is currently defined by POSIX.1-2008 (IEEE Std 1003.1, 2013 Edition / The Open Group Base Specifications Issue 7).

The API is mostly covered by the header documented at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html and the behaviour by http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09

See https://en.wikipedia.org/wiki/POSIX_Threads for more details and further reading. The POSIX.1-2008 Base Definitions is available online at http://pubs.opengroup.org/onlinepubs/9699919799/

POSIX Threads is also covered extensively in Programming with POSIX Threads by David Butenhof.

A port to MS-Windows (x86/x64) is available at: https://sourceware.org/pthreads-win32/

pthreads is also the name of an Object Oriented API that allows user-land multi-threading in PHP created by Joe Watkins

8869 questions
3
votes
1 answer

php pthread, embeded synchronized works

This question follows this answer : Why not all threads are completed? I've tried to implement Joe Watkins's exemple into a couple of classes : SynchronizedWork :
JesusTheHun
  • 1,217
  • 1
  • 10
  • 19
3
votes
2 answers

how to check if a pthread is joinable?

I know I can create a pthread with joinable attribute set, but once created, am I right that I can also change that pthread to a detached pthread? If that's the case, how can I check if a pthread is joinable? And how can I change a pthread from…
james
  • 1,107
  • 14
  • 29
3
votes
4 answers

Threading newbie with issue with runaway threads

Ok, to you understand I will explain the problem: I am using a library called ClanLIB (not my choice), that library, SEEMLY (I am not certain, even reading the sourcE), creates a thread that handles sound. This thread, when the buffer is empty,…
speeder
  • 6,197
  • 5
  • 34
  • 51
3
votes
1 answer

How to deal with duplicate code inside a thread function?

Below function is run by producer threads. This function contains duplicate code. Had it been a threadless program, I would have created a separate function for the duplicate code and called that function as per need with desired arguments. What…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
3
votes
2 answers

Thread doesn't get executed in C

I am trying to create a program in C to calculate the sum and the product via threads.It's my exercise for university.The problem I face is that when I run the program the thread doesn't seem to execute.I am stuck and I don't know how to proceed. …
John Vn
  • 81
  • 2
  • 10
3
votes
1 answer

PHP 7.0.0 with pthreads 3.1.5 on Windows can't start

When trying to start PHP 7.0.0 (VC14 x64 Thread Safe 2015-Dec-03 20:07:26) with pthreads 3.1.5 (x64) on a Windows 7 system, I'm getting this error message: php-cgi.exe -b 127.0.0.1:8745 -c php.ini PHP Fatal error: The cgi-fcgi SAPI is not supported…
760 mmHg
  • 81
  • 10
3
votes
2 answers

Conditional wait of pthread never returns in c++

I am trying to implement a queue based worker using pthread. But I have some confusions about pthread_cond_wait(). class Worker class Worker { private: pthread_t thread; vector queue; bool stop; …
shantanu
  • 2,408
  • 2
  • 26
  • 56
3
votes
1 answer

(C) Using mutex in multithreaded client and server

I need help getting mutex to work the way I want. I am making a simple bank system with a server and multiple clients. The server has two threads. One thread listens for connections. The second thread is created when a client connects to the server.…
o.o
  • 3,563
  • 9
  • 42
  • 71
3
votes
2 answers

On Linux GCC/pthread parallel code is much slower than simple single thread code

I am testing pthread parallel code on Linux with gcc (GCC) 4.8.3 20140911, on a CentOS 7 Server. The single thread version is simple, it is used to init a 10000 * 10000 matrix : int main(int argc) { int size = 10000; int * r =…
LFF
  • 31
  • 2
3
votes
1 answer

Pthread lost signals / slow conditions?

I'm writing a simple threadpool for some small jobs (100 to 700 microseconds). I'm working only with two threads (because there are only two jobs and the processor has only two cores). My problem is that most of the time both jobs are executed by…
Lenz
  • 33
  • 3
3
votes
1 answer

Background Processing using pthread in php

I am trying to implement muti-threading in php using pthread to send emails. The basic idea here is to send email as a background job so that users dose not have to wait for the task to finish. I have a service that users PHPMailer to send emails…
DC-
  • 797
  • 9
  • 14
3
votes
1 answer

PHP-FPM and pthreads

Im using PHP-FPM to run a Phalcon application and have just installed pthreads so I can start running tasks asynchronously. I currently have pthreads working using the command line interface:
John Foley
  • 4,373
  • 3
  • 21
  • 23
3
votes
3 answers

How to include -std=c++11 and -lpthread in makefile?

I tried the advice in this answer, but it's for GCC and didn't help anyways. I want to #include in a file, so I have a make file as the following: OBJS = clitest.o Sources/NClient.o CC = g++ DEBUG = -g CFLAGS = -Wall -c…
galois
  • 825
  • 2
  • 11
  • 31
3
votes
1 answer

Memory leak found with Valgrind but I can't understand it

thanks in advance for your attention. I'm writing a simulation program for a project, but I have a deallocation problem with his "skeleton" when I use valgrind. Program Description: The program iterates until the user stops it with a SIGINT or a…
Redrus
  • 31
  • 2
3
votes
3 answers

segmentation fault(core dumped) error message

#include #include #include #include #include pthread_mutex_t mutex_lock; /* semaphore declarations */ sem_t students_sem; /* ta waits for a student to show up, student notifies ta his/her…
KhoaVo
  • 376
  • 3
  • 18
1 2 3
99
100