LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-15-2005, 02:53 AM   #1
gecoool
Member
 
Registered: Feb 2005
Location: Romania
Distribution: Fedora 2
Posts: 38

Rep: Reputation: 15
unusually long wait time for mutex


My initial problem: i wrote a multithreaded application, which uses several shared resources: a vector(v) which holds several maps(which hold i.e string-kwID) (one shared res), and other two maps(2nd and 3rd shared res). Ofcourse, i am using pthread_mutex_lock to acces the resources (v[i]), but ... the time it takes for a call like pthread_mutex_lock(&my_mutex[i]) (where my_mutex is a vector of pthread_mutex_t of the same size as the vector) is unusually long, it is about 0.1->1 microseconds (on a Athlon CPU@1800MHz). The sad thing is that it happens even if i start my program with one single thread. In theory the only time taken by the call for ptread_mutex_lock would be the time needed to execute the actual call. Unfortunately measuring the time taken for the call (pthread_mutex_lock) returns the same time as above, which seems to me way to long.
The reason for which I divided the map in several partitions (the number of the elements in the vector) was to avoid having two or more threads to wait for all the map. I think that doing so I decreased the probability for a pthread_mutex_lock to wait because the resource is being used. Even like this the pthread...lock calls are eating huge amounts of time.
What would be the usuall time for such a call like pthread_mutex_lock to execute (on a single threaded app), that is without actually waiting for the resource to become available ?

If anyone could suggest me anything, it would be great.
 
Old 11-15-2005, 11:58 AM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Unless i am mistaken a mutex operation is kernel deep, this is why it takes a "little" time for the op.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
controlling the wait time on boot up Veteq Linux - General 2 03-19-2005 04:10 PM
Long Time Reader - 1st Time Poster prissed LinuxQuestions.org Member Intro 1 08-10-2004 12:13 PM
normal wait time for yast2 package reading? l1fe Linux - Newbie 2 07-01-2004 03:20 PM
Reboot only after long wait Kroenecker Linux - Hardware 2 03-23-2004 08:02 AM
etho bootup dhcp wait time change skeletal29 Linux - Networking 4 06-19-2002 04:49 PM


All times are GMT -5. The time now is 06:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration