Skip to content

pthread_mutex1: Enable contention on a shared pthread_mutex across pr…#39

Open
ivanalgo wants to merge 1 commit into
antonblanchard:masterfrom
ivanalgo:pthread_mutex1
Open

pthread_mutex1: Enable contention on a shared pthread_mutex across pr…#39
ivanalgo wants to merge 1 commit into
antonblanchard:masterfrom
ivanalgo:pthread_mutex1

Conversation

@ivanalgo

Copy link
Copy Markdown

pthread_mutex1: Enable contention on a shared pthread_mutex across processes

The original "Contended pthread mutex" test case was unfair when comparing
threads and processes, because each process created by fork() used its own
copy of the pthread_mutex_t, resulting in no actual contention between processes.

To make the test fair and meaningful in both multi-threaded and multi-process
modes, this patch modifies the test to allocate a pthread_mutex_t in a shared
memory region (mmap), and initializes it with PTHREAD_PROCESS_SHARED so that
all processes contend on the same mutex.

This change ensures that contention happens on the same mutex object regardless
of whether the test is run using threads or processes.

Signed-off-by: Yongting Lin linyongting@gmail.com

…ocesses

The original "Contended pthread mutex" test case was unfair when comparing
threads and processes, because each process created by fork() used its own
copy of the pthread_mutex_t, resulting in no actual contention between processes.

To make the test fair and meaningful in both multi-threaded and multi-process
modes, this patch modifies the test to allocate a pthread_mutex_t in a shared
memory region (mmap), and initializes it with PTHREAD_PROCESS_SHARED so that
all processes contend on the same mutex.

This change ensures that contention happens on the same mutex object regardless
of whether the test is run using threads or processes.

Signed-off-by: Yongting Lin <linyongting@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant