Linux version: Linux version 3.4.20-rt31+ gcc version: gcc version 4.6.4 20120303 (prerelease) (GCC) processor infomation: Processor : ARM926EJ-S rev 5 (v5l) BogoMIPS : 199.06 Features : swp half thumb fastmult edsp java testing procedure: 1.build test code # arm-dspg-linux-uclibceabi-gcc -o lock_test pthread_lock_test.c -lpthread -Wall 2.run at linux shell # ./lock_test 212121212121211111111111111111111111111111111111111111^C # # ./lock_test 12211221211221122121212112212121212121^C # # ./lock_test 12211212121221111111111111111111111111111111111111111111111111^C # ./lock_test 122112211212211221121221122112212112211221212121122121212121212121212121212121212121212222222222222222222222222222222222222222222222222222222222222222222^C # The results of the analysis: 1.When problems arise PC at pthread_mutex_lock function call can not quit,this thread can't be scheduled(stopped). 2.Two threads(thread1,thread2) are likely happen. test code:pthread_lock_test.c /*************************************************/ #include <unistd.h> #include <pthread.h> #include <string.h> #include <stdio.h> #include <linux/futex.h> #include <sys/time.h> #include <errno.h> pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static int sequence1 = 0; static int sequence2 = 0; int func1() { pthread_mutex_lock(&mutex); ++sequence1; pthread_mutex_unlock(&mutex); if(sequence1 % 60000 == 0) write(2, "1", 1); return 0; } int func2() { pthread_mutex_lock(&mutex); ++sequence2; pthread_mutex_unlock(&mutex); if(sequence2 % 60000 == 0) write(2, "2", 1); return 0; } void* thread1(void* arg) { while (1) func1(); } void* thread2(void* arg) { while (1) func2(); } int main() { pthread_t tid[2]; if (pthread_create(&tid[0], NULL, &thread1, NULL) != 0) { _exit(1); } if (pthread_create(&tid[1], NULL, &thread2, NULL) != 0) { _exit(1); } while(1) sleep(50000000); return 0; } /*************************************************/