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

Making MIN_SLEEP_DURATION a platform variable and Add busy wait #403

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

soyerefsane
Copy link
Collaborator

As discussed in #332, I have moved forward to make the following changes for the threaded runtime:

  • If the wait duration is less than MIN_SLEEP_DURATION the wait_until function busy waits until wait_until_time is reached.
  • MIN_SLEEP_DURATION was defined as an arbitrary constant of 10 usec, I changed that to be a platform variable such that the value of MIN_SLEEP_DURATION is equal to underlying system's clock resolution.

@soyerefsane soyerefsane requested a review from edwardalee March 28, 2024 01:43
@soyerefsane soyerefsane added enhancement Enhancement of existing feature bugfix labels Mar 28, 2024
@soyerefsane soyerefsane marked this pull request as draft March 28, 2024 02:07
@soyerefsane
Copy link
Collaborator Author

I made the MIN_SLEEP_DURATION a platform property but realized the clock resolution value was just for Unix-based platforms, WIP is to update the other support files to add the declaration of MIN_SLEEP_DURATION based on their clk resolutions right now.

@soyerefsane soyerefsane removed the request for review from edwardalee March 28, 2024 05:58
Copy link
Contributor

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

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

Good direction. Suggestions added.

Comment on lines 242 to 243
LF_PRINT_DEBUG("Wait time " PRINTF_TIME " is less than MIN_SLEEP_DURATION " PRINTF_TIME ". Skipping wait.",
wait_duration, MIN_SLEEP_DURATION);
Copy link
Contributor

Choose a reason for hiding this comment

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

This debug message is no longer accurate. Please update.

@@ -42,7 +42,7 @@
* to prevent unnecessary delays caused by simply setting up and
* performing the wait.
*/
#define MIN_SLEEP_DURATION USEC(10)
// #define MIN_SLEEP_DURATION USEC(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

We prefer to just remove code rather than commenting it out.

@@ -1,6 +1,8 @@
#include <time.h>
#include <errno.h>

extern instant_t MIN_SLEEP_DURATION;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest renaming lf_min_sleep_duration. Our convention uses upper case for #define constantsand the prefixlf_` for all variables whose scope extends beyond one file.

@@ -6,6 +6,8 @@
#include "logging.h"
#include "platform/lf_unix_clock_support.h"

instant_t MIN_SLEEP_DURATION;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment.

@@ -23,6 +25,7 @@ void _lf_initialize_clock() {
}

lf_print("---- System clock resolution: %ld nsec", res.tv_nsec);
MIN_SLEEP_DURATION = NSEC(res.tv_nsec);
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation does not match the description of the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix enhancement Enhancement of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants