Is there a way of doing a non-blocking pthread_join?
Some sort of timed join would be good to.
I'll try to clarify the question:
I'm coding the shutdown of a multithreaded server.
If everything goes as it should all the threads exit by their own, but there's a small chance that a thread gets stuck.
In this case it would be convenient ...
GDB has severe issues when debugging with multiple threads (pthreads).
Are there any other good multi-threaded debuggers for C/C++ on *nix?
...
In the C programming language and Pthreads as the threading library; do variables/structures that are shared between threads need to be declared as volatile? Assuming that they might be protected by a lock or not (barriers perhaps).
Does the pthread POSIX standard have any say about this, is this compiler-dependent or neither?
Edit to ...
I'm wondering the best way to start a pthread that is a member of a C++ class? My own approach follows as an answer...
...
What does it mean when it gives a backtrace with the following output?
#0 0x00000008009c991c in pthread_testcancel () from /lib/libpthread.so.2
#1 0x00000008009b8120 in sigaction () from /lib/libpthread.so.2
#2 0x00000008009c211a in pthread_mutexattr_init () from /lib/libpthread.so.2
#3 0x0000000000000000 in ?? ()
The program has ...
i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (which defeats my debugging strategies)
I would like the following req...
Suppose I have the following code:
while(TRUE) {
pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t));
pthread_create(thread, NULL, someFunction, someArgument);
pthread_detach(*thread);
sleep(10);
}
Will the detached thread free the memory allocated by malloc, or is that something I now have to do?
...
I've recently seen the light of EventWaitHandle's powerful behavior in C# and decided to move some functionality in a sister application to do the same. The only problem is that the sister app is written in C.
No big deal, I'm using pthreads, which have a pthread_cond_t datatype that allows for signalling. My only question is, is it pos...
It looks like some work has been done to make pthread-win32 work with x64, but there are no build instructions. I have tried simly building with the Visual Studio x64 Cross Tools Command Prompt, but when I try to link to the lib from an x64 application, it can't see any of the function exports. It seems like it is still compiling the lib...
Trying to get a grip on how people are actually writing parallel code currently, considering the immense importance of multicore and multiprocessing hardware these days. To me, it looks like the dominant paradigm is pthreads (POSIX threads), which is native on Linux and available on Windows. HPC people tend to use OpenMP or MPI, but th...
is there any easier solution in porting a windows manual-reset event to pthread,
than a pthread conditional-variable + pthread mutex + a flag if event is set or unset?
...
I have a thread running in the background that is reading events from an input device in a blocking fashion, now when I exit the application I want to clean up the thread properly, but I can't just run a pthread_join() because the thread would never exit due to the blocking IO.
How do I properly solve that situation? Should I send a pth...
I would like to implement a producer/consumer scenario that obeys interfaces that are roughly:
class Consumer {
private:
vector<char> read(size_t n) {
// If the internal buffer has `n` elements, then dequeue them
// Otherwise wait for more data and try again
}
public:
void run() {
read(10);
re...
I am asked to work on a piece of code which relies heavily on pthreads. So many calls are made to this library that I know nothing of. I have learnt the basics of pthread and have tried out a few examples like creating joining etc. but dont know the depths of it.
I have learnt much of it using http://www.yolinux.com/TUTORIALS/LinuxTuto...
I have a single HW interface I want to use from two applications (processes) on the same workstation. The HW requires a single initialization call then either app uses the same function (in the same library) to do many transactions with the HW.
So each app should act like this:
main()
// I don't know if another app already init'e...
How, under Windows and Linux, given a thread handle can I determine the beginning and end of its corresponding static thread local storage block?
...
I've been reading and researching this for a couple of days
now, and decided I need some outside assistance!
(and this site seemed like a nice place, so I thought I'd
post my question here and see how it goes)
our little company hasn't built our applications on AIX
for several years, and I've been assigned this task (good
thing I like ...
I am using xcode 2.4.1 on tiger. When i do below everything is ok. when i do
pthread_mutex_t mute;
ImageMan()
{
dibSize=0;
mute = PTHREAD_MUTEX_INITIALIZER;
}
I get these two errors
error: expected primary-expression before '{' token
error: expected `;' before '{' token
I dont know why. However if i do pthread_mutex_t mute = PT...
Can anyone point me towards a definitive list of POSIX cancellation points?
I was just about to answer a question on stackoverflow and realised I didn't know my stuff well enough! In particular, are accept() and select() cancellation points? I have an old book that says no, but I've seen sites on the internet claim that they are. Con...
pthread takes in as its parameter void (start_routine)(void* userPtr), i was hoping i can use std::mem_fun to solve my problem but i cant.
I would like to use the function void * threadFunc() and have the userPtr act as the class (userPtr->threadFunc()). Is there a function similar to std::mem_func that i can use?
...