Pthreads (POSIX Threads) is a standardised C-based API for creating and manipulating threads on a POSIX-compliant system. It is defined by the standard "POSIX.1c, Threads extensions (IEEE Std 1003.1c-1995)", and subsequently by the Single Unix Specification.

learn more… | top users | synonyms

1
vote
0answers
31 views

Multithreaded MJPG network stream server

I'm a bit of a neophyte when it comes to C++, and so I'd like some feedback regarding a recent project. The code sits on a Raspberry Pi and streams camera data over TCP on a specified port. The ...
1
vote
1answer
32 views

Using semaphore in C

This is my first time using semaphores and I was wondering if I implemented them to the best of their abilities in my code.... ...
0
votes
1answer
35 views

Loading message with Pthreads

I want to print a nice loading message with these three fading dots, while the main thread does some heavy IO stuff. This is why I implemented this: ...
3
votes
1answer
54 views

Multiplying square matrix with C pthreads (POSIX threads)

I'm a student, and I'm trying to make the product of two square matrix with some threads in the soup. I've already worked on some fast single-threaded product (with some cache-friendly tricks), and ...
3
votes
1answer
46 views

Thread sync using conditional variables

Can you review the code? ...
3
votes
1answer
58 views

Async safe threadpool

I'm trying the write a threadpool that can safely be added inside a signal handler or in code forked by multithreaded code. Are there any corner cases that would cause this code to fail? What could be ...
0
votes
1answer
73 views

Multiple producers accessing multiple shared queues by checking for space two times

I request a review on the way multiple producers and consumers access multiple shared queues. What I have done here requires the threads to check for the space in queues minimum two times. Can it be ...
2
votes
0answers
49 views

N Processing connect to a single process: Socket Programming

The idea of my program is to use pthreads, semaphores, posix shared memory, and sockets to create an environment where N processes (that we will refer to as the children) can connect to a single ...
4
votes
2answers
108 views

pthread_cond_wait() based multithreaded Linux daemon skeleton

I'm trying to design a multithreaded daemon for an industrial automation related project. The daemon will be using a number of 3rd party libs like MQTT, mysql, etc.. My idea is to have worker threads ...
5
votes
1answer
148 views

Using a mutex to read from a file [closed]

I am new to C and I am trying to implement a mutex. The idea of the program is: main() will create three threads. Each thread will read one character each from ...
5
votes
1answer
202 views

Porting Java's synchronized() block to C++

I tried to create a class for porting Java's synchronized keyword to C++ using below code using *nix pthread's library. In general my test cases seem to work, but since this is a very critical topic ...
4
votes
1answer
431 views

Implementing pthread barrier for Mac OS/X

I have written this little thingie to fix a problem of missing pthread_barrier_t in Mac OS/X pthreads. Are there any issues with this code? The header: ...
2
votes
1answer
1k views

Readers-Writers problem in C

I would love some suggestions on this code of mine, pointers on overall design, code quality, optimization in terms of memory and speed. ...
6
votes
2answers
309 views

Harmonic partial sum calculator with multithreading

I wrote a program which computes the harmonic partial sum to N terms with multithreading capability. I've been working on this to sharpen my C++ skills for the upcoming semester. Just wondering if ...
5
votes
3answers
126 views

Counting letters as quickly as possible

I received a task, of taking a known text file (Linux dictionary), use threads to count the different letters in it, and present the results in an array. The code doesn't have to be pretty, elegant, ...
4
votes
1answer
412 views

Vehicle-crossing simulation

It seems like this code should be shorter, but with all the error checking it is long and hard to follow. This is for a simulation of vehicles crossing a bridge, and this part is dealing with mutexes. ...
4
votes
2answers
410 views

Example of a Multithreaded C program

In answering password cracker in c with multithreading, I ended up writing a sample in C, which is not my forte. Is there anything that I missed which should have been included in a responsible ...
4
votes
1answer
108 views

Synchronous events library

I have implemented a small library that handles synchronous events with POSIX compliant threads. I oriented me on the already existing POSIX thread API. Here are the files I created: ...
3
votes
1answer
264 views

Consumer producer implementation involving POSIX, semaphores, and locks

