pthread_mutex1: Enable contention on a shared pthread_mutex across pr…#39
Open
ivanalgo wants to merge 1 commit into
Open
pthread_mutex1: Enable contention on a shared pthread_mutex across pr…#39ivanalgo wants to merge 1 commit into
ivanalgo wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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