|
-
April 27th, 2011, 12:03 AM
#1
thread waiting at pthread_mutex_lock() does not leave the cpu
Hi all,
I am running a process which creates 12 threads and its function is to pass messages between other processes. Platform is montavista
The problem is :
one of its thread lock a mutex and before it can unlock it another thread try to lock that mutex and gets blocked, but for next 7 seconds no other thread get scheduled.
20 062244:538 Acquiring lock
20 062244:538 Acquired lock
20 062244:538 Message for PEER node
20 062244:676 Acquiring lock
20 062251:131 ############handleMessages: accept returned with fd:
function which was shared is
int handleMessage(void *pkt, int len)
{
int sockfd;
log("Acquiring lock");
pthread_mutex_lock(&data_handler_mutex);
log("Acquired lock");
sMessageHeader *temp = &(((sMessagePacket *)pkt)->msgHdr);
if((len != EXT_MSG_PKT_SIZE) && (len != MSG_PKT_SIZE))
log("\n ~~~~~~~ %s called for invalid length: %d",func, len); ........
please tell me what could be the problem.
-
April 27th, 2011, 12:04 PM
#2
Re: thread waiting at pthread_mutex_lock() does not leave the cpu
Isn't that what's supposed to happen? One thread locks the mutex, all others have to wait for it to unlock it.
Viggy
-
April 28th, 2011, 01:40 AM
#3
Re: thread waiting at pthread_mutex_lock() does not leave the cpu
Thanks for reply,
Other threads except the one which is waiting to get lock do not use that mutex. I guess i found the problem and it is with send() which actually blocks later in that function.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|