Hi,
I just tried a very simple program:
pthread_mutex_t mutex_here;
void *start_it( void *arg ){
pthread_mutexattr_t attr;
pthread_mutexattr_init( &attr );
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( &mutex_here, &attr );
rtl_printf( "Locking 1st\n" );
pthread_mutex_lock( &mutex_here );
rtl_printf( "Locking 2nd\n" );
pthread_mutex_lock( &mutex_here );
rtl_printf( "UnLocking 2nd\n" );
pthread_mutex_unlock( &mutex_here );
rtl_printf( "UnLocking 1st\n" );
pthread_mutex_unlock( &mutex_here );
}
pthread_t start;
int um_module_init(void){
if ( pthread_create( &start, NULL, start_it, NULL ) ){
rtl_printf( "Couldn't create thread!\n" );
return -1;
}
return 0;
}
void um_module_exit( void ){
}
module_init( um_module_init );
module_exit( um_module_exit );
-------------------------------------------------------------------
According to what I read about the mutexes and especially about
PTHREAD_MUTEX_RECURSIVE, this should give
Locking 1st
Locking 2nd
UnLocking 2nd
UnLocking 1st
But the thread hangs after printing the second line, like I would expect to do
it if the attribute was PTHREAD_MUTEX_NORMAL. What am I doing wrong?
Thanks for any help,
Linus
_______________________________________________
Rtl mailing list
[EMAIL PROTECTED]
http://www2.fsmlabs.com/mailman/listinfo.cgi/rtl