Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msgq: use shared memory mutex and condition variables for synchronization #617

Closed

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented May 30, 2024

This PR resolve issue #208, enhances the msgq with shared memory mutexes and condition variables for improved IPC synchronization. While handling signals interrupts all processes, shared memory mechanisms provide a more robust and efficient solution, reducing overhead and complexity in high-frequency event scenarios.

key changes:

Each block of shared memory used for messages now includes a header:


struct SharedMemoryHeader {
  pthread_mutex_t mutex;
  pthread_cond_t cond;
  bool initialized;
};

This header contains the IPC mutex, condition variable, and an initialization flag.

When sending a message, the corresponding condition variable is used to notify the receiver to retrieve the message.
The Poller uses a global shared memory context, PollerContext, to handle message notifications and reception efficiently.

@pd0wm If you have a moment, your review of this PR would be greatly appreciated to ensure I haven't missed anything or introduced new issues.

@deanlee deanlee closed this May 30, 2024
@deanlee deanlee reopened this May 30, 2024
@deanlee deanlee force-pushed the use_shared_memory_to_notify_receivers branch from 9a44f24 to 29123b7 Compare May 30, 2024 20:29
@deanlee deanlee marked this pull request as draft May 30, 2024 20:32
@deanlee deanlee force-pushed the use_shared_memory_to_notify_receivers branch 2 times, most recently from a095ab3 to b10fb02 Compare May 31, 2024 07:29
@deanlee deanlee marked this pull request as ready for review May 31, 2024 09:07
@deanlee deanlee marked this pull request as draft June 26, 2024 10:42
@deanlee deanlee force-pushed the use_shared_memory_to_notify_receivers branch from b10fb02 to 77e5aff Compare June 29, 2024 01:51
@deanlee
Copy link
Contributor Author

deanlee commented Jul 3, 2024

Closed. linux futex #625 appears to be a more efficient solution compared to using mutex and condition variables.

@deanlee deanlee closed this Jul 3, 2024
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