I was studying computer architectures and got to the Call Stack As wikipedia...

Anthony Ward
Anthony Ward

I was studying computer architectures and got to the Call Stack
As wikipedia says
This kind of stack is also known as an execution stack, program stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack"
why there are so many names for the same thing?
Also why we use stacks and not queques? FIFO makes more sense to me in this case

Attached: 342px-Call-stack-layout.svg[1].png (17.18 KB, 342x279)

Ethan Lee
Ethan Lee

why there are so many names for the same thing?
why are there 40,000 different flavors of christianity?

Luke Peterson
Luke Peterson

There are huge differences between christian denominations

Ayden James
Ayden James

the jews did it
^ this.

Wikipedia is trash if you want to learn anything. Great for picking up useless trivia or getting the (((official story))) for controversial events.

Lincoln Russell
Lincoln Russell

he doesnt program using only the heap
you look like a baby

Logan Bennett
Logan Bennett

this is why Holla Forums is the worst place to discuss anything
I used to lurk treads of things I didn't even care about just because people actually argued and explained their views and it was nice to read
Nowadays is just (((>jews)))
go back to /pol/index.html faggots

Angel Campbell
Angel Campbell

Uneducated brainlets who can't make the difference between stacks and queues aren't interesting.

Isaiah Cooper
Isaiah Cooper

Uneducated brainlets who can't make a single coherent sentence aren't interesting either.

Xavier Gray
Xavier Gray

I know the difference, I was just asking why we use those
and actually while waiting for a decent reply, I understood why stacks are used

Andrew Howard
Andrew Howard

Good for you.
It's literally programming 101, covered in the first week of every decent Programming course.
But it still shouldn't take much to imagine for anyone who has a minimum grasp on how local declarement works.

Juan Bennett
Juan Bennett

I'm not following a programming course
My uni is more EE with lots of mathematics and a couple of CS courses

Carson Evans
Carson Evans

FIFO makes more sense to me in this case
Think about the implementation here. How many pointers would you need to keep track of a queue? With a stack, it is just one. This is used so frequently, it's kept in a register, can you spare more registers to support a queue structure? Why wouldn't that be a good idea?

Easton Wood
Easton Wood

Why wouldn't that be a good idea?
Because you would have to waste cycles loading the register with the additional pointer?
Thanks for the help

Daniel Morgan
Daniel Morgan

still, if you understand how local declarment manages the memory, then you should automicatically understand why it is the way it is

Hudson Walker
Hudson Walker

More than that, it just doesn't make sense a to use a queue for function calls. Why would you want to remove the oldest part of the stack? You'd have nowhere to return to. I guess it could work if you used jumps everywhere instead of calls, but that would be pretty retarded, like only using goto's in C.

Ryder Diaz
Ryder Diaz

Well the fact that you have to waste a register is bad enough. The queue would give you no advantages at all, and many disadvantages. A key thing to remember is that just because things are thrown onto the stack in FIFO order, doesn't mean they cannot be accessed arbitrarily. There are memory fetch instructions built into the assembly language to fetch a location with offset.

Isaac Torres
Isaac Torres

Thanks, really, it makes a lot more sense now

Tyler Diaz
Tyler Diaz

built into the assembly language
Err, scratch that part out.
You're welcome.

Brandon Jones
Brandon Jones

Assemblers do sometimes have pseudoinstructions that translate into 2 or more actual instructions, easy examples to point out would be how various fixed width ISAs like MIPS deal with having registers larger than their encoding allows (32bit MIPSIV with 64bit registers). I mean its one way to add a couple "missing" instructions, or you can staple shit into a heavily microcoded trashheap every few months instead...

Oliver Brooks
Oliver Brooks

Human pride

Owen Brooks
Owen Brooks

Yeah, but the point of scratching that out was because I phrased the sentence poorly.

Charles Barnes
Charles Barnes

why there are so many names for the same thing?
This probably stems from different processor manufacturers calling them different things.
Also why we use stacks and not queques?
A queue is not how a program typically works. Using a queue would be more applicable if we only ever entered a new function at the end of the last one. Even then the queue would only have a size of 1. Since 99% of the time function calls are in the middle of a function we need to use a stack. It should be pretty simple to visualize entering and exiting functions to be like a stack. Think of calling a funcion as pushing it onto a theoretical stack and return instruction as popping off the top of our theoretical stack. With this mental model you should notice how function calls, even recursive one closely align with the idea of FIFO. A function that has returned must also have been the last function that was called.

Adam Lee
Adam Lee

You don't want fifo when the first ones are your kernel.

Disable AdBlock to view this page

Disable AdBlock to view this page

Confirm your age

This website may contain content of an adult nature. If you are under the age of 18, if such content offends you or if it is illegal to view such content in your community, please EXIT.

Enter Exit

About Privacy

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. We also share information about your use of our site with our advertising and analytics partners.

Accept Exit