I try to inject the exception to thread using signals, but some times the exception is not get caught. For example the following code:
void _sigthrow(int sig)
{
throw runtime_error(strsignal(sig));
}
struct sigaction sigthrow = {{&_sigthrow}};
void* thread1(void*)
{
sigaction(SIGINT,&sigthrow,NULL);
try
{
while(...
Hello,
I'm looking for a way to use pthread rwlock structure with conditions routines in C++.
I have two questions:
First: How is it possible and if we can't, why ?
Second: Why current POSIX pthread have not implemented this behaviour ?
To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing ...
Hello,
I am looking for a method to implement lock-free queue data structure that supports single producer, and multiple consumers. I have looked at the classic method by Maged Michael and Michael Scott (1996) but their version uses linked lists. I would like an implementation that makes use of bounded circular buffer. Something that us...
When I run GDB against a program which loads a .so which is linked to pthreads, GDB reports error "Cannot find new threads: generic error".
Note that executable that I run is not linked with pthreads.
Any clues?
$ gdb --args lua -lluarocks.require
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv...
Okay, so if I'm running in a child thread on linux (using pthreads if that matters), and I run the following command
kill(getpid(), someSignal);
it will send the given signal to the parent of the current thread.
My question: Is it guaranteed that the parent will then immediately get the CPU and process the signal (killing the app if ...
There's a weird behavior in my threads:
void * foo(void * nic){
printf("foo");
}
void * threadF(void * pointer){
printf("1\n");
pthread_t threadT;
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_create(&threadT,NULL,&foo,(void*)NULL);
pr...
I'd like to minimize synchronization and write lock-free code when possible in a project of mine. When absolutely necessary I'd love to substitute light-weight spinlocks built from atomic operations for pthread and win32 mutex locks. My understanding is that these are system calls underneath and could cause a context switch (which may be...
I have an application developed under Linux with GCC 4.2 which makes quite heavy use of stringstreams to wrap and unwrap data being sent over the wire. (Because the Grid API I'm using demands it). Under Linux everything is fine but when I deploy to SunOS (v5.10 running SPARC) and compile with GCC 3.4.6 the app hangs when it reaches the p...
I have a weird problem with my threaded software.
I start 2 instances of the software. Each instance has 2 threads, one thread creates a socket to use, and the other one is uses the socket for communication.
When one of the threads in one instance calls sleep(3), the other threads in the the other instance sleeps too. And the weirdest...
I’m buried in multithreading / parallelism documents, trying to figure out how to implement a threading implementation in a programming language I’ve been designing.
I’m trying to map a mental model to the pthreads.h library, but I’m having trouble with one thing: I need my interpreter instances to continue to exist after they complete ...
I've implemented the Barnes-Hut gravity algorithm in C as follows:
Build a tree of clustered stars.
For each star, traverse the tree and apply the gravitational forces from each applicable node.
Update the star velocities and positions.
Stage 2 is the most expensive stage, and so is implemented in parallel by dividing the set of star...
I’m reading up on pthread.h; the condition variable related functions (like pthread_cond_wait(3)) require a mutex as an argument. Why? As far as I can tell, I’m going to be creating a mutex just to use as that argument? What is that mutex supposed to do?
...
Write program that has two threads one is reading numbers from the user and the other is printing them such that the first thread reads a new number only after it has been printed by the second thread. Declare one global varaible to use for reading and printing.
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
sem_t m;
vo...
I try to build an application which uses pthreads and __m128 SSE type. According to GCC manual, default stack alignment is 16 bytes. In order to use __m128, the requirement is the 16-byte alignment.
My target CPU supports SSE. I use a GCC compiler which doesn't support runtime stack realignment (e.g. -mstackrealign). I cannot use any ot...
I have a large tree structure on which several threads are working at the same time. Ideally, I would like to have an individual mutex lock for each cell.
I looked at the definition of pthread_mutex_t in bits/pthreadtypes.h and it is fairly short, so the memory usage should not be an issue in my case.
However, is there any performanc...
I'm looking for a good multi-thread-aware debugger, capable of showing performance charts of application threads on Linux, don't know if such a thing exists, perhaps as a Eclipse plugin.
The idea would be to track per thread memory allocation a CPU usage as well as being able to interrupt a thread and examine its stack trace, local vars,...
Hello,
I'm using pthreads-win32 to allow threading support for windows.
I have a cross platform project that uses pthreads and I want to make it work on windows with various compilers and different OS versions.
At least, according to the documentation pthreads-win32 should work with MSVC and even
MSVC builds provided.
But I don't kno...
I'm a little new to threading, so you'll have to forgive the naiveté of this question.
How is pthread_join implemented and how does it effect thread scheduling?
I always pictured pthread_join implemented with a while loop, simply causing the calling thread to yield until the target thread completes. Like this (very approximate pseudoc...
Hi,
I want to create a custom malloc which allocates memory blocks within a given address range.
I am writing a pthreads application in which threads are bound to unique cores on a many-core machine. The memory controllers are statically mapped, so that certain range of addresses on main memory are electrically closer to a core.
I want...
A part of an application I'm working on is a simple pthread-based server that communicates over a TCP/IP socket. I am writing it in C because it's going to be running in a memory constrained environment. My question is: what should the program do if one of the threads encounters a malloc() that returns NULL? Possibilities I've come up wi...