-
as seen on Stack Overflow
- Search for 'Stack Overflow'
On Linux (kernel 2.6.5) our build system calls gcc with -D_REENTRANT.
Is this still required when using pthreads?
How is it related to gcc -pthread option? I understand that I should use -pthread with pthreads, do I still need -D_REENTRANT?
On a side note, is there any difference that you know…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I'm using read/write locks on Linux and I've found that trying to upgrade a read locked object to a write lock deadlocks.
i.e.
// acquire the read lock in thread 1.
pthread_rwlock_rdlock( &lock );
// make a decision to upgrade the lock in threads 1.
pthread_rwlock_wrlock( &lock ); // this…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi,
I cannot compile this code under SUA:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void * thread_function(void *arg) {
printf("thread_function started. Arg was %s\n", (char *)arg);
// pause for 3 seconds
sleep(3);
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi all, I'm working on a graphical application which looks something like this:
while (Simulator.simulating)
{
Simulator.update();
InputManager.processInput();
VideoManager.draw();
}
I do this several times a second, and in the vast majority of cases my computation will be taking up…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Iam new to c programming and needs some help.
long *taskids[NUM_THREADS];
for(t=0; t<NUM_THREADS; t++)
{
taskids[t] = (long *) malloc(sizeof(long));
*taskids[t] = t;
printf("Creating thread %ld\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *) taskids[t]);
...
}
This…
>>> More