I was reading source code of glibc. In function void *__libc_malloc(size_t bytes): It shows that if the first thread was created, it calls ptmalloc_init(), and links thread_arena with main_arena, and sets __malloc_initialized to true. On the other hand, the second thread was blocked by the following code in ptmalloc_init(): Thus the thread_arena of the second thread is NULL, and it
Tag: multithreading
Parallel TCP connection using threads
I am trying to build a system that opens parallel TCP sockets using threads. My threads are triggered using message queue IPC , thus every time a packet arrive to the message queue a thread “wakes up” , open TCP connection with remote server and send the packet. My problem is that in Wireshark , I can see the the
Is linux perf accurate for measuring cache misses for multithread C program?
Can linux perf measure cache misses for multithread program, or it can only report the result for master thread? I used it on a C program using pthread, it seemed the cache miss number was lower than the expected number. Answer Yes, perf stat is an accurate total across all threads. (Unless your CPU has an erratum where a certain
Problem with same thread ID for different threads
I am having trouble with my threads. I am trying to create 10 threads and for each thread I want to print the thread ID. I am able to print the thread ID but the problem is that all threads prints out the same thread ID. This is my code: main: mqClient: When testing two threads this is the output
Simple division of labour over threads is not reducing the time taken
I have been trying to improve computation times on a project by splitting the work into tasks/threads and it has not been working out very well. So I decided to make a simple test project to see if I can get it working in a very simple case and this also is not working out as I expected it to.
Organize multitrheading datalogging [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I’m working on a C project for an embedded target running a Linux distribution (build with Yocto). I’m new to Linux embedded world and I
How to launch the same linux process with different arguments in multiple threads with Poco process
When trying to launch the same C++ Linux program, with different arguments and with Poco::process, I get exit 72 code from my second DummyProcess. This code snippet below is executed in a thread function, which launches every other time, with different task and duration arguments. When task-1 is running and task-2 wants to launch, its PID gets assigned (different then
How to use SIGEV_THREAD, sigevent for linux-timer(s) expiration handling in C?
Problem: I have timer(s) running, upon expiration of timer(s) certain function needs to be invoked. Output: There is a segfault inside Hndlr() function As per man page of sigevent, it says, SIGEV_THREAD – Notify the process by invoking sigev_notify_function “as if” it were the start function of a new thread. (Among the implementā tation possibilities here are that each timer
How to solve pthread_create error (11) resource temporarily unavailable?
I’m building a project in c language (using openwrt as OS) to upload files to FTP server. and i’m using MQTT for the incoming data. So for each topic i subscribe to, i save this data and then upload it to the FTP server and to keep things going smoothly, each time i need to upload a file i just
Why does pthread_exit use void*?
I recently started using posix threads and the choice of argument types in the standard made me curious. I haven’t been able to asnwer the question of why does pthread_exit use void* instead of int for the returning status of the thread? (the same as exit does). The only advantage I see is that it lets the programmers define the