pthreads Questions
3
Solved
so I cannot seem to find solid info on whether assert is useable in a mulththreaded context.
logically to me it seems if an assertion fails the thread get shutdown but not the other threads?
or d...
Collectivity asked 20/11, 2014 at 12:4
3
I am just curious to know how functions related to synchronization between threads are implemented inside Unix. For example, what happens when I call pthread_mutex_lock? Are there any pointers in u...
Dreeda asked 23/2, 2011 at 19:6
4
Solved
I'm installing mingw-w64 on Windows and there are two options: win32 threads and posix threads. I know what is the difference between win32 threads and pthreads but I don't understand what is the d...
4
Solved
Say you have this code
pthread_mutex_lock(&cam->video_lock);
while(cam->status == WAIT_DISPLAY) // <-- Why is this a 'while' and not an 'if'?
pthread_cond_wait(&cam->video_con...
2
Solved
On Linux ps -eLf | grep my-process-name gives a list of the threads within my process along with the TID of each thread.
On OSX ps -M pid gives me the list of the threads but does not show the TID...
12
Solved
I just reviewed some really terrible code - code that sends messages on a serial port by creating a new thread to package and assemble the message in a new thread for every single message sent. Yes...
4
Solved
recently I set out to port ucos-ii to Ubuntu PC.
As we know, it's not possible to simulate the "process" in the ucos-ii by simply adding a flag in "while" loop in the pthread's call-back function ...
0
Mutexes were not introduced to the C standard until C11, right? Now that they exist, which should one use or prefer, and when? Why? What are the differences?
C11's mtx_lock() vs pthread_mutex_lock(...
1
Solved
I have a program to write in C for a class I am taking. The objective is to take an array and count all the instances of a certain string using 10 different threads. In this instance, we are trying...
Malay asked 22/6, 2021 at 19:33
2
Solved
I just dipped my toes into the POSIX pond and tried out POSIX threads for the first time. Until now, I'd been under the impression that there's a big architectural difference between POSIX threads ...
Cellulose asked 13/4, 2011 at 5:45
2
Solved
Here is my code:
#include <thread>
#include <chrono>
using namespace std::literals::chrono_literals;
#include <iostream>
void f(int n)
{
for (int cnt = 0; cnt < n; ++cnt) {
...
0
Why is /sysdeps/unix/sysv/linux/x86_64/clone.S crashing with SIGSTOP at (disassembled) "test %rax,%rax" on Ubuntu 20.10 when running this auto generated minimal (no-qt) C++ application in...
Chalky asked 9/4, 2021 at 16:6
7
Solved
A coworker had an issue recently that boiled down to what we believe was the following sequence of events in a C++ application with two threads:
Thread A holds a mutex.
While thread A is holding ...
Headstone asked 16/6, 2016 at 13:32
8
Solved
I tried passing a structure as the 4th argument while using pthread_create() with something like this:
pthread_create(&tid1, NULL, calca, &t); //t is the struct
Now whenever I try to acc...
Mastoiditis asked 14/5, 2009 at 15:15
3
Solved
Is there a sane way to map a pthread_t value (as returned from pthread_create() or std::thread::native_hanle() ) to pid(tid) in Linux? Before someone gets duplicate-happy, this is not about finding...
2
Solved
Using pthreads it mandatory to call pthread_mutex_init() on any mutex before obtaining the lock.
According to POSIX the locking an uninitialized mutex is only defined for mutex with priority prote...
4
Solved
I wish to create the following:
int amount[i];
As a global variable (to practice using threads and mutexes) but the variable i is defined at launch of the program:
./a.out 10
How may I take t...
3
Solved
This is a general question. For example, currently two child threads have called pthread_cond_wait(&cond1,&mutex), and they are both waiting. Then, the parent thread calls
pthread_cond_sig...
Spirit asked 18/3, 2013 at 20:31
8
Solved
2
I am using the pthread library to make a program to find the accurate value of pi with Leibniz formula. I am working on shared resource here. My multithreaded function looks like this:
void *Leibni...
Ductile asked 4/2, 2021 at 10:10
5
Solved
I am using a for loop to create a number of threads and passing the index i as an argument as follows:
pthread_t p[count];
for (int i = 0; i < count; i++){
pthread_create(&p[i], NULL, &...
Assemblage asked 19/4, 2013 at 2:17
6
Solved
I have a joinable pthread runner function defined as below:
void *sumOfProducts(void *param)
{
...
pthread_exit(0);
}
This thread is supposed to join the main thread.
Whenever I ran my program ...
2
Solved
I have an array of 100 requests(integers). I want to create 4 threads to which i call a function(thread_function) and with this function i want every thread to take one by one the requests:
(thread...
Ocker asked 15/1, 2021 at 20:24
4
I'm running RHEL 5.1 and use gcc.
How I tell cmake to add -pthread to compilation and linking?
4
Solved
I didn't find it in Mac, but almost all Linux os support it..
Any one knows how to port it to mac?
© 2022 - 2024 — McMap. All rights reserved.