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

Bugfix: Dedicated event signalling for each thread #46

Merged
merged 2 commits into from Nov 5, 2021
Merged

Conversation

aentinger
Copy link
Contributor

Objective

Previous implementation required call to rtos::ThisThread::yield() in every thread in order to prevent what I thought was a result of resource starvation (only messages from one thread were printed). However, it was the result of using a single condition variable instead of one condition variable per thread. Now there's one dedicated signalling flag per thread by using EventFlags.

Output of Threadsafe_Serial_Writer

Note: All threads are executed in chronological order, this is preemptive round-robin-scheduling seen in action.

[1339741] Thread #1: Lorem ipsum ...
[1339743] Thread #2: Lorem ipsum ...
[1339744] Thread #3: Lorem ipsum ...
[1339746] Thread #0: Lorem ipsum ...
[1339748] Thread #1: Lorem ipsum ...
[1339750] Thread #2: Lorem ipsum ...
[1339751] Thread #3: Lorem ipsum ...
[1339753] Thread #0: Lorem ipsum ...
[1339755] Thread #1: Lorem ipsum ...
[1339757] Thread #2: Lorem ipsum ...
[1339758] Thread #3: Lorem ipsum ...
[1339760] Thread #0: Lorem ipsum ...
[1339762] Thread #1: Lorem ipsum ...

@aentinger aentinger self-assigned this Nov 5, 2021
@github-actions
Copy link

github-actions bot commented Nov 5, 2021

Memory usage change @ 29c42ee

Board flash % RAM for global variables %
arduino:mbed_nano:nano33ble 🔺 +4928 - +5440 +0.5 - +0.55 🔺 +8 - +16 0.0 - +0.01
arduino:mbed_nano:nanorp2040connect 0 - 0 0.0 - 0.0 🔺 +12 - +12 0.0 - 0.0
arduino:mbed_portenta:envie_m4 🔺 +3256 - +3832 +0.31 - +0.37 🔺 +8 - +16 0.0 - +0.01
arduino:mbed_portenta:envie_m7 🔺 +3320 - +3832 +0.42 - +0.49 🔺 +8 - +16 0.0 - 0.0
Click for full report table
Board examples/Threading/Demo_Shared_Counter
flash
% examples/Threading/Demo_Shared_Counter
RAM for global variables
% examples/Threading/Demo_Source_Sink_Counter
flash
% examples/Threading/Demo_Source_Sink_Counter
RAM for global variables
% examples/Threading/Demo_Source_Sink_LED
flash
% examples/Threading/Demo_Source_Sink_LED
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_SPI
flash
% examples/Threadsafe_IO/Threadsafe_SPI
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_SPI_BusIO
flash
% examples/Threadsafe_IO/Threadsafe_SPI_BusIO
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_Serial_GlobalPrefixSuffix
flash
% examples/Threadsafe_IO/Threadsafe_Serial_GlobalPrefixSuffix
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_Serial_ProtocolWrapping
flash
% examples/Threadsafe_IO/Threadsafe_Serial_ProtocolWrapping
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_Serial_Reader
flash
% examples/Threadsafe_IO/Threadsafe_Serial_Reader
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_Serial_Writer
flash
% examples/Threadsafe_IO/Threadsafe_Serial_Writer
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_Wire
flash
% examples/Threadsafe_IO/Threadsafe_Wire
RAM for global variables
% examples/Threadsafe_IO/Threadsafe_Wire_BusIO
flash
% examples/Threadsafe_IO/Threadsafe_Wire_BusIO
RAM for global variables
%
arduino:mbed_nano:nano33ble 4928 0.5 8 0.0 5440 0.55 8 0.0 5376 0.55 16 0.01 5440 0.55 16 0.01 5440 0.55 16 0.01 5056 0.51 16 0.01 5272 0.54 16 0.01 5048 0.51 16 0.01 5048 0.51 16 0.01 5376 0.55 16 0.01 5376 0.55 16 0.01
arduino:mbed_nano:nanorp2040connect 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0 0 0.0 12 0.0
arduino:mbed_portenta:envie_m4 3256 0.31 16 0.01 3768 0.36 16 0.01 3768 0.36 8 0.0 3768 0.36 8 0.0 3768 0.36 8 0.0 3376 0.32 8 0.0 3528 0.34 8 0.0 3384 0.32 8 0.0 3384 0.32 8 0.0 3768 0.36 8 0.0 3832 0.37 8 0.0
arduino:mbed_portenta:envie_m7 3320 0.42 8 0.0 3832 0.49 8 0.0 3768 0.48 16 0.0 3768 0.48 16 0.0 3768 0.48 16 0.0 3440 0.44 16 0.0 3592 0.46 16 0.0 3448 0.44 16 0.0 3448 0.44 16 0.0 3832 0.49 16 0.0 3768 0.48 16 0.0
Click for full report CSV
Board,examples/Threading/Demo_Shared_Counter<br>flash,%,examples/Threading/Demo_Shared_Counter<br>RAM for global variables,%,examples/Threading/Demo_Source_Sink_Counter<br>flash,%,examples/Threading/Demo_Source_Sink_Counter<br>RAM for global variables,%,examples/Threading/Demo_Source_Sink_LED<br>flash,%,examples/Threading/Demo_Source_Sink_LED<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_SPI<br>flash,%,examples/Threadsafe_IO/Threadsafe_SPI<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_SPI_BusIO<br>flash,%,examples/Threadsafe_IO/Threadsafe_SPI_BusIO<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_Serial_GlobalPrefixSuffix<br>flash,%,examples/Threadsafe_IO/Threadsafe_Serial_GlobalPrefixSuffix<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_Serial_ProtocolWrapping<br>flash,%,examples/Threadsafe_IO/Threadsafe_Serial_ProtocolWrapping<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_Serial_Reader<br>flash,%,examples/Threadsafe_IO/Threadsafe_Serial_Reader<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_Serial_Writer<br>flash,%,examples/Threadsafe_IO/Threadsafe_Serial_Writer<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_Wire<br>flash,%,examples/Threadsafe_IO/Threadsafe_Wire<br>RAM for global variables,%,examples/Threadsafe_IO/Threadsafe_Wire_BusIO<br>flash,%,examples/Threadsafe_IO/Threadsafe_Wire_BusIO<br>RAM for global variables,%
arduino:mbed_nano:nano33ble,4928,0.5,8,0.0,5440,0.55,8,0.0,5376,0.55,16,0.01,5440,0.55,16,0.01,5440,0.55,16,0.01,5056,0.51,16,0.01,5272,0.54,16,0.01,5048,0.51,16,0.01,5048,0.51,16,0.01,5376,0.55,16,0.01,5376,0.55,16,0.01
arduino:mbed_nano:nanorp2040connect,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0,0,0.0,12,0.0
arduino:mbed_portenta:envie_m4,3256,0.31,16,0.01,3768,0.36,16,0.01,3768,0.36,8,0.0,3768,0.36,8,0.0,3768,0.36,8,0.0,3376,0.32,8,0.0,3528,0.34,8,0.0,3384,0.32,8,0.0,3384,0.32,8,0.0,3768,0.36,8,0.0,3832,0.37,8,0.0
arduino:mbed_portenta:envie_m7,3320,0.42,8,0.0,3832,0.49,8,0.0,3768,0.48,16,0.0,3768,0.48,16,0.0,3768,0.48,16,0.0,3440,0.44,16,0.0,3592,0.46,16,0.0,3448,0.44,16,0.0,3448,0.44,16,0.0,3832,0.49,16,0.0,3768,0.48,16,0.0

@aentinger aentinger marked this pull request as ready for review November 5, 2021 08:59
@aentinger aentinger merged commit 4652522 into main Nov 5, 2021
@aentinger aentinger deleted the fix-serial-bug branch November 5, 2021 09:00
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

Successfully merging this pull request may close these issues.

None yet

1 participant