Stack Implementation in Operating System uses by Processor

A stack is an associate ordered a set of components, only one of that (last added) are often accessed at a time. The point of access is named the highest of the stack. The number of components within the stack, or length of the stack, is variable. Items could solely be side to or deleted from the highest of the stack. For this reason, a stack is additionally referred to as a pushdown list or a last-in-first-out (LIFO) list.

The implementation of a stack needs that there be some set of locations accustomed store the stack components. A typical approach is illustrated in the below diagram.







The location of the continuous block is reserved in main memory (or virtual memory) for the stack. Most of the time, the block is part full of stack components and also the remainder is accessible for stack growth. Three addresses area unit required for correct operation, and these area units typically keep in processor registers:

  • Stack Pointer:
    It contains the address of this prime of the stack. If the associated item is appended to (PUSH) or deleted from (POP) the stack, the pointer is decremented or incremented to contain the address of the new prime of the stack.
  • Stack Base:
    It contains the address of a very cheap location within the reserved block. this can be the primary location to be used once the associated item is side to associate empty stack. If an effort is formed to POP a component once the stack is empty, an error is reported.

  • Stack Limit:
    It contains the address of the opposite finish, or top, of the reserved block. If an effort is formed to PUSH a component once the stack is full, an error is reported.

Traditionally, and on most processors, these days, the base of the stack is at the high address finish of the reserved stack block, and also the limit is at the low-address finish. so, the stack will grow from higher addresses to lower addresses.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.