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

doc: kernel: document general policy for Zephyr without threads #29338

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/reference/kernel/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ synchronization.
scheduling/index.rst
threads/system_threads.rst
threads/workqueue.rst
threads/nothread.rst
other/interrupts.rst
other/polling.rst
synchronization/semaphores.rst
Expand Down
3 changes: 3 additions & 0 deletions doc/reference/kernel/threads/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Threads
#######

.. note::
There is also limited support for using :ref:`nothread`.

.. contents::
:local:
:depth: 2
Expand Down
103 changes: 103 additions & 0 deletions doc/reference/kernel/threads/nothread.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.. _nothread:

Zephyr Without Threads
######################

Thread support is not necessary in some applications:

* Bootloaders
* Simple event-driven applications
* Examples intended to demonstrate core functionality

Thread support can be disabled in Zephyr by setting
:option:`CONFIG_MULTITHREADING` to ``n``. Since this configuration has
a significant impact on Zephyr's functionality and testing of it has
been limited, there are conditions on what can be expected to work in
this configuration.

What Can be Expected to Work
****************************

These core capabilities shall function correctly when
:option:`CONFIG_MULTITHREADING` is disabled:

* The :ref:`build system <application>`

* The ability to boot the application to ``main()``

* :ref:`Interrupt management <interrupts_v2>`

* The system clock including :c:func:`k_uptime_get`
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be worthwhile mentioning SYS_CLOCK_EXISTS here, because when no MT is often combined with no system clock

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll have to look at that. Looks like SYS_CLOCK_EXISTS=n means nothing related to ticks is supported, including k_uptime_get(). So the only way to detect passage of time is k_cycle_get_32().

I guess this one goes too. The value of this feature to me is diminishing rapidly....


* Timers, i.e. :c:func:`k_timer`

* Non-sleeping delays e.g. :c:func:`k_busy_wait`.

* Specifically identified drivers in certain subsystems, listed below.

The expectations above affect selection of other features; for example
:option:`CONFIG_SYS_CLOCK_EXISTS` cannot be set to ``n``.

What Cannot be Expected to Work
*******************************

Functionality that will not work with :option:`CONFIG_MULTITHREADING`
includes but is not limited to:

* :c:func:`k_sleep()` and any other API that causes a thread to
Copy link
Member

Choose a reason for hiding this comment

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

We should consider being explicit here, just like we are explicit above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Better would be to make progress on #18970 so we can just say "Any api that sleeps except if using the no-wait path".

Copy link
Member

Choose a reason for hiding this comment

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

Since we don't have that as of now, I'd rather you mention that explicitly as @nashif mentions so we can move this forward while we wait for progress in #18970.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure if the direction given was to list all API that meets the "sleeps" criteria (which I can't do until #18970 progresses to the point where we've identified that API), or to just refine the text to match what I said. So I did the latter.

:ref:`api_term_sleep` except if using the :ref:`api_term_no-wait`
path.

.. contents::
:local:
:depth: 1

Subsystem Behavior Without Thread Support
*****************************************

The sections below list driver and functional subsystems that are
expected to work to some degree when :option:`CONFIG_MULTITHREADING` is
disabled. Subsystems that are not listed here should not be expected to
work.

Some existing drivers within the listed subsystems do not work when
threading is disabled, but are within scope based on their subsystem, or
may be sufficiently isolated that supporting them on a particular
platform is low-impact. Enhancements to add support to existing
capabilities that were not originally implemented to work with threads
disabled will be considered.

Flash
=====

The :ref:`flash_api` is expected to work for all SoC flash peripheral
drivers. Bus-accessed devices like serial memories may not be
supported.

*List/table of supported drivers to go here*

GPIO
====

The :ref:`gpio_api` is expected to work for all SoC GPIO peripheral
drivers. Bus-accessed devices like GPIO extenders may not be supported.

*List/table of supported drivers to go here*

UART
====

A subset of the :ref:`uart_api` is expected to work for all SoC UART
peripheral drivers.

* Applications that select :option:`CONFIG_UART_INTERRUPT_DRIVEN` may
work, depending on driver implementation.

* Applications that select :option:`CONFIG_UART_ASYNC_API` may
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about this one. I always thought this actually required at least k_timer:
https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/serial/uart_nrfx_uarte.c#L830

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's unfortunate. I wouldn't expect other SoC's to have that problem. I suppose we don't support that API, then.

work, depending on driver implementation.

* Applications that do not select either :option:`CONFIG_UART_ASYNC_API`
or :option:`CONFIG_UART_INTERRUPT_DRIVEN` are expected to work.

*List/table of supported drivers to go here, including which API options
are supported*