Ask Your Question
0

How can C++ 20 coroutines be used on AVR?

asked 2023-05-18 10:55:02 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-18 11:00:01 +0000

lalupa gravatar image

It is important to note that C++20 coroutines were designed primarily for use on desktop and server environments, and not optimized for embedded systems such as AVR. That being said, it is possible to use coroutines on AVR with some limitations and additional requirements.

  1. Compiler support: Coroutines require a compiler that supports C++20 features such as std::coroutine and co_await. Currently, none of the major compilers for AVR (avr-gcc, avr-clang) support these features, so a custom implementation or port may be necessary.

  2. Stack size: Coroutines require a larger stack than regular functions, as they maintain additional state information. AVR devices typically have limited RAM, so ensuring adequate stack space is important.

  3. Context switches: Coroutines rely heavily on context switching, which can be expensive in terms of execution time and memory usage on AVR. Additional optimizations may be required to reduce the cost of context switches.

  4. Use case: It is important to consider whether using coroutines on AVR is the best solution for a given use case. The added complexity and overhead of coroutines may not be necessary for simple applications.

In summary, using C++20 coroutines on AVR requires careful consideration and possible custom implementation. It may not be the most efficient or practical solution in many cases.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-18 10:55:02 +0000

Seen: 16 times

Last updated: May 18 '23