Skip to content
0:00 / 0:00

#activeobjectpattern#rtos#event-drivenprogramming

#34 Event-Driven Programming Part-2: Best practices for concurrency & Active Object pattern

Quantum Leaps, LLC

74K subscribers • 20 videos on Hallway

YouTube

Intermediate. Assumes working knowledge.

33K views6 years ago1 recommendation

Systems programmingSoftware designConcurrency and parallelismDesign patternsEmbedded systems

Miro Samek explains the Active Object design pattern and best practices for concurrent event-driven programming in real-time embedded systems.

This lesson continues the subject of event-driven programming, but this time as it applies to real-time embedded systems. Specifically, today you will learn the best practices of concurrent programming which form the "Active Object" design pattern. Later you will implement your own Active Object framework Micro-C/AO on top of the Micro-C/OS-II RTOS. ------ Resources: Companion web page for this video course: state-machine.com/quickstart GitHub repository for projects for this video course: github.com/QuantumLeaps/modern-embedded-programming-course Transcript of this lesson: state-machine.com/course/lesson34.txt Recommended Reading: - Herb Sutter "Prefer Using Active Objects Instead of Naked Threads" state-machine.com/doc/Sutter2010a.pdf - David Cummings "Managing Concurrency in Complex Embedded Systems" state-machine.com/doc/Cummings2006.pdf - David Kalinsky "Messages for Intertask Communication” state-machine.com/doc/Kalinsky2010.pdf Music credits: The background music comes from: bensound.com/royalty-free-music/track/straight

Why it's here

1 person recommends this

What people say. Engineers recommend this video for learning how to structure embedded software using the Active Object pattern instead of raw RTOS threads.

u/active-objectin r/embedded • Recommends

On “FreeRTOS is it a good practice to split a task into 2 or more smaller tasks?”

Your problem is very common and there are standard patterns to elegantly and safely structure your software. So, instead of re-inventing the wheel, you might want to apply the "Active Object" design pattern (a.k.a. Actor), which promotes event-driven programming with FSMs (finite state machines). You might want to check out the free YouTube video "Best practices for concurrency & Active Object pattern". The YouTube channel hosting this video has also many other videos about FSMs, RTOS, and event-driven programming.

u/active-objectin r/embedded • Recommends

On “path of learning the arm cortex-m embedded c programming?”

The video course offers some ideas for interesting projects and code challenges. For example, in the segment about the RTOS, you witness building a "Minimal Real-time Operating System "MiROS". The MiROS code is available on GitHub, and you can keep adding to it other features. Building a functional RTOS is a great way to learn about RTOSes. Another interesting project is uC/AO (Micro-C Active Object), introduced in lesson-34. This is the implementation of the "Active Object" design pattern on top of the popular uC/OS-II (MicroC/OS-II), which is now open source. This project is expanded in the subsequent lessons. For example, state machines are added to the "Active Objects" in lesson-36…

u/active-objectin r/embedded • Recommends

On “Beginner's guide for professional firmware development?”

This architecture sounds like the "Active Object" (a.k.a. "Actor") design pattern, which is an excellent starting point for the "professional firmware development" requested in the OP. The system described by mtconnol consists of just one AO, but the approach can be generalized to multiple AOs (e.g., where each AO runs in a separate task of an RTOS.) The main point is that interrupts or other parts of the system (like device drivers or other AOs) post events to that AO **asynchronously** (without waiting for the actual processing of the event). Internally, each AO implements an event loop, with the following structure: `while (1) { // event loop of an Active Object "me"` `Event *e =…

u/active-objectin r/embedded • Recommends

On “Responsive tasks in FreeRTOS and event loops”

This is a good approach and is known as the "Active Object" design pattern. Since you are apparently working with FreeRTOS, you might check out the GitHub repo "FreeACT" a minimal real-time embedded framework (RTEF) based on the FreeRTOS kernel.