The Call Stack

  Рет қаралды 206,133

Computer Science Lessons

Computer Science Lessons

Күн бұрын

Пікірлер: 121
@bigboypal
@bigboypal 3 жыл бұрын
Why do computer scientists have to overcomplicate the stack so much? You are the first person that I've found to give a straightforward explanation of the order in which the stack frame is created. Thank you very much!
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
My motto - K.I.S.S. :)KD
@sorvex9
@sorvex9 2 жыл бұрын
Some of them don't really understand it themselves.
@beverlyukandu9337
@beverlyukandu9337 5 жыл бұрын
This clarified 10 years of confusion with the ordering of how parameters are pushed onto the stack. Thanks!
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
You're very welcome. :) KD
@NoobUCantBeat
@NoobUCantBeat 2 жыл бұрын
been studying this for a couple hours... this has been the most straight forward and simplest explanation that finally makes everything make sense! thanks!
@dickvanfreedman
@dickvanfreedman 4 жыл бұрын
FINALLY this makes sense. You did a better job explaining than most professors and text books.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you :)KD
@ostracean
@ostracean 3 жыл бұрын
The first video to actually explain the difference between callee and caller cleanup of parameters
@user-xo3fn1fj2g
@user-xo3fn1fj2g 2 жыл бұрын
Wow thanks for the clear explanation, I’ve been banging my head trying to understand this. Watching this video made everything click in place
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
You're welcome :)KD
@abdoullatifabdoumoussa1990
@abdoullatifabdoumoussa1990 4 жыл бұрын
Finally someone who makes this idea much clear for me. Thanks very much, thumb up
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you. Much appreciated :)KD
@JordanRohilliard
@JordanRohilliard 3 ай бұрын
understanding this is so key to understanding recursion. Always having this knowledge in the back of your mind makes it easier
@ComputerScienceLessons
@ComputerScienceLessons 3 ай бұрын
I agree. Understanding the recursive sorting algorithms depends on this :)KD
@tobi3497
@tobi3497 8 жыл бұрын
A truly great explanation; I'd watched a previous one filled with ambiguity, and lacking the actual detail you coherently portrayed - I'll be sure to explore your series.
@ComputerScienceLessons
@ComputerScienceLessons 8 жыл бұрын
Your comment is much appreciated.
@keeganfisher1900
@keeganfisher1900 7 жыл бұрын
this helped me get over some confusion with implementing recursion in assembly... I was forgetting that the arguments should be considered part of the called procedures stack frame!!! thank you!
@Wrtvrxgvcf55
@Wrtvrxgvcf55 7 жыл бұрын
mate you keep surprising me by the amount of content your channel offers. high quality content as well.
@NOPerative
@NOPerative 7 жыл бұрын
Sweet explanation. Call/stack frames can be extremely confusing for those whom are new to memory management at lower levels.
@franhm100
@franhm100 6 жыл бұрын
I'm a new man now. Thanks!
@satyasingh6144
@satyasingh6144 4 жыл бұрын
So, no one noticed how insanely 'unique' the name of this channel is? I bet this channel started with the inception of KZbin.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
It was called Kevin Drumm to begin with - not so catchy :)KD
@humanflybzzz4568
@humanflybzzz4568 6 жыл бұрын
Fantastic and eloquent explanation!!! This is a bit of a tough nut to crack on a first few tries, kinda like learning subnetting for the first time. I like how you don't just attack the viewer with a barrage of concepts rushing to complete the video, so that the ones with add can follow more easily :) Thanks dude!
@SleepyLink1
@SleepyLink1 4 жыл бұрын
Great video! Thank you I was struggling with this concept a little, but it's very clear here.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You're welcome :)KD
@lizdenhup
@lizdenhup 5 жыл бұрын
Such a helpful video! I love this channel!!
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
Thanks for the comment. :) KD
@TomerBenDavid
@TomerBenDavid 5 жыл бұрын
By far the best explanation please continue uploading videos
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
Thanks. I really appreciate the comments.
@sidchakravarty
@sidchakravarty 8 жыл бұрын
Thank you Kevin for creating this video. This is one of the best videos I saw that clearly explained call stack. Do you have any videos on Heap Memory?
@cm5754
@cm5754 3 жыл бұрын
It is interesting to present things in terms of popping individual elements off the stack, rather than just accessing them directly in memory and then restoring the frame pointer one time when a procedure returns.
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
I agree; this is an abstract view of an abstract data structure. My videos on the stack data structure mention how a stack might actually be implemented. :)KD
@gristlelollygag
@gristlelollygag 7 ай бұрын
This is fantastic, thank you!
@BB-wh2vm
@BB-wh2vm 4 жыл бұрын
Truly amazing explanation, thank you.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you :)KD
@mohalelebeya9469
@mohalelebeya9469 8 жыл бұрын
very clear and easy to follow, thanks guy!
@johnywhy4679
@johnywhy4679 4 жыл бұрын
4:50 : Unclear: In the scheme described, parameters passed from P1 to P2 are pushed onto stack before P1 address. Thus, P2 must clean up the parameters P1 passed to it. This was confusingly stated in the vid as "P1 must clean up the stack". Confusing since it was implied (but not stated) that, in the alternate scheme, P1 must clean up the parameters it passes to P2.
@pumbo_nv
@pumbo_nv 9 жыл бұрын
It should be noted that parameters are not always passed through the stack. It depends on calling convention and architecture. For example, on x64 first several parameters are passed in registers.
@medvfx3370
@medvfx3370 6 жыл бұрын
that's not what he said, he was talking about the return value, which is what happens in cdecl the return adress is in EAX @Frank Madrid
@davidnguyen9023
@davidnguyen9023 7 ай бұрын
This is great, thank you!
@LongVu-sm8wm
@LongVu-sm8wm 2 жыл бұрын
thanks. the explanation is very clear.
@YuhuiZHI
@YuhuiZHI 7 жыл бұрын
Very nice video. No technical word but very clear.
@ComputerScienceLessons
@ComputerScienceLessons 7 жыл бұрын
"Everything should be made as simple as possible, but not simpler" :)
@Decco6306
@Decco6306 4 жыл бұрын
thank you for these
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
My pleasure. :)KD
@Decco6306
@Decco6306 4 жыл бұрын
@@ComputerScienceLessons Im working on a smol z80 computer with 32k ram and rom and an 8255 pia for io this has helped my digest the information in the datasheets they throw out at you with no context as well as under the assumption you know what they are talking about. I got it to blink an led and im so happy. thanks again! (apparently they still make the 8 bit z80 and other supporting chips from zilog brand new. you can buy from Mouser.com and digikey.com as well as the 6502 from WDC from the same two suppliers mentioned)
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Crikey! The Sinclair Z80 was my first ever computer, before I upgraded to a Spectrum. You might enjoy Ben Eater's channel. kzbin.info/door/S0N5baNlQWJCUrhCEo8WlA
@Decco6306
@Decco6306 4 жыл бұрын
@@ComputerScienceLessons that's neat. My first PC was a win 98 PC from Packard Bell. play command & conquer for hours on end. mind you, this was wayyyy out of date. I got this in 2005.And you're too late! I'm already caught up with his videos! you're videos are filler for more "modern/relevant" topics if you will.
@henrychen1595
@henrychen1595 4 жыл бұрын
Question: Are the parameters and variables shuffled out of the stack if the procedure traverses it but does not use it?
@arpittiwari3749
@arpittiwari3749 11 ай бұрын
Very straightforward answer
@SJ_46
@SJ_46 2 жыл бұрын
Great explaination, one equestion: Why doesn't the initial frame or main() frame have any return address? I know that it's the first func, still the control goes to somewhere, r8? Maybe to the OS or somewhere.. Can you pls put some light on it?
@mariyehcloud
@mariyehcloud Жыл бұрын
well explained! thanks a lot
@ComputerScienceLessons
@ComputerScienceLessons Жыл бұрын
Thank you :)KD
@FaresYch16
@FaresYch16 Жыл бұрын
i love u, you are a hero
@ComputerScienceLessons
@ComputerScienceLessons Жыл бұрын
You are too kind :)KD
@arturasbrk5521
@arturasbrk5521 7 жыл бұрын
10 out of 10 ! very helpful!
@humanflybzzz4568
@humanflybzzz4568 4 жыл бұрын
Amazingly explained indeed ! Could you please do a vid on the topic of GOT and PLT tables, as well as got.plt ....
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
I am planning to do a video on linkers and loaders. In the mean time, you might find my playlist on compilers interesting: kzbin.info/www/bejne/mamxnZVofLl-f8U
@evolvOwns
@evolvOwns 7 жыл бұрын
Wow, excellent conceptual explanation.
@OneNordicWarrior
@OneNordicWarrior 8 жыл бұрын
Kevin, you're my man!
@Nobody-df7vn
@Nobody-df7vn 4 жыл бұрын
Hi, do you have a video on binding? and how different binding works? AMAZING VIDEO BTW!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thanks for the comment. :)KD I haven't covered binding explicitly, but it does come up in some of my videos. I have made a series of Python programming videos which mentions implicit variable declaration; in Python, a variable need not be declared explicitly, as it must in VB.NET (with Dim or Public), rather, Python infers the variable data type from the data you assign. This is called dynamic binding. I have also made a series of videos on object oriented programming with VB.NET. This includes a technique known as method overloading. When a program that calls an overloaded method is compiled, the compiler has to work out which variation of the method will be called at runtime based on its method signature. This 'resolved' call becomes part of the compiled code. This is known as static binding. These videos might help: kzbin.info/www/bejne/l6C9lpiBjbFnl68 kzbin.info/www/bejne/b4bcZZ5vr9OYpKc
@laurentiustefan398
@laurentiustefan398 5 жыл бұрын
great vid.
@bettyswunghole3310
@bettyswunghole3310 4 жыл бұрын
Do you have to manually push the return address onto the stack and then manually pop it back to the program counter? Forgive me if this is a dumb question...I'm a bit of a noob, and so far I've only seen the "ret" instruction that seems to "magically" take care of return addresses.
@kindalost1
@kindalost1 9 жыл бұрын
10x. elaborated and clear.
@magica2z
@magica2z 6 жыл бұрын
Great video.. Thank you and Subscribed..
@Xpingwinz
@Xpingwinz 9 жыл бұрын
Awesome video and thank you!!
@alimeree4299
@alimeree4299 8 жыл бұрын
thanks allot man , very clear .. keep going ..
@bestsaurabh
@bestsaurabh 3 жыл бұрын
Great explaination. One question: Why are agruments of a function read from right to left? The right most argument is at the bottom of the stack. Can someone please help me understand what if we read it other way round( left to right). ??
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
Interesting question. I believe it has to do with the fact that functions can be defined with optional parameters. For example, here is a VB.NET function definition with two mandatory parameters, a and b, and an optional parameter. Function myFunction(a As Integer, b As Integer, Optional c As Integer = 0) Any optional parameters must be specified at the right hand side of the comma separated list. When these arguments are read onto the stack, the mandatory ones will end up at the top, and their memory locations (offsets) will be known at compile time, so it's possible to access them more easily. Optional arguments, which may or may not be there, are lower down. :)KD
@zoutuzhuren3370
@zoutuzhuren3370 7 жыл бұрын
thank you, this is really really Great!!!
@ComputerScienceLessons
@ComputerScienceLessons 7 жыл бұрын
Cheers :)
@jjjww975
@jjjww975 6 жыл бұрын
Well done!
@ppotter10
@ppotter10 3 жыл бұрын
Hardly any video that explains how the stack is actually being used. Thanks!
@tobiasdummling6144
@tobiasdummling6144 4 жыл бұрын
What I dont understand is how can the subprocess read their parameters? They pop the return address and than it says the next process cleans up the stack. But shouldnt it be cleaned up by the process automatically as it has to pop the parameters to read them (LIFO)?
@jedmuff5597
@jedmuff5597 7 жыл бұрын
So what is the "Stack"? An order that the procedures must follow when carrying out there instructions? Like a BODMAS sort of thing that they do in maths? Or is it more like how the computer sorts out the procedures that are calling each one another? Also, which way does the procedure have to travers the stack(top to bottom or bottom to top) and does the procedure do the whole stack or does the procedure just do its selected stack frame?
@ComputerScienceLessons
@ComputerScienceLessons 7 жыл бұрын
Take a look at this one kzbin.info/www/bejne/pJqlpHqtac1or6s
@anirudh8575
@anirudh8575 6 жыл бұрын
Is there any specific reason why the parameters are stored in the reverse order on the stack?
@muktadir.rahman
@muktadir.rahman 9 жыл бұрын
Thank you so much for this video.
@coasterfreak-486
@coasterfreak-486 3 жыл бұрын
Informative video
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
Thank you :)KD
@sinisatadic1959
@sinisatadic1959 8 жыл бұрын
Excellent! :)
@ComputerScienceLessons
@ComputerScienceLessons 8 жыл бұрын
Tnx
@NinaHProductions1
@NinaHProductions1 8 жыл бұрын
Is this for all stacks i.e. does this work for the JVM?
@rajeevsawant2281
@rajeevsawant2281 7 жыл бұрын
Hi , Can you please give an example (name of the architecture )where the above implementation method of pushing the parameters first and then pushing return addr of previous procedure is implemented ??
@gaithsabah1026
@gaithsabah1026 4 жыл бұрын
Thanks
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You're welcome :)KD
@akashkhunt4191
@akashkhunt4191 5 жыл бұрын
Hi, Why does all recursion calls have same return address ? Thank you
@jdeleca
@jdeleca 4 жыл бұрын
I think it's because it's calling it-self, well, it does need to call it self, just update the memory/registers inside a conditional loop
@tharangamadhusankha
@tharangamadhusankha Жыл бұрын
Thank you
@sia3540
@sia3540 3 жыл бұрын
How do I troubleshoot Windows 10 error "new guard page for the stack cannot be created"? I know nothing about programing!
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
This error indicates that you are low on memory, or virtual memory. (Virtual memory is a swap file on your hard drive, or SSD, that is used to supplement the RAM when it's getting full.) The circumstances under which the error appears are important. Is it being triggered when you are playing a particular game? Does your computer meet the requirements of the software you are using? What has changed since you started seeing the error message - did it start after you download something? Grand Theft Auto for example can be problematic. A lot of computers these days boot from an SSD (solid state drive). The SSD holds the operating system (such as Windows) and is usually labelled drive C. SSDs tend to have a much lower capacity than magnetic drives and will fill up quickly if you install all of your applications on it, leaving little space for virtual memory. How full is your drive C looking? (Click on This PC in File Explorer to check.) If your computer has another (magnetic) drive (labelled drive D), install your software there instead of the SSD in future. You could also try moving some of your software from C to D. (I put all of my Epic and Steam games on drive D). Be careful how you do this, you can't just cut and paste files. Maybe you could also do with a general clear out. Uninstall any applications (incl. games) that you don't use anymore, and delete any photos and videos you don't want to keep (or move them to an external drive). Be careful not to throw the baby away with the bath water! You could also defragment your drive if you haven't done it for a while (right click the drive in File Explorer and select Properties then Tools). If you have a PC that you can expand, you could also consider putting some more RAM sticks inside it (but make sure you research how to do this, or get someone else to do it for you, if you are not sure what to do). Good luck :)KD
@sia3540
@sia3540 3 жыл бұрын
@@ComputerScienceLessons Thanks for replying! I will try your suggestions.
@thlu308
@thlu308 7 жыл бұрын
Wouldn't it make more sense to push the return address first, then the parameters? This way, when the called function returns control to the calling function, the stack frame is already clean.
@yaroxkendo3043
@yaroxkendo3043 6 жыл бұрын
It's really just a conventional issue to decide who is responsible to clear the stack. In the given design, the procedure which pushed the parameters is responsible to pop them again. When programming in Assembler you can 'abuse' this functionality whenever you push the same parameters over and over again to (different) procedures, so you don't even need to push pop them over and over again, just once pushing them onto the stack when calling the first procedure and popping them after a last call.
@RahulKumar-ci4by
@RahulKumar-ci4by 3 жыл бұрын
Good very good
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
Thank you :)KD
@stevedcohen
@stevedcohen 4 жыл бұрын
Great video, although it would have been better to use 83 procedures instead of 4.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
I totally agree :)KD
@saurabhjha8733
@saurabhjha8733 Жыл бұрын
what if procedure 4 calls procedure 5?
@rajvijay3276
@rajvijay3276 6 жыл бұрын
perfect
@SwissPhil02
@SwissPhil02 3 жыл бұрын
I thought the stack grew downwards not upwards ???
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
At the risk of sounding glib, it's a matter of perspective. These are abstract diagrams. Conventionally, you are correct, but my students find it more intuitive to imagine it growing up. :)KD
@violinsheetmusicblog
@violinsheetmusicblog 7 жыл бұрын
thank you!!!!!
@guilhermetomishiyoteixeira4731
@guilhermetomishiyoteixeira4731 9 жыл бұрын
Thank you! Not that hard...I was looking around the internet trying to get a better grasp in the subject.
@MRAXELGRINDER
@MRAXELGRINDER 5 жыл бұрын
great
@allisonscanlan4144
@allisonscanlan4144 3 жыл бұрын
Great video but the sound static makes it hard to listen
@poojanaregal9907
@poojanaregal9907 6 жыл бұрын
Can u get us a opengl program for this ...
@mushahidhussain1516
@mushahidhussain1516 6 жыл бұрын
Your voice man.
@YouB3anz
@YouB3anz 4 жыл бұрын
nice bass
@Theexacc
@Theexacc 7 ай бұрын
bro is defining a recursion
@cslogs1633
@cslogs1633 4 жыл бұрын
cool
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
:)KD
@venkzvenki
@venkzvenki 6 жыл бұрын
Saintgits peopls....Like adikke...😋🙋‍♂️
@johnywhy4679
@johnywhy4679 4 жыл бұрын
Awesome vid! But, could have been made shorter by eliminating one or two procedures. After P2, it's just redundant.
@shalineebhawnani
@shalineebhawnani 7 жыл бұрын
itti English aati to video dekhne ko jarurt ni padhti
@J2897Tutorials
@J2897Tutorials 8 жыл бұрын
I can't see no code, circuit, tracks, ICs, nor electrons, just silly diagrams. Still makes no sense. So a clicking I will go, a clicking I will go, E I antio, a clicking I will go...
Roaming User Profiles
4:31
Computer Science Lessons
Рет қаралды 9 М.
Ep 081: Introduction to the Stack Pointer
16:09
Intermation
Рет қаралды 57 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Laravel API: Custom 404 Error Message (Laravel 11 Version)
3:59
Call Stacks - CS50 Shorts
7:40
CS50
Рет қаралды 130 М.
The Call Stack and Stack Overflows (example in C)
12:56
Jacob Sorber
Рет қаралды 47 М.
The Call Stack
9:33
MrBrownCS
Рет қаралды 10 М.
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,5 МЛН
The JS Call Stack Explained In 9 Minutes
9:30
Colt Steele
Рет қаралды 89 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 456 М.
Tips for C Programming
34:41
Nic Barker
Рет қаралды 66 М.
Mastering Memory: Allocation Techniques in C, C++, and ARM Assembly
17:05
ARRAYLIST VS LINKEDLIST
21:20
Core Dumped
Рет қаралды 93 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН