Skip to content

Commit

Permalink
Merge pull request #478 from EhsanKhodadad/main
Browse files Browse the repository at this point in the history
lf_sleep and lf_nanosleep added to lf_patmos_support
  • Loading branch information
schoeberl authored Sep 30, 2024
2 parents 9ef620b + b9ee3ac commit 815696c
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit 815696c

Please sign in to comment.