What is a computer stack and how many stacks are there in computer?

rukawa

rukawa

@rukawa-Y0pUkC Oct 22, 2024

I would like to know how many stacks are there in a computer and what is a stack in reality and what is the function of each stack.
Thank you in advance

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Jeffrey Arulraj

    Jeffrey Arulraj

    @jeffrey-xA7lUP Aug 7, 2013

    Remeber a pile of Coins or a pile of books arranged one over the other That is a really good example of a stack

    In a stack the last placed object can only be taken out at the first time

    That is when you place 10 books one over the other the book on top only can be removed @ the first time though you wish to take the last book This is called stack

    The first question I am not sure about it mate

    In a computer the Main Memory is based on Stack concept I guess

  • Pensu

    Pensu

    @pensu-8tNeGU Aug 7, 2013

    Stack is just a pile with a last in first out mechanism. In computer science, stacks are used quite a lot. The simplest example is functions. When a function calls another function it just put the other function on the top of the stack. So, the top would be executed first.

    As far as the number of stacks is concerned, I dont think there is a limit. I guess it depends on your system's memory.

  • rukawa

    rukawa

    @rukawa-Y0pUkC Aug 7, 2013

    Thak you for your answers. Each process have a stack right? what is it used for and where is it stored?

  • Pensu

    Pensu

    @pensu-8tNeGU Aug 7, 2013

    Stack is a logical entity. The computer represent the memory in form of a stack. So, stack is nothing but your memory only. Any as far as I know every thread has a stack.

  • rukawa

    rukawa

    @rukawa-Y0pUkC Aug 7, 2013

    In Mr. Tanenbaum's book "operating systems", he says that processes in UNIX have their memory divided up into 3 segments :

    - the text segment (i.e the program code)
    - the data segment (i.e the variables)
    - the stack segment.

    rfdfgdf
    The stack segment is used for what?

  • Pensu

    Pensu

    @pensu-8tNeGU Aug 7, 2013

    Well, the stack segment mainly stores local variables, while the data segment stores global and static variables.

  • rukawa

    rukawa

    @rukawa-Y0pUkC Aug 7, 2013

    In the body of the process's program there are a numbrer of functions. Everytime a function is called, the process uses its stack (I mean the process's stack) to store the parameters and local variables and return addresses, is that true? is the process's stack used fot all the functions of the program?

  • Pensu

    Pensu

    @pensu-8tNeGU Aug 7, 2013

    Well, that makes senses. The function shouldn't have it's stack outside process's memory space.

  • Nayan Goenka

    Nayan Goenka

    @nayan-Dhpt4N Aug 7, 2013

    There is nothing like a Computer Stack. We have stacks. It is a data structure which allows you to store arrays of data together in a LIFO format that is Last in first out.

    The number of stacks is not specific. A stack can be of any size and length. If you have doubt any particular stack in any program or you have read about it somewhere and you didnt understand then paste that content here. We will try to explain.

  • rukawa

    rukawa

    @rukawa-Y0pUkC Aug 8, 2013

    The process's program contains functions which may call other functions. When a function calls another function, the address that the called function should return to is stored in the stack. But what exactly is this address :
    - the address of the instruction following the instruction that called the function
    - the address of the instruction that called the function
    - the address of the program itself
    what is it?

  • Pensu

    Pensu

    @pensu-8tNeGU Aug 8, 2013

    Option A.....😉