0

I implemented a sorted linked list as two versions. The first one is using single mutex for the entire list and the second one uses single rwlock for the entire list.

I ran half of the operations as Member and the other half made of Insert(0.25) and Delete(0.25) operations. I plotted the time against a number of threads and in this case was not as expected that the time for rwlock was higher than mutex.

How can this happen? When there are more than 90% Member operations then rwlocks were better as expected.

Amila Senadheera
  • 12,229
  • 15
  • 27
  • 43
  • 3
    Your qeustion belongs elsewhere in the SO universe. Select your planet [here](https://stackexchange.com/sites). When migrated... post also some minimal code as test example. – ZF007 Apr 02 '19 at 05:51
  • 1
    "Can the overhead of rwlock is higher than the overhead of mutex?" - Yes, it can. `rwlock` implements more complex constraints than a simple `mutex`, so it may consume more memory. Not sure what is "I run half of the operations as `Member`", but inserting and deleting elements from the list are mutation operations, and they are run exclusively both with `mutex` and with `rwlock`. Why do you expect `rwlock` to show better results in that case? – Tsyvarev Apr 02 '19 at 22:23
  • @Tsyvarev could you please look into the plots [here](https://unix.stackexchange.com/questions/510038/can-the-overhead-of-rwlock-is-higher-than-the-overhead-of-mutex) and explain the situation. – Amila Senadheera Apr 03 '19 at 08:27
  • Hm, I am not sure why the first commenter suggests to ask the question on other Stack Exchange site. From my understanding, the question is definitely a programming one and belongs to Stack Overflow. You suggest to look into plots, but you still don't describe what "operations as `Member`" mean. Please, update your question post with **more details**. – Tsyvarev Apr 03 '19 at 09:18
  • `Member` means searching the list for a given integer by traversing the list starting from the first node. `Delete` and `Insert` operations do the same traversing and do delete the node if found or insert a new node to the correct position in sorted list. – Amila Senadheera Apr 03 '19 at 09:31

0 Answers0