For Linux consult the following man pages: pthread_mutexattr_init (with sample) pthread_mutexattr_setpshared pthread_condattr_init pthread_condattr_setpshared Methods, types, constants etc. Are normally defined in usr/include/pthread. H usr/include/nptl/pthread.h.
For Linux consult the following man pages: pthread_mutexattr_init (with sample) pthread_mutexattr_setpshared pthread_condattr_init pthread_condattr_setpshared Methods, types, constants etc. Are normally defined in /usr/include/pthread. H, /usr/include/nptl/pthread.h.
Vlad, I'm on Linux, there's no such attribute (according to the manpages). – janesconference Mar 19 '10 at 13:51 @james, check your header files (find /usr/include/ -type f | xargs egrep '(PTHREAD_PROCESS_SHARED|pthread_condattr_setpshared|pthread_mutexattr_setpshare? D)'), it should all be there in /usr/include/pthread.
H, even on Linux (it's POSIX after all, and I have it on my CentOS 4. X box. ) – vladr Mar 19 '10 at 14:12 ...which also bears the question, while we're at it, what Linux are you on?
:) (uname -a; cat /etc/issue) – vladr Mar 19 '10 at 14:23 I'm on Montavista for ARM 9. – janesconference Mar 19 '10 at 17:37 you were right! Thanks.
– janesconference Mar 19 '10 at 14:43.
This is the example code from opengroup. Org: pthread_cond_wait(mutex, cond): value = cond->value; /* 1 */ pthread_mutex_unlock(mutex); /* 2 */ pthread_mutex_lock(cond->mutex); /* 10 */ if (value == cond->value) { /* 11 */ me->next_cond = cond->waiter; cond->waiter = me; pthread_mutex_unlock(cond->mutex); unable_to_run(me); } else pthread_mutex_unlock(cond->mutex); /* 12 */ pthread_mutex_lock(mutex); /* 13 */ pthread_cond_signal(cond): pthread_mutex_lock(cond->mutex); /* 3 */ cond->value++; /* 4 */ if (cond->waiter) { /* 5 */ sleeper = cond->waiter; /* 6 */ cond->waiter = sleeper->next_cond; /* 7 */ able_to_run(sleeper); /* 8 */ } pthread_mutex_unlock(cond->mutex); /* 9.
I am asking because, it's a very common mistake : Your process must not call wait() unless you are sure that some process will call signal() (or broadcast()) later. Concidering this code (from pthread_cond_wait man page) : pthread_mutex_lock(&mut); while (x check if the condition is still true -> do work. Hope it's clear.
– janesconference Mar 22 '10 at 17:38 @janesconference : see my edit – Ben Mar 23 '10 at 9:50.
What the last poster said is correct. The KEY to the whole cond-variable situation working correctly is that the cond-var is NOT signalled prior to it being waited on. Its strictly a signal that is to be used when others (single or multiple) are waiting.
When no one is waiting, its effectively a NOP. Which, btw, is NOT how I believe it SHOULD work, but how it DOES work. Larry.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.