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...
Azal asked 21/6, 2013 at 19:1

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...
Kristiekristien asked 14/10, 2011 at 10:3

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...
Moustache asked 20/1, 2015 at 14:21

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...
Nebuchadnezzar asked 14/10, 2010 at 3:3

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 ...
Nolte asked 22/2, 2012 at 14:49

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(...
Nessim asked 23/6, 2021 at 22:1

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) { ...
Zaratite asked 30/10, 2019 at 16:19

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...
Megalomania asked 14/12, 2017 at 15:39

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...
Cilia asked 28/6, 2014 at 15:48

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...
Sardella asked 2/3, 2016 at 10:30

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

I'm encountering the following error at unpredictable times in a linux-based (arm) communications application: pthread_mutex_lock.c:82: __pthread_mutex_lock: Assertion `mutex->__data.__owner ==...
Dinitrobenzene asked 9/7, 2009 at 18:36

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, &amp...
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 ...
Tea asked 2/10, 2010 at 6:41

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?
Cockadoodledoo asked 25/10, 2009 at 13:25

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?
Jestude asked 18/11, 2011 at 2:22

© 2022 - 2024 — McMap. All rights reserved.