Lets say I have a class where each object should interact independently. For example, I may have various tables out of a database over many servers offsite. However, internally, I happen to know that some of the tables are linked, and I can save a significant amount of IO by grouping commands that do not require any response together. ...
Hi,
I'm working on the POSIX subsystem of my operating system project, and I've reached the point where I would like to work on pthreads support. However, I'm not certain about the extent to which I should implement them.
What is the most-used pthreads functionality? Is there anything I could safely "just stub out" for now and implemen...
A question about threads in C/C++...
C++0x syntax
#include <thread>
void dummy() {}
int main(int, char*[]) {
std::thread x(dummy);
std::thread y(dummy);
...
return 0;
}
How many threads are there? Two (x and y) or three (x, y and main)? Can I call this_thread::yield() in main? And what do I get from calling this_thread:...
I want to implement threading in c++.I am using visual stdio2008 and wish to implement threading using pthreads.can any one guide me about pthreads and also about there implementations in vs2008.Thanking in anticipation
...
I can't find any evidence online of pthread_cond_wait being strange on Mac OS X, but it seems to be failing the simplest test for me.
The function
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t * );
is supposed to unlock the mutex argument #2 and then wait for a signal to be sent on the condition argument #1. I wrote a simpl...
I am Cross Compiling PARSEC Benchmarks in Alpha, and several of the benchmarks seg fault when the program exits. I have narrowed the issue down to the Pthreads Library as I went ahead and ran a non-pthreads version and there was no seg fault. The programs get the correct results despite the seg fault, but this issue is unacceptable.
Som...
Hi all,
I have 2 questions :
Q1) Can i implement an asynchronous timer in a single threaded application i.e i want a functionality like this.
....
Timer mytimer(5,timeOutHandler)
.... //this thread is doing some other task
...
and after 5 seconds, the timeOutHandler function is invoked.
As far as i can think this cannot be done ...
I'm using this dtrace script from here to try to find when context switches occur for the threads of a java program.
I'm trying to match the data gathered from the script with trace data gathered from the running program (things like method entry/exit). I get the pthread id of the running thread using a short JNI method that simply ret...
The function header for pthread_create looks like this:
int pthread_create(pthread_t * thread,
const pthread_attr_t * attr,
void * (*start_routine)(void *),
void *arg);
I understand it all except that the function pointer for start_routine is of the form void* (fpointer) (void...
I need to pass multiple arguments to a function that I would like to call on a separate thread. I've read that the typical way to do this is to define a struct, pass the function a pointer to that, and dereference it for the arguments. However, I am unable to get this to work:
#include <stdio.h>
#include <pthread.h>
struct arg_struct {...
Hi everyone.
I've been working with pthreads a fair bit recently and there's one little thing I still don't quite get. I know that condition variables are designed to wait for a specific condition to come true (or be 'signalled'). My question is, how does this differ at all from normal mutexes?
From what I understand, aren't condition ...
One resource on Linux mentions pthread-create being implemented with clone system call as against other unix-based platform (which implement the same in some other ways).
This means that under linux two threads created from the same process using pthread_create will have different parent process ids.
$ ./a.out
new thread: pid 662...
With no explicit scheduling, pthreads are scheduled to run by the kernel in a random manner.
Are there any scheduling methods defined in the pthread library for the same such as priorities?
...
Is there a mechanism that I can use to tell if a pthread thread is currently running, or has exited? Is there a method for pthread_join() that is able to timeout after a specific period of time if the thread has not yet exited?
...
Hey guys I was wondering if someone could provide a little help.
I've been trying to teach myself pthreads and with that, mutex locks to get threads running together and using the same structure, whilst not reading and writing to bad data.
My problem at the moment is,
From my thread function, if i call a helper function that might loo...
I'm trying to learn how to program parallel algorithms in C using POSIX threads. My environment is a Mac OS X 10.5.5 with gcc 4.
Compiling:
gcc -Wall -D_REENTRANT -lpthread source.c -o test.o
So, my problem is, if I compile this in a Ubuntu 9.04 box, it runs smoothly in thread order, on Mac looks like mutexes doesn't work and the thr...
I have a program which:
has a main thread (1) which starts a server thread (2) and another (4).
the server thread (2) does an accept(), then creates a new thread (3) to handle the connection.
At some point, thread (4) does a fork/exec to run another program which should connect to the socket that thread (2) is listening to. Occasion...
Which operating system platform(s) (other than Windows) lack support for POSIX threads ("pthreads")?
...
Hey everyone, considering the following code (compiled with g++ -lpthread thread_test.cpp) how can I know what number thread I am in from inside "thread_function"? And let me know if you have any other suggestions.
Thanks!
thread_test.cpp:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
class A {
p...
I am working on some code which uses the pthread and semaphore libraries. The sem_init function works fine on my ubuntu machine, but on OS X the sem_init function has absolutely no effect. Is there something wrong with the library or is there a different way of doing it? This is the code I am using to test.
sem_t sem1;
sem_t sem2;
sem_t...