I understand the differences between a multithreaded program and a program relying on inter-machine communication. My problem is that I have a nice multithreaded program written in 'C' that works and runs really well on an 8-core machine. There is now opportunity to port this program to a cluster to gain access to more cores. Is it wo...
I'm having a strange problem. I have the following code:
dbg("condwait: timeout = %d, %d\n",
abs_timeout->tv_sec, abs_timeout->tv_nsec);
ret = pthread_cond_timedwait( &q->q_cond, &q->q_mtx, abs_timeout );
if (ret == ETIMEDOUT)
{
dbg("cond timed out\n");
return -ETIMEDOUT;
}
dbg calls gettimeofd...
I have an application that runs multiple threads which are sometimes cancelled. These threads may call into another object that internally accesses a resources (socket). To prevent the resource to be accessed simultaneously, there is a critical section to get some order in the execution.
Now, when cancelling the thread, it (sometimes) h...
I am working on a project and trying to use pthread_cond_wait() and pthread_cond_signal() to synchronize two threads.
My code looks something like this:
pthread_mutex_t lock_it = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t write_it = PTHREAD_COND_INITIALIZER;
int main(int argc, char**argv)
{
pthread_t t_send_segments, t_re...
Hi!
I have a question: Is there some way to the SPID in linux 2.6 from a C++ application? When I do a "ps -amT" I can see the threads in the process:
[email protected]:~# ps -amT
PID SPID TTY TIME CMD
1120 - pts/1 00:00:20 sncmdd
- 1120 - 00:00:00 -
- 1125 - 00:00:00 -
- 1126 - 00...
I'm using the pthread library on Linux.
I'm assigning a string in thread A, and then trying to print the string in thread B. However, the string just prints out empty (I have verified that it works in thread A).
Note: The string resides inside an object, which I suspect may be getting cleaned up or re-instantiated empty... The containe...
I'm doing a simple ray tracer in C++ using SDL for graphics and pthread for threading. And I have a problem making my program utilizing two cores, the threads work, they just don't drive both cores to 100%. To interface SDL I write directly to it's memory, SDL_Surface.pixels, so I assume that it can't be SDL locking me.
My thread functi...
I previously inquired about synchronizing two threads without using pthread_join and I was able to resolve it using pthread_cond_wait and pthread_cond_signal.
I've written a small struct to bundle this functionality into a single place:
struct ConditionWait
{
int i_ConditionPredicate;
pthread_mutex_t lock_Var;
pthread_c...
After posting my solution to my own problem regarding memory issues, nusi suggested that my solution lacks locking.
The following pseudo code vaguely represents my solution in a very simple way.
std::map<int, MyType1> myMap;
void firstFunctionRunFromThread1()
{
MyType1 mt1;
mt1.Test = "Test 1";
myMap[0] = mt1;
}
void only...
pthread_create returns the value 251 without creating the thread. Does anyone know what the problem is? Please help. The machine is a HP-UX.
I'm new to multi-threading.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *print_message_function( void *ptr );
main()
{
pthread_t thread1, threa...
I want to make an opengl application that shows some 3d graphics and a command-line. I would like to make them separate threads, because they both are heavy processes. I thought that I could approach this with 2 different viewports, but I would like to know how to handle the threads in opengl.
According to what I've been reading, Opengl...
(I think that) the consensus number for a mutex is 2.
What is the consensus number for semaphores (like in pthread_sem_*)?
What is the consensus number for condition variables (like in pthread_cond_*)?
...
#include <pthread.h>
static void * worker_thread(void *);
void some_func(void)
{
pthread_t * tmp;
tmp = malloc(sizeof(pthread_t));
if (NULL != tmp)
{
if (!pthread_create(tmp, NULL, worker_thread, (void *)tmp))
pthread_detach(*tmp);
else
free(tmp);
}
}
static void * worker_thre...
Hello,
is it possible to know how much memory is being used by a given phtread thread? I am interested by a VmRSS like information.
...
Hello,
I am working on a trace tool for multithread applications, more especially about memory allocation.
I would like a per thread memory allocation. I know that when a thread do a malloc, the memory used is the global heap. I would like to trace which thread allocated how much memory.
I did a wrapper upon malloc, incrementing value...
I am looking for lightweight multi-threading framework for C++. I found POSIX Threads.
Please, share you practical experience with POSIX threads: before I start with it I want to know its pros and cons from real people, not from wiki.
If you practically compared it with anything (maybe, better), it would be interesting to know either.
...
This Linux Magazine article http://www.linux-mag.com/id/792 explains the difference in the way threads are implemented in Linux as compared to commercial Unixs such as Solaris. In summary, Linux uses a 1-to-1 mapping of user threads to kernel threads, while Solaris uses a many to many mapping. The article implies that this might give Sol...
AIX (and HPUX if anyone cares) have a nice little feature called msemaphores that make it easy to synchronize granular pieces (e.g. records) of memory-mapped files shared by multiple processes. Is anyone aware of something comparable in linux?
To be clear, the msemaphore functions are described by following the related links here.
...
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 access variables in the structure - t.a, t.b or t.c, I keep getting an error - request for member in something not a structure or union.
What alternate ...
Hi.
I´m pretty new to programming in C++ and I´m using pthreads. I´m cross compiling my code for OpenWRT but for some reason I get segmentation fault when I run the program on my board but it runs fine on my PC. I suspect that the error occurs in the linking stage of the compilation because I tried a small C program and that worked fine...