Hello QNXers,
I am trying to coordinate data transfer between two threads using
pthread_sleepon_* functions. My starting point is the discussion
about sleepon locks in Ch. 1 of Rob Krten’s book “Getting Started with
QNX Neutrino2” including default attributes of the threads.
The main mechanism is the blocking of one thread by a call to
pthread_sleepon_wait() until the other thread wakens it by a
pthread_sleepon_signal(). From my first attempts at this
implementation, it appears that the _signal function in the active
thread is not causing the blocked thread to wake up.
- Is there a known problem with pthread_sleepon_signal()?
For the morbidly curious, here’s the abridged version of my current
code (extended a bit from Krten’s example):
volatile char line_data_ready = 0; //start with empty buffer
main(): {
pthread_create(&recv_tid, NULL, &recv_lines, &recv_arg);
pthread_create(&send_tid, NULL, &send_lines, &send_arg):
…
<pthread_join()s occur next>
}
recv_lines():
while( ) {
pthread_sleepon_lock()
while(!line_data_ready)
pthread_sleepon_wait(&line_data_ready)
printf(“SCORE!”)
line_data_ready = 0;
pthread_sleepon_signal(&line_data_ready) // notify send_lines()
pthread_sleepon_unlock()
}
send_lines()
while( ) {
pthread_sleepon_lock()
while(line_data_ready)
pthread_sleepon_wait(&line_data_ready)
printf(“SEND MORE”)
sleep()
line_data_ready = 1
pthread_sleepon_signal(&line_data_ready) //notify recv_lines()
pthread_sleepon_unlock()
}
My understanding is that the _signal() call should awaken the other
thread but I only see one “SEND MORE” and pidin indicates that each
thread is in the CONDVAR state and blocked on b034b2e0.
- What is b034b230? (It’s not the address of line_data_ready)
Gratefully yours,
Bob Bottemiller
Stein.DSI/Redmond, WA USA