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

lf_sleep and lf_nanosleep added to lf_patmos_support #478

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions low_level_platform/impl/src/lf_patmos_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ int _lf_interruptable_sleep_until_locked(environment_t* env, instant_t wakeup) {
}
}

int lf_sleep(interval_t sleep_duration) {
instant_t now;
_lf_clock_gettime(&now);
instant_t wakeup = now + sleep_duration;

// Do busy sleep
do {
_lf_clock_gettime(&now);
} while ((now < wakeup));
return 0;
}

/**
* Pause execution for a number of nanoseconds.
*
* @return 0 for success, or -1 for failure. In case of failure, errno will be
* set appropriately (see `man 2 clock_nanosleep`).
*/
int lf_nanosleep(interval_t requested_time) { return lf_sleep(requested_time); }

/**
* Patmos clock does not need initialization.
*/
Expand Down
Loading