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

Multi-threading #28

Merged
merged 5 commits into from
May 12, 2024
Merged

Multi-threading #28

merged 5 commits into from
May 12, 2024

Conversation

linguini1
Copy link
Collaborator

This PR implements multi-threading for sensor data collection. This has a few benefits:

Scheduler Control

The scheduler handles which threads get to run, so multiple operations can be performed concurrently when the I2C bus is not locked, speeding up the program. Any sensors (like the system clock) that do not use the I2C bus can run significantly more often.

Additionally, threads can be given higher or lower priorities, which is useful for prioritizing certain data to collect when fetcher is modified to receive commands eventually.

Better sensor interface

The original sensor interface/API developed for fetcher has limitations, such as reducing precision into only three options, allowing only a single piece of data to be read at a time using polling, etc.

Now, the sensor drivers can be written as C utilities for full control over the sensor implementation, making use of all the options a sensor can offer. Additionally, for sensor with batch read operations (like the GPS), these batch read commands can be sent and then the thread can block until the data is prepared, relinquishing the bus to other sensors in the meantime.

This additional thread of control allows InSpace devs to put whatever logic they want to control how a sensor collects data into its own thread of control, removing any limitations of the previous API.

Notes

In the future, sensor threads should communicate with the main thread of control using message queues instead of printing the information themselves. This is a temporary fix while I wait to enable mqueue in the microkernel image.

@linguini1 linguini1 added the enhancement New feature or request label May 12, 2024
@linguini1 linguini1 self-assigned this May 12, 2024
@linguini1 linguini1 merged commit 1a84e81 into main May 12, 2024
1 check passed
@linguini1 linguini1 deleted the threading branch May 12, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant