Skip to content

Facilitate Multi-Threaded Access #33

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

Closed
wants to merge 7 commits into from

Conversation

garethpotter
Copy link
Collaborator

Add a request per-context and a reader-writer lock to facilitate uncontended concurrent reads.

Copy link
Contributor

@martinjaeger martinjaeger left a comment

Choose a reason for hiding this comment

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

This is quite a huge breaking change (it touches almost every function).

Can you please give a bit more context under which circumstances this is needed? Most importantly: Do we really need the struct thingset_global_context to facilitate a readers-writer locking mechanism?

Comment on lines +1676 to +1678
struct k_mutex reader_wait_writer;
struct k_sem sem;
atomic_t reader_count;
Copy link
Contributor

Choose a reason for hiding this comment

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

These member variables should be documented.

@garethpotter
Copy link
Collaborator Author

I'm going to close this because I think we're going to adopt another approach.

For posterity though, my original rationale for it was based on a theory more than anything else that if a device is being read (or is publishing) more than it is being written to (probably usually the default?), there is no need for read access to be mutually exclusive, hence the reader-writer lock. To make that work, the buffers involved obviously need to become per-operation rather than global, so I:

  • repurposed the thingset_context as a sort of per-operation context
  • made the truly global parts (i.e. the object array, the replacement for the mutex lock) of that struct part of thingset_global_context.

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