Date: Sat, 19 Mar 2011 16:32:53 +0800
From: ??<dunning2...@gmail.com>
To: Ian Collins<i...@ianshome.com>,
        opensolaris-discuss@opensolaris.org
Subject: Re: [osol-discuss] libc thread failure:
        _thread_setschedparam_main() fails
Message-ID:
        <AANLkTi=qoytk+ck_q+nvi0hnydoysrgvbwkz0axxt...@mail.gmail.com>
Content-Type: text/plain; charset="gb2312"

Actually, I am writing a new spm_malloc() interface for some academic
research reason. The spm_malloc() is going to allocate a small on-chip
memory for multicore.

it looks like: void *spm_malloc(long bytes), I test the function in many
programs, it works ok.

In this example, the malloc() is called like this:

struct queue {
   int head, tail;
   void ** data;
   int size;
   int threads;
   int end_count;
#ifdef PARALLEL
   pthread_mutex_t mutex;
   pthread_cond_t empty, full;
#endif //PARALLEL
};

struct queue *chunk_que;

chunk_que = spm_normal_malloc(sizeof(struct queue) * nqueues);

pthread_mutex_init(&que->mutex, NULL);

pthread_mutex_lock(&que->mutex);  //The error occurs here!
...

Can you tell me how the malloc() function will do some relationship with the
pthread_mutex_lock() function? I think that is the point. Many thanks.

The confusing message is caused (in Solaris 10) by calling
pthread_mutex_lock() on an uninitialized mutex, due to
random garbage in the mutex.

Go check your test program.  It is not doing what you think it is.
Check the return code from your call to pthread_mutex_init().

If you want more help, post a complete test program, not just
the snippets shown above.

Roger Faulkner

_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org

Reply via email to