I am trying to get over my fear of multithreading programming and teaching myself to code using POSIX. I wrote a small version of the consumer producer problem. I am hoping I can get some feedback if ...
5
votes
1answer
5k views

Consumer-Producer Problem: POSIX Thread

I have implemented a producer consumer problem, following the resources below: Oracle doc CSEE I have used mutex_t and ...
5
votes
1answer
2k views

Scalability of C server implementation based on pthreads

I am wondering about the feasibility of the following basic implementation of a server and how well it would scale. I know that large-scale, distributed servers should probably be written in a ...
15
votes
1answer
13k views

Thread-safe concurrent FIFO queue in C++

Is this the correct way to implement a thread-safe concurrent FIFO queue in C++? It requires passing unsigned char* arrays of binary data. Thread Safe Concurrent ...
2
votes
1answer
180 views

1 Producer, N Consumers working in parallel, each doing ~1/nth of a task

I am not wondering about error checking (I will add that soon). I would instead like to know about correctness, efficiency and simplicity. ...
7
votes
3answers
16k views

Dining philosophers problem with mutexes

I know this dining philosophers problem has been researched a lot and there are resources everywhere. But I wrote simple code to solve this problem with C and then turned to the Internet to see if ...
4
votes
1answer
92 views

Uses of barriers for one main thread controlling n threads

Referring to this post, my problem (summarized): One main thread waits for connections, on accept() spawns a new thread for each connection. After we received ...
1
vote
4answers
3k views

Concurrent queue with pthread implementation

I'm writing a multi-threaded queue implemented with pthreads. Since I came up with the code based on several tutorials from Internet, I would like to make sure there are no logic errors in my code: ...
2
votes
1answer
357 views

Multithreaded GPS system

I am trying to reduce the total execution time of my code. I have a GPS system which calculates routes between two points, and returns all points in between them. I did a simple profile and the ...
10
votes
1answer
3k views

Threading lambda functions

I've created this very small header that allows direct creation of threads from lambdas. I can't find anything else similar on the net so I want to know whether there are any problems with this that I ...
4
votes
1answer
118 views

Demonstration of pthread calls

Please review for any unnecessary casting, memory leaks, wrong use of pthread call, or validation problems in the given code. ...
0
votes
2answers
2k views

Mutex locker class in C++

What needs to be corrected, added, or subtracted here? ...
2
votes
2answers
6k views

Producer-consumer in C using pthread_barrier

We're preparing for an exam at the moment, and our lecturer has given us a sample problem to work on. I have it completed, but would like to know a) If it is actually doing what it's supposed to, and ...
4
votes
2answers
451 views

Maintaining a count with two threads using conditional variables

This is just a program to show the use of conditional variables when two threads are involved. One thread wants a non-zero value of count, and other thread is ...
1
vote
1answer
399 views

std::lock implementation in C with pthreads

I messed a little bit with pthreads and needed an alternative to the C++11 function std::lock (2 args are enough), and this is what I came up with: ...
2
votes
2answers
769 views

Thread design for sending data to multiple servers

In the following code, checkServerExists function checks if the server exists in the vector. If it does, then the new message is directly pushed in the vector, ...
3
votes
4answers
7k views

Linux C++ Timer Class: How can I improve the accuracy?

I wrote this class today, but I am trying to figure out how to make it more accurate. I pass in seconds and multiply by 1000 to make it milliseconds, and the time does not line up. I need the ability ...
3
votes
1answer
1k views

Seperate rendering thread with XLib (GLX) and OpenGL

I am writing a prototype for something at work. Not very many people here know much about Linux/Unix or Xlib so I can't really ask here at work (most developers are expert Windows programmers). With ...
3
votes
2answers
278 views

Accessing limited resources with Pthreads

I'm a Pthreads newbie and I've been giving myself a challenge: I want to have a resource that multiple threads can access at the same time as read. However, if a thread wants to write, then this need ...
7
votes
1answer
4k views

Multithreading algorithm for high performance parallel computing and Producer-Consumer queue using POSIX threads

The following is the producer-consumer algorithm for a piece of software that I'm upgrading to take advantage of multi-core processing. The intended platform is some flavor of Linux running on an EC2 ...