Skip to content

Conversation

@aayushi363
Copy link
Collaborator

Added a function to write shm_global_variable address which is protected by the mutexes. Another function to read shm_global_variable with a thread local variable to make sure it read only once. This way we avoid the race happening between reading and writing of this shared global variable.

Added a function to write shm_global_variable address which is protected
by the mutexes. Another function to read shm_global_variable with a
thread local variable to make sure it read only once. This way we avoid
the race happening between reading and writing of this shared global
variable.
Comment on lines +34 to +36
if (local_shm_start == NULL) {
local_shm_start = global_shm_start;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be wrapped in a pthread_mutex_lock()/pthread_mutex_unlock(), but otherwise it's good

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I say this, I meant only line 35 to be precise since local_shm_start is thread_local.

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.

2 participants