Skip to content

Add feature for unix systems that toggles sleep function used - #1185

Open
mayushiiii wants to merge 1 commit into
eclipse-zenoh:mainfrom
mayushiiii:add_sleep_toggle
Open

Add feature for unix systems that toggles sleep function used#1185
mayushiiii wants to merge 1 commit into
eclipse-zenoh:mainfrom
mayushiiii:add_sleep_toggle

Conversation

@mayushiiii

@mayushiiii mayushiiii commented Mar 13, 2026

Copy link
Copy Markdown

Description

Added a flag for changing the sleep function that is used on unix-based systems in order to increase efficiency.

What does this PR do?

As of right now, the z_sleep_ms function leads to an increased CPU usage, as it has multiple syscalls. The addition of the flag determines which sleep function is used depending on the user's needs. This will allow to decrease the CPU usage for systems where oversleep is not that big of a problem and is more acceptable than a high CPU usage.

Note: I'm sorry since I haven't done this before, but I'm not sure how to add a label to the PR. Seems to be a permission problem.


🏷️ Label-Based Checklist

Based on the labels applied to this PR, please complete these additional requirements:

Labels: enhancement, good first issue

✨ Enhancement Requirements

Since this PR enhances existing functionality:

  • Enhancement scope documented - Clear description of what is being improved
  • Minimum necessary code - Implementation is as simple as possible, doesn't overcomplicate the system
  • Backwards compatible - Existing code/APIs still work unchanged
  • No new APIs added - Only improving existing functionality
  • Tests updated - Existing tests pass, new test cases added if needed
  • Performance improvement measured - If applicable, before/after metrics provided
  • Documentation updated - Existing docs updated to reflect improvements
  • User impact documented - How users benefit from this enhancement

Remember: Enhancements should not introduce new APIs or breaking changes.

Instructions:

  1. Check off items as you complete them (change - [ ] to - [x])
  2. The PR checklist CI will verify these are completed

This checklist updates automatically when labels change, but preserves your checked boxes.

@mayushiiii
mayushiiii marked this pull request as draft March 13, 2026 14:42
@mayushiiii
mayushiiii marked this pull request as ready for review March 13, 2026 14:53
@mayushiiii
mayushiiii force-pushed the add_sleep_toggle branch 3 times, most recently from 62da8be to bc3a229 Compare March 16, 2026 14:56
@sashacmc
sashacmc requested a review from steils March 17, 2026 11:02
@sashacmc sashacmc added enhancement Existing things could work better good first issue Good for newcomers labels Mar 17, 2026
Comment thread src/system/unix/system.c

z_result_t z_sleep_ms(size_t time) {
#if Z_FEATURE_EFFICIENT_SLEEP
z_result_t ret = z_sleep_us(time * 1000);

Check warning

Code scanning / Cppcheck (reported by Codacy)

time is Y2038-unsafe

time is Y2038-unsafe
This change adds a flag that changes the z_sleep_ms function that is used on Unix-based systems so as to decrease overhead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing things could work better good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants