rootfs/aboriginal-1.4.5/sources/root-filesystem/src/thread-hello2.c
// Receive a block of data through mailbox.
Receive a block of data through mailbox.
Receive a block of data through mailbox .
void thread_receive(struct thread_info *ti, char **data, unsigned *len)
{
	pthread_mutex_lock(&(ti->wakeup_mutex));
	if (!ti->len)
		pthread_cond_wait(&(ti->wakeup_receive), &(ti->wakeup_mutex));
	*data = ti->data;
	*len = ti->len;
	ti->len = 0;
	pthread_cond_signal(&(ti->wakeup_send));
	pthread_mutex_unlock(&(ti->wakeup_mutex));
}
void thread_receive ( struct thread_info * ti , char * * data , unsigned * len ) { pthread_mutex_lock ( & ( ti -> wakeup_mutex ) ) ; if ( ! ti -> len ) pthread_cond_wait ( & ( ti -> wakeup_receive ) , & ( ti -> wakeup_mutex ) ) ; * data = ti -> data ; * len = ti -> len ; ti -> len = 0 ; pthread_cond_signal ( & ( ti -> wakeup_send ) ) ; pthread_mutex_unlock ( & ( ti -> wakeup_mutex ) ) ; }
Receive a block of data through mailbox.
Receive a block of data through mailbox .
// If sender is waiting to send us a second message, wake 'em up. // Note that "if (ti->len)" be used as an unlocked/nonblocking test for // pending data, although you still need call this function to read data.