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

Why does default_idle_hook() lock deep sleep? #6199

Closed
amq opened this issue Feb 23, 2018 · 3 comments
Closed

Why does default_idle_hook() lock deep sleep? #6199

amq opened this issue Feb 23, 2018 · 3 comments

Comments

@amq
Copy link
Contributor

amq commented Feb 23, 2018

Description

Question

According to the documentation, sleep is managed automatically, including deep sleep. However from what I see, deep sleep is locked by default_idle_hook() for non-tickless targets

static void default_idle_hook(void)
{
// critical section to complete sleep with locked deepsleep
core_util_critical_section_enter();
sleep_manager_lock_deep_sleep();
sleep();
sleep_manager_unlock_deep_sleep();
core_util_critical_section_exit();
}

What is the reason for this? What is the expected way of entering deep sleep?

I know that it is possible to use a custom default_idle_hook(), but before I do, I would like to understand it more.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 26, 2018

This was intentionally added for backward compatibility. Previously only sleep was invoked, therefore deep sleep is locked to keep the same behavior. If you remove the deep sleep locking, some platform might potentially not wake up.

Does that answer your question?

@amq
Copy link
Contributor Author

amq commented Feb 26, 2018

How is deep sleep meant to be used? Is it just meant for tickless targets or is Thread::attach_idle_hook(&sleep); also a good approach?

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 26, 2018

Yes, you can attach your own handler and overwrite the default behavior. Or enable tickless for your platform (there is feature sleep branch to actually address this, it contains specifications and tests, target additions will follow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants