[Bug 7220] New: thread can' t be scheduled(pthread_mutex_lock)

bugzilla at busybox.net bugzilla at busybox.net
Sat Jun 21 03:40:44 UTC 2014


https://bugs.busybox.net/show_bug.cgi?id=7220

           Summary: thread can't be scheduled(pthread_mutex_lock)
           Product: uClibc
           Version: 0.9.33.3
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P5
         Component: Threads
        AssignedTo: unassigned at uclibc.org
        ReportedBy: jh at yealink.com
                CC: uclibc-cvs at uclibc.org
   Estimated Hours: 0.0


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; 
}

/*************************************************/

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the uClibc-cvs mailing list