Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
74 views

Given volatile int stopping = 0; void handler(int) { stopping = 1; } int main(int, char **) { pthread_sigmask(BLOCK, [INT], ...); pthread_create(); pthread_sigmask(UNBLOCK, [INT], ......
Simon Richter's user avatar
4 votes
1 answer
135 views

I have a more complex situation that uses pthreads, synchronized with condition variables. Each thread had its own condition variable so there is no access problem. The code runs a loop of 10 ...
tomdean1939's user avatar
0 votes
1 answer
116 views

I am learning on how threads can be cancelled. Asynchronous cancellation can cancel the thread at any given point in time, but what I have learned about deferred cancellation is that it can only be ...
Easha's user avatar
  • 9
1 vote
0 answers
108 views

pthread_rwlock_wrlock are used inside real-time threads to cause hang to live, Why would you live? There is a priority inversion bug described here involving pthread_rwlock_wrlock and real time ...
scubasteve623's user avatar
0 votes
1 answer
133 views

I'm having troubles understanding the behaviour of the following application. There are 3 threads: worker thread with an infinite loop which locks the mutex, modifies a global variable but in the end ...
Sterpu Mihai's user avatar
0 votes
1 answer
60 views

It seems to be true but I cannot find the docs that explicitly says that. The man page says The pthread_threadid_np() function stores the system-wide unique integral ID of thread in the location ...
wanghan02's user avatar
  • 1,339
1 vote
1 answer
111 views

Code: pthread_rwlock_wrlock(&memlock); // (1) // do something... pthread_rwlock_rdlock(&memlock); // (2) // do something... pthread_rwlock_wrlock(&memlock); // (3) The following tags, (1),...
bod's user avatar
  • 33
3 votes
2 answers
160 views

PURPOSE: I want to create a thread pool: essentially an array of pthread_t values. I want to be able to terminate threads in progress, and to mark their pthread_t value as invalid, thus the slot is ...
Jon Green's user avatar
  • 702
3 votes
1 answer
100 views

I need to use robust mutexes for IPC in case one of my processes crashes while holding a mutex locked. Definition is clear from e.g. man pthread_mutexattr_setrobust and I will not repeat it here. I ...
toxic's user avatar
  • 600
2 votes
1 answer
106 views

I have multiple threads performing sigwait on the same signal, and the main thread will wake specific thread up via pthread_kill. On Linux the program runs fine, but on MacOS the wrong thread will be ...
Guest0x0's user avatar
  • 306
5 votes
2 answers
279 views

I'm trying to revive Hemlock, which now appears abandoned (original author has been absent for some time now). Mostly this has been a straightforward process of clearing out the bit rot, but I'm now ...
CL-USER's user avatar
  • 848
0 votes
1 answer
128 views

We're seeing some strange crashes and noticed the following. It's unclear if related or not. The contract for xpc_main, which internally calls dispatch_main, is This function never returns. and they ...
Léo Natan's user avatar
  • 57.2k
0 votes
1 answer
74 views

I am trying to understand when -pthread is needed. For code that directly uses pthread API, of couse -pthread should be passed, but: should I pass -pthread if my code does not use pthread directly, ...
Guest0x0's user avatar
  • 306
2 votes
1 answer
95 views

I'm observing unexpected behavior when using pthread_getattr_default_np() in conjunction with pthread_attr_setaffinity_np() on Linux. I override the default thread attributes using ...
sys's user avatar
  • 21
4 votes
1 answer
111 views

I know that, for POSIX shared and robust mutexes, if the process holding them crashes, the next process trying to acquire the lock will successfully call pthread_mutex_lock, which will return ...
Alessandro Bertulli's user avatar
5 votes
0 answers
127 views

Summary: I have encountered some behaviour I don't understand when using pthreads with C++17. When calling pthread_exit() from a method marked as noexcept, SIGABRT is raised. While I have some ideas ...
vykt's user avatar
  • 153
2 votes
1 answer
86 views

I am in a university course focused on parallel and concurrent programming. My professor left us some homework to do, and three of them are basically the same project. My first revision of the project ...
Serujio74's user avatar
2 votes
1 answer
109 views

In the documentation at Open Group, it states that: NAME pthread_rwlock_wrlock, pthread_rwlock_trywrlock - lock a read-write lock object for writing ... The pthread_rwlock_wrlock() and ...
hyunseo welcome's user avatar
1 vote
0 answers
40 views

Why is pthread_setname_np and PR_SET_NAME limited to 16 bytes? Linux processes can have much longer names, for example systemd-timesyncd comes pre-installed on my system, and is 18 bytes including the ...
hanshenrik's user avatar
  • 22.4k
1 vote
2 answers
122 views

I'm not sure why my valgrind is spitting heap errors and I've been tracing my code left and right. I have some code, but I'm not sure if more code is needed. My jobs.h #include "piper.h" #...
minyoung heo's user avatar
1 vote
1 answer
90 views

I'm working on a C++ application that launches multiple processes. All of them load the same executable and share a memory region using shm_open + mmap. In that shared memory, we store a ...
Ilan Noy's user avatar
  • 111
1 vote
0 answers
56 views

Does Rust threads have concept of thread cancellation points just like POSIX threads. In POSIX, a cancellation request can be sent to a thread using pthread_cancel function. Also, thread's ...
Harry's user avatar
  • 4,198
3 votes
0 answers
83 views

I am working on a C program that simulates a hair salon, and I'm facing an issue with terminating the main process from the simulation_timer_thread. The only way I can successfully exit the main ...
Bartłomiej's user avatar
6 votes
2 answers
155 views

Lets say I spawn 4 threads, running these functions int func1() {sleep(2); return 1}; int func2() {sleep(4); return 0}; int func3() {sleep(6); return 2}; int func4() {sleep(8); return 3}; I want to ...
ijklr's user avatar
  • 311
4 votes
2 answers
109 views

So, I am currently writing a program that uses the standard pthread.h library. I want there to be multiple threads, all calculating stuff independently of each other at the same time (no mutexes ...
Tritium's user avatar
  • 41
1 vote
1 answer
147 views

I am trying to implement a simple multi-threaded program where two threads increment a shared counter (cnt) n times. I want to use a semaphore to ensure mutual exclusion and prevent race conditions. ...
StaY_Hungry's user avatar
0 votes
1 answer
194 views

Clarification: When I say "output" here, I'm not talking about the .o or .exe or whatever. I'm talking about the warnings and errors emitted during my failed attempt to find the Threads ...
Mark Storer's user avatar
  • 15.9k
0 votes
1 answer
70 views

Suppose I'm creating 2 thread and I'm also created synchronization. Thread 1 : program to adding 2 integer. Thread 2 : program to subtract 2 integer In multithread thread 1 and thread 2 will be ...
Akbar294's user avatar
2 votes
1 answer
87 views

I am learning multi-threading in C and I'm trying to build a simple chat application. The idea is that clients connect to a central server and the server forwards messages sent by the clients to the ...
Az JRC's user avatar
  • 35
0 votes
0 answers
114 views

TLDR; towards the bottom I am trying to build a runtime with Green Threads for my language which are inspired by Golang's go routines and scheduler. The runtime is written in C++ and I am trying to ...
Aarav Dayal's user avatar
1 vote
1 answer
350 views

I am encountering a puzzling issue with ThreadSanitizer while using pthread_cancel and a cleanup handler in a multithreaded C++ program. The sanitizer reports a data race on a global variable even ...
m. bs's user avatar
  • 93
1 vote
1 answer
68 views

I wrote a simple program of #include <pthread.h> #include <stdio.h> #include <stdlib.h> void *thread(void *arg) { printf("thread() entered with argument '%s'\n", arg); ...
Sameer Mahajan's user avatar
-3 votes
2 answers
150 views

Immediately after spawning a thread with pthread_create, I would like the parent to wait an arbitrary amount of time until the child thread allows it to continue. Here is how I might approach it with ...
Adam Rutledge's user avatar
0 votes
1 answer
50 views

Question: I'm working on a C program where I have two threads, p1 and p2, and I need them to print the sequence 1234 1234 1234 .... I am using semaphores to synchronize the threads, but the output is ...
Badreddine's user avatar
1 vote
2 answers
148 views

I'm fairly new to C programming and am at the moment trying to wrap my head around the pthreads library and threading more generally. Question 1: When and why is detaching a thread a nice option to ...
noob1232's user avatar
1 vote
1 answer
194 views

sigprocmask(2) says: Each of the threads in a process has its own signal mask. , but also: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). ...
Caulder's user avatar
  • 459
2 votes
0 answers
128 views

I am currently creating a Minecraft clone in C and OpenGL. I have implemented a chunk loading system however this would result in freezing as new chunks are loaded as the main thread is having to wait ...
Brumus14's user avatar
0 votes
0 answers
68 views

I am new to rt c++ development and sorry if i am missing out on something basic. I'm experiencing inconsistent latency behavior in a real-time system using clock_nanosleep for precise wakeups. The ...
Prasaanth Lakshmi's user avatar
1 vote
0 answers
58 views

I'm just facing a problem with my threads. I'm coding a program that needs to execute asynchronous tasks, and I do it via a thread pool. To avoid my threads running in the void when they have nothing ...
Maxence Gama's user avatar
1 vote
0 answers
85 views

I want every time a student is created to display who has been created and in which department they study. I'm stuck and I don't know what parameters to pass to printInfo(), do you have any idea? I ...
mitsislav's user avatar
1 vote
1 answer
130 views

I am working on an assignment which requires me to simulate a bus travelling from Stop A to Stop B over and over again while students can get on and get out of it. I coded the whole routine of the bus ...
Jukeland's user avatar
0 votes
1 answer
185 views

On Linux, libstdc++ doesn't use pthread_create() to create threads, as it can be seen from this bug: https://bugzilla.kernel.org/show_bug.cgi?id=218607 (libpsx wraps pthread_create() to intercept ...
vinipsmaker's user avatar
  • 2,431
0 votes
0 answers
62 views

I get a C2011 error each time i try executing despite having the library installed. This was the video I follow along for install. #include <stdio.h> #include <pthread.h> void* PrintHello(...
JR16CS's user avatar
  • 31
0 votes
1 answer
108 views

I have this little program that is supposed to create a thread and cancel it. #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> void *...
Мария Шипаева's user avatar
0 votes
0 answers
93 views

I am using C++. I have a set of files to be processed by another program (Executable). I intend to run this process in multiple threads (not more than N threads to prevent system from being becoming ...
tpb261's user avatar
  • 255
2 votes
0 answers
75 views

This is a follow-up of this question. I have updated the code to incorporate some of the ideas pointed out by Peter Cordes. My threads should be doing actual parallel work (now it takes time to the ...
onlycparra's user avatar
2 votes
1 answer
131 views

I am learning about C memory ordering models, and I came up with this little code for a producer and consumer sharing a "bucket" with "units". I intended to create this sequence of ...
onlycparra's user avatar
0 votes
1 answer
110 views

I'm working in a multiprocess, multithreaded environment where I'm using a pthread_rwlock_t read-write lock stored in shared memory so that all processes can access it. Here's how I initialized the ...
Joan Jeremiah J's user avatar
1 vote
0 answers
85 views

I have a socket class that has a separate thread for recv/send data, and it is able to send/receive data correctly. The part of the logic that is not working and giving me an exception is the part ...
bourne's user avatar
  • 1,259
0 votes
0 answers
70 views

#include <pthread.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <...
Endless Paradox's user avatar

1
2 3 4 5
180