No video

Introduction to RTOS Part 4 - Memory Management | Digi-Key Electronics

  Рет қаралды 147,992

DigiKey

DigiKey

Күн бұрын

Пікірлер: 73
@Henrix1998
@Henrix1998 Жыл бұрын
This channel is basically covering one of my courses thats painfully unclear, absolutely awesome
@Apocobat
@Apocobat Жыл бұрын
real time embedded systems at my school, although lecture wise is ok, does not cover hardware implementation at all. Im really disappointed considering that my school is supposed to be one of the more advanced in terms of software/hardware education. It doesnt help that they pulled the lab ta off the street and he knows virtually nothing about rtos and wants to teach us about linux and computer os instead which is completely disconnected from the course content.
@AlphaCrucis
@AlphaCrucis Жыл бұрын
"Good luck. We're all counting on you." I love this guy. He's good at explaining, makes it interesting, makes good use of visual aids and demos, and has a sense of humor. Thank you Shawn!
@adityasreeram.k.s9527
@adityasreeram.k.s9527 7 ай бұрын
For those who are referring his solution form website, do note that instead of "idx ;" correct it as "idx++;" .If index in not incremented there can be chance for assert failed error. Hope this helps someone.
@claytube1958
@claytube1958 7 ай бұрын
I found that too..
@Dygear
@Dygear 3 жыл бұрын
Nice Mission Impossible reference! Your voice does remind me of the guy on the tape, now that you said it.
@ShawnHymel
@ShawnHymel 3 жыл бұрын
I was hoping someone would catch that :)
@Astronomer6573
@Astronomer6573 3 жыл бұрын
Really good explanation and visual demonstration on how memory allocation should be done. Your voice can really stay in my head, looking forward to all of your videos!
@turkey343434
@turkey343434 3 жыл бұрын
Excellent content. Thank you Shawn, keep them coming!
@achalasamapriya2701
@achalasamapriya2701 3 жыл бұрын
was waiting for this.. thanks
@minefacex
@minefacex 2 жыл бұрын
This guy is seriously amazing! Thanks for the vid!
@Hasan...
@Hasan... 3 жыл бұрын
Shawn, are you planning to upload a quick tutorial that uses both cores of ESP32 soon?
@ShawnHymel
@ShawnHymel 3 жыл бұрын
I wasn't planning on it, as these videos are focused on RTOS concepts and FreeRTOS (the ESP32 just happened to be a really easy way to start using FreeRTOS). However, I'm glad to know there's interest in talking about multi-core operations and the ESP32, so I'll keep that in mind. For now, I recommend starting by looking the differences between ESP-IDF and FreeRTOS to get a sense of how the ESP32 uses its 2 cores when running tasks: docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/freertos-smp.html
@josephlai7737
@josephlai7737 3 жыл бұрын
How do you get 768 bytes overhead at 6:22? Shouldn't it be 623 (1024 - 401)?
@ShawnHymel
@ShawnHymel 3 жыл бұрын
Each task in ESP-IDF requires 768 bytes of task stack for bare minimum operation. If you allocate 1024 bytes for stack, that gives you 1024 - 768 = 256 bytes left in stack for that task. Since we try to declare an int array with 100 elements, that will try to use 400 bytes of stack (100 * sizeof(int) = 400 bytes), which is more than we have left. Hope that helps!
@josephlai7737
@josephlai7737 3 жыл бұрын
​@@ShawnHymel Thanks! Now I see that 768 bytes comes from documentation/configuration.
@coderhex1675
@coderhex1675 3 жыл бұрын
@@ShawnHymel you should have explain like that in the video. Because i have had the same question. Now , i got this but i have wasted my brain tying to figure out. Anyway.. Thank you
@jinmingtang1545
@jinmingtang1545 2 жыл бұрын
Thank you for pointing it out and bridging the gap!
@diyworkshopvn6231
@diyworkshopvn6231 Жыл бұрын
I have the same question, thank for your pointing it out. :)
@boontecklee592
@boontecklee592 3 жыл бұрын
At around 0:34, you mentioned that: "This section is labelled as static memory and connot be used for other parts of the program". This explanation is misleading as it gave the impression that static memory cannot be 'used' for other parts of the program. Static memory can certainly be used in any part of program as long as the variable visibility rules are adhered to. Instead, your explanation could have been better stated as: "This section is labelled as static memory which is only allocated during compile time".
@ShawnHymel
@ShawnHymel 3 жыл бұрын
Good point, thank you!
@Microcontrollerslab
@Microcontrollerslab 3 жыл бұрын
What he is trying to say is that the static variables have an internal linkage that means static variables can only be accessed within the same program file where they are defined. You can not access static variables in any other file if your program has multiple files. similarly, if we use static with the function definition, it can not be accessed from any other file.
@boontecklee592
@boontecklee592 3 жыл бұрын
@@Microcontrollerslabit would have been clearer and much more accurate to simply state that static variables follow the same visibility rules as other variables.
@zee-lab-electronics
@zee-lab-electronics 3 жыл бұрын
Awesome work Shawn
@shubhamsen4572
@shubhamsen4572 3 жыл бұрын
This guy is excellent
@neilbalch
@neilbalch 3 жыл бұрын
Interesting note... I wasn't able to get my ESP32-S2-Mini-1 to crash when allocating the 400-byte array when I configured the task to use 1024 bytes of stack memory. I had to lower it to something like 500 bytes to replicate the hard reset. I supposed this means that the overhead is lower for my version of the ESP-IDF core? :)
@SohamChakraborty42069
@SohamChakraborty42069 Жыл бұрын
Yes, probably this is what is happening. I suppose the overhead needed would depend on the device
@philflupp8199
@philflupp8199 Жыл бұрын
Calculating the size of the actually allocated memory gives me 4112 bytes instead of 4 * 1024 = 4096 bytes, why is that?
@vex123
@vex123 Жыл бұрын
I was wondering the exact same thing. I also did the exercise and even just allocating one byte, it decreases the heap size by like 20 bytes. Is there some type of overhead in the heap when dynamic allocation is used?
@baobuiquoc4763
@baobuiquoc4763 3 жыл бұрын
Dear Mr Shawn, thanks for your video. On your solution code, you use a global variable msg_flag. Will it create a race condition between the printMessage task and the interrupt handler? i.e. before the task clear the flag, interrupt occur and set the flag, then return to the task and the task clear the flag. The message will be missed, and the msg_ptr is not freed
@perlmansoong944
@perlmansoong944 2 жыл бұрын
Great video, Shawn! And I've a question. From 2:46, what is the usage of the light-orange-colored Stack (at the top of the RAM pattern)? Seems that this part is unused in FreeRTOS system, doesn't it? Thank you :-)
@MuhammadDaudkhanTV100
@MuhammadDaudkhanTV100 3 жыл бұрын
Really good ideas
@philflupp8199
@philflupp8199 Жыл бұрын
I have completed the challenge. However I could not get my application to run properly without using vTaskDelay(0) in both tasks. Otherwise, only the task which was created first, is executed, and the other one never. The tasks are of the same priority and are pinned to one core. It seems to me that you actually have to explicitly yield task execution (by calling vTaskDelay() ) in order to give other tasks a chance to run. Which contradicts, what was said about the scheduler executing tasks of same priority in round robin fashion ?!
@user-kp7im1sg8k
@user-kp7im1sg8k 11 ай бұрын
I have the same problem...
@mudkiptheengineer5339
@mudkiptheengineer5339 10 ай бұрын
check if you have configUSE_PREEMPTION 1, this will make the scheduler round Robin through all the tasks of the same priority that are in the ready state
@lucvanhove9639
@lucvanhove9639 3 жыл бұрын
Thanks Shawn, you just explain my problem and show the way to a sullution. 👍🧐
@jahidulislamrahat9877
@jahidulislamrahat9877 3 жыл бұрын
Sorry actually, I did not understand stack size calculation. can you please describe to me how can I calculate it? in my case memory size is 408 bytes.
@ShawnHymel
@ShawnHymel 3 жыл бұрын
To get stack, you need to add up the size of all of the automatically allocated variables for that task.
@3adelz90
@3adelz90 3 жыл бұрын
@@ShawnHymel How can I calculate thr stack size I need if I have a big Task with lots of functions ?
@fouzaialaa7962
@fouzaialaa7962 8 ай бұрын
malloc is called that becoz it references the human readable Memory Allocate so it becomes malloc i find it easier to memorize the functions name if i know the human readable equivalent .
@vikrantgsai7327
@vikrantgsai7327 5 ай бұрын
If the heap has some bytes remaining that is more than enough to allocate more arrays of 1024 integers in the above example at 9:17 why does it say that the heap has run out of heap?
@minefacex
@minefacex 2 жыл бұрын
Hey Shawn! I have realized that if I put vTaskDelay(100 / portTICK_PERIOD_MS); at the and of the task where you demonstrated the stack free space size problem, there is no Guru Meditation Error! Why is that?
@MingOnUTube
@MingOnUTube 2 жыл бұрын
Please can anyone help? Why is the stack canary watchpoint not triggered immediately and the task while loop is able to run several times before the trigger? Also, is it watching the "real" stack or the "task" stack in the heap?
@taccle1129
@taccle1129 Жыл бұрын
Could you find any answer to your question?
@yadavsomnath6188
@yadavsomnath6188 Жыл бұрын
Same question buddy..
@MingOnUTube
@MingOnUTube Жыл бұрын
@@taccle1129 Nope. I moved on. Better not be stuck. Can always revisit this issue.
@pandabar2869
@pandabar2869 Жыл бұрын
The stack overflow is not checked every time when something is written to the stack, but only when the tick is finished and the kernel takes over control. Then the kernel can check if the canary was overwritten.
@MingOnUTube
@MingOnUTube Жыл бұрын
@@pandabar2869 Thank you! I think it might take several ticks? Because the loop is able to run 10+ times(not sure, don't have the code at hand).
@eylulmood4830
@eylulmood4830 2 жыл бұрын
please, how did you calculate the overhead 768 at 06:21
@digikey
@digikey 2 жыл бұрын
Shawn Hymel 6 months ago Each task in ESP-IDF requires 768 bytes of task stack for bare minimum operation. If you allocate 1024 bytes for stack, that gives you 1024 - 768 = 256 bytes left in stack for that task. Since we try to declare an int array with 100 elements, that will try to use 400 bytes of stack (100 * sizeof(int) = 400 bytes), which is more than we have left. Hope that helps!
@eylulmood4830
@eylulmood4830 2 жыл бұрын
@@digikey thank you Mr it helps :)
@yadavsomnath6188
@yadavsomnath6188 Жыл бұрын
@@digikey then why it didn't overflowed in first iteration itself ? I mean we are not freeing up the space then according to calculation 400>>usable stack.. So it should not allow this many iteration..rather it should give error at first iteration itself..
@debarkamondal6406
@debarkamondal6406 2 жыл бұрын
Why are we counting till idx-1 and why is volatile qualifier necessary?
@maurod6180
@maurod6180 3 жыл бұрын
thank you very much!!!!!
@jasonleng2490
@jasonleng2490 3 жыл бұрын
So if I dynamically allocated a array inside a task, does it go onto the task's stack?
@KP_100
@KP_100 25 күн бұрын
How void loop() is called ? there is no api call.
@eslamsayed1947
@eslamsayed1947 3 жыл бұрын
How to change task scheduling time in freeRTOS?
@ShawnHymel
@ShawnHymel 3 жыл бұрын
Good question--It's set in the line "#define configTICK_RATE_HZ" in FreeRTOSConfig.h. This is set to "1000" by default in the ESP32 Arduino package.
@zulkaifahmed1893
@zulkaifahmed1893 2 жыл бұрын
you look like glassreflection guy who reviews anime
@mdmaroof2007
@mdmaroof2007 3 жыл бұрын
Maybe you need to slow down while explaining 😉
@alissonneres5067
@alissonneres5067 3 жыл бұрын
Good thing it is a video and I can watch again and again if I need (and I usually do)
@boontecklee592
@boontecklee592 3 жыл бұрын
I too feel the narrative is too fast. It tends to distract the listeners and affect understanding. I hope your narrative for future videos can be slower by say 10~15%. Nevertheless, your content is excellent!
@rbclima
@rbclima 2 жыл бұрын
@@boontecklee592 you can always watch at 0.75x!
@ashwin372
@ashwin372 Жыл бұрын
use 0.5x for that
@pnuema1.618
@pnuema1.618 Жыл бұрын
Slow the video down and open up his code for review before watching the video. That's how you really learn this stuff anyway
Introduction to RTOS Part 5 - Queue | Digi-Key Electronics
12:01
How He Got $600,000 Data Engineer Job
19:08
Sundas Khalid
Рет қаралды 24 М.
Lehanga 🤣 #comedy #funny
00:31
Micky Makeover
Рет қаралды 29 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 7 МЛН
JavaScript Tips on Element Class Name
0:47
Vanilla Web Dev
Рет қаралды 56
17 VLAN 5  VLAN Troubleshooting Lab, Part 2
1:36
Just_D_Firewall_Stuff #sagar_akim
Рет қаралды 3
Scammed selling my MacBook, almost
15:09
Alex Ziskind
Рет қаралды 43 М.
Foundations of AI: A multi-GPU softmax function in Chapel
4:17
Chapel Parallel Programming Language
Рет қаралды 20
Lehanga 🤣 #comedy #funny
00:31
Micky Makeover
Рет қаралды 29 МЛН