Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
Go to file
Nicolas Pitre 099850e916 ring_buffer: the great simplification
This code is rather hairy. When I look at it I don't like the way it
stares back at me.

First, the rewind business looks fishy. It has to die.

And we don't have to rely on modulus either. Not even for non-power-of-2
buffers. Let's kill that distinction too and make all sizes always
"high performance".

The code is now entirely relying only on simple ALU operations (add,
sub and compare).

The key assumption: 32-bit values do wrap around after max range has
been reached. No saturation. All architectures supported by Zephyr
do that.

Some stats:

lib/os/ring_buffer.c: 62 insertions(+), 124 deletions(-)

ring_buffer.c.obj       before   after    diff
----------------------------------------------
frdm_k64f                 1224    1136     -88
m2gl025_miv               2485    2079    -406
mps2_an385                1228    1132     -96
mps2_an521                1228    1132     -96
native_posix              1546    1496     -50
native_posix_64           1598    1595      -3
nsim_hs_mpuv6             1252    1192     -60
nsim_hs_smp               1252    1192     -60
nsim_sem                  1252    1192     -60
qemu_arc_em               1324    1192    -132
qemu_arc_hs6x             1824    1620    -204
qemu_arc_hs               1252    1192     -60
qemu_cortex_a53_smp       2154    1888    -266
qemu_cortex_a53           2154    1888    -266
qemu_cortex_a9            1938    1792    -146

Before (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 52
4 byte put-get, avg cycles: 47
1 byte put claim-finish, avg cycles: 39
5 byte put claim-finish, avg cycles: 41
5 byte get claim-finish, avg cycles: 52
 PASS - test_ringbuffer_performance in 0.8 seconds

After (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 34
4 byte put-get, avg cycles: 41
1 byte put claim-finish, avg cycles: 27
5 byte put claim-finish, avg cycles: 29
5 byte get claim-finish, avg cycles: 29
 PASS - test_ringbuffer_performance in 0.4 seconds

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
.github ci: make git credentials non-persistent 2022-02-24 09:00:07 -08:00
arch arch: arm: aarch32: Change CPU_CORTEX_R kconfig option 2022-02-23 08:14:15 -06:00
boards drivers: can: unify CAN controller configuration in devicetree 2022-02-24 13:48:55 -08:00
cmake cmake: package_helper CMake script 2022-02-23 11:34:22 -08:00
doc ring_buffer: the great simplification 2022-02-24 14:49:00 -08:00
drivers ring_buffer: rationalize the item-based put and get methods 2022-02-24 14:49:00 -08:00
dts drivers: can: unify CAN controller configuration in devicetree 2022-02-24 13:48:55 -08:00
include ring_buffer: the great simplification 2022-02-24 14:49:00 -08:00
kernel kernel: mmu: add a log line for z_phys_unmap 2022-02-24 08:38:38 -06:00
lib ring_buffer: the great simplification 2022-02-24 14:49:00 -08:00
misc cmake: only write devicetree files when there are changes. 2022-02-11 15:47:09 +01:00
modules modules: hal_nordic: Remove nrf_802154_lp_timer platform 2022-02-24 14:05:09 -08:00
samples include: sensor: sensor_value from double overflow 2022-02-24 13:45:29 -08:00
scripts scripts: add board revision help text for west build 2022-02-24 13:44:01 -08:00
share cmake: support sub-component loading in zephyr_default module 2022-02-23 11:34:22 -08:00
soc pm: Rename pm_power_state_exit_post_ops 2022-02-23 07:33:46 -05:00
submanifests west.yml: allow users to easily add more modules 2021-10-07 13:45:42 +02:00
subsys shell: fix history memory reclaim 2022-02-24 14:49:00 -08:00
tests ring_buffer: the great simplification 2022-02-24 14:49:00 -08:00
.checkpatch.conf checkpatch: Ignore IS_ENABLED_CONFIG warnings 2021-10-18 08:28:01 -04:00
.clang-format
.codecov.yml
.editorconfig
.gitattributes gitattributes: consider SVG files generated 2021-10-14 12:42:44 -04:00
.gitignore gitignore: ignore macos DS_Store files 2021-11-03 16:14:20 -04:00
.gitlint gitlint: Stop ignoring merge, revert, fixup and squash commits 2022-01-10 08:13:36 -05:00
.mailmap
.uncrustify.cfg uncrustify: force a single EOF newline 2021-11-03 16:14:20 -04:00
CMakeLists.txt cmake: emu: allow emulation to be OOT 2022-02-21 22:10:42 -05:00
CODEOWNERS CODEOWNERS: Removed vanwinkeljan 2022-02-21 22:14:15 -05:00
CODE_OF_CONDUCT.md
CONTRIBUTING.rst
Kconfig
Kconfig.zephyr soc: rp2040: Added UF2 output file support 2022-02-02 16:23:35 +01:00
LICENSE
MAINTAINERS.yml lvgl: move the lvgl glue out of the zephyr tree 2022-02-24 11:51:33 +01:00
README.rst readme: make README logo dark-mode aware 2022-02-15 19:47:48 +01:00
VERSION VERSION: bump patchlevel to 99 2022-02-21 19:05:46 -05:00
version.h.in cmake: version.h generation performed at build time 2022-02-08 07:50:24 -05:00
west.yml manifest: update hal_nordic revision 2022-02-24 13:50:42 -08:00
zephyr-env.cmd
zephyr-env.sh

README.rst

.. raw:: html

   <a href="https://www.zephyrproject.org">
     <p align="center">
       <img src="doc/_static/images/logo-readme.svg">
     </p>
   </a>

   <a href="https://bestpractices.coreinfrastructure.org/projects/74"><img
   src="https://bestpractices.coreinfrastructure.org/projects/74/badge"></a>
   <a
   href="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml?query=branch%3Amain">
   <img
   src="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml/badge.svg?event=push"></a>


The Zephyr Project is a scalable real-time operating system (RTOS) supporting
multiple hardware architectures, optimized for resource constrained devices,
and built with security in mind.

The Zephyr OS is based on a small-footprint kernel designed for use on
resource-constrained systems: from simple embedded environmental sensors and
LED wearables to sophisticated smart watches and IoT wireless gateways.

The Zephyr kernel supports multiple architectures, including ARM Cortex-M,
Intel x86, ARC, Nios II, Tensilica Xtensa, and RISC-V, and a large number of
`supported boards`_.

.. below included in doc/introduction/introduction.rst


Getting Started
***************

Welcome to Zephyr! See the `Introduction to Zephyr`_ for a high-level overview,
and the documentation's `Getting Started Guide`_ to start developing.

.. start_include_here

Community Support
*****************

Community support is provided via mailing lists and Discord; see the Resources
below for details.

.. _project-resources:

Resources
*********

Here's a quick summary of resources to help you find your way around:

* **Help**: `Asking for Help Tips`_
* **Documentation**: http://docs.zephyrproject.org (`Getting Started Guide`_)
* **Source Code**: https://github.com/zephyrproject-rtos/zephyr is the main
  repository; https://elixir.bootlin.com/zephyr/latest/source contains a
  searchable index
* **Releases**: https://github.com/zephyrproject-rtos/zephyr/releases
* **Samples and example code**: see `Sample and Demo Code Examples`_
* **Mailing Lists**: users@lists.zephyrproject.org and
  devel@lists.zephyrproject.org are the main user and developer mailing lists,
  respectively. You can join the developer's list and search its archives at
  `Zephyr Development mailing list`_. The other `Zephyr mailing list
  subgroups`_ have their own archives and sign-up pages.
* **Nightly CI Build Status**: https://lists.zephyrproject.org/g/builds
  The builds@lists.zephyrproject.org mailing list archives the CI nightly build results.
* **Chat**: Real-time chat happens in Zephyr's Discord Server. Use
  this `Discord Invite`_ to register.
* **Contributing**: see the `Contribution Guide`_
* **Wiki**: `Zephyr GitHub wiki`_
* **Issues**: https://github.com/zephyrproject-rtos/zephyr/issues
* **Security Issues**: Email vulnerabilities@zephyrproject.org to report
  security issues; also see our `Security`_ documentation. Security issues are
  tracked separately at https://zephyrprojectsec.atlassian.net.
* **Zephyr Project Website**: https://zephyrproject.org

.. _Discord Invite: https://chat.zephyrproject.org
.. _supported boards: http://docs.zephyrproject.org/latest/boards/index.html
.. _Zephyr Documentation: http://docs.zephyrproject.org
.. _Introduction to Zephyr: http://docs.zephyrproject.org/latest/introduction/index.html
.. _Getting Started Guide: http://docs.zephyrproject.org/latest/getting_started/index.html
.. _Contribution Guide: http://docs.zephyrproject.org/latest/contribute/index.html
.. _Zephyr GitHub wiki: https://github.com/zephyrproject-rtos/zephyr/wiki
.. _Zephyr Development mailing list: https://lists.zephyrproject.org/g/devel
.. _Zephyr mailing list subgroups: https://lists.zephyrproject.org/g/main/subgroups
.. _Sample and Demo Code Examples: http://docs.zephyrproject.org/latest/samples/index.html
.. _Security: http://docs.zephyrproject.org/latest/security/index.html
.. _Asking for Help Tips: https://docs.zephyrproject.org/latest/getting_started/index.html#asking-for-help