none
Thread Stack, Virtual Execution Stack, Evaluation Stack RRS feed

  • Question

  • I am trying to learn CIL Programming out of my interest and i am bit confused b/w Thread Stack and Virtual Evaluation stack/Execution stack. I understand that before start of any method stack size are determined and items are first loaded into stack before getting processed. When is this thread stack coming into picture.?


    RishiKesh Singh

    Sunday, April 15, 2012 3:24 PM

Answers

  • Hi, 

    Evaluation stack , analogous to Operand stack in JVM, contains the intermediate values of computation performed by the executing method. Each time a method is invoked, a method state is created which includes Evaluation stack with the size of 2 slots of each slot is either 4 or 8 bytes. This is what .maxstack directive represents in IL

     Hence the life time of Evaluation stack is life time of method. Since this is also a stack follows LIFO (Last in First out) which is what Joel showed with example above.

    Each time when thread has been created a reserved region of memory , 1 MB of size, will be committed ( means 1 MB of memory is committed even though there is no 1 MB data) this converts if there are 100 threads will take minimum 100MB of memory only for thread stack. At a min thread stack is used to hold the location of function calls in order to allow return statements return to correct location.

    Hence thread stack memory will be freed when the thread  exits.

    I hope this helps you to understand...


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".


    Sunday, April 15, 2012 6:25 PM
  • Lets make the call stack even simpler to understand.  It is the memory reserved to put the the variables/objects in the call list plus the return variable/object.  I've never programed in CIL, but have programs in lots of assembly languages and recognized the code that Kris posted immediately.  Also took quite a few assembly language cources in college.  If the total number of bytes in the parameter list plus the numnber of bytes in the return object.  Kris example the total is 8 bytes.


    jdweng

    Sunday, April 15, 2012 8:08 PM

All replies

  • What documentation are you reading? If it is a webpage can you give us the link?  it would make it easier to answer your question.


    jdweng

    Sunday, April 15, 2012 3:31 PM
  • You cannot vote on your own post

    I was googling and reading. I read about evaluation stack and then read about Thread stack and got confused.


    RishiKesh Singh

    Sunday, April 15, 2012 3:38 PM
  • The thread stack and the evaluation stack could be the same stack.  Some algorithms pushes variables onto a stack before the algorithm is performed and this is refered to as an evaluation stack.  Sppose you have to formula below:

    Y = A + B + C

    If a evaluation stack is used, first the variables in order get pushed onto the stack.  When you pop the variables off the stack you start evaluation the C variable (last variable) first.  It is a cleaver way of getting the last parameter.

    Now you have to be careful in which direction the stack is going (from top of memory or bottom of memory) which is called the first item into the stack and which is the last item into the stack.


    jdweng

    Sunday, April 15, 2012 4:18 PM
  • Thanks jdweng.. but when these two Evaluation and Thread can be same and when different? What are their actual role?

    RishiKesh Singh

    Sunday, April 15, 2012 4:27 PM
  • Hi, 

    Evaluation stack , analogous to Operand stack in JVM, contains the intermediate values of computation performed by the executing method. Each time a method is invoked, a method state is created which includes Evaluation stack with the size of 2 slots of each slot is either 4 or 8 bytes. This is what .maxstack directive represents in IL

     Hence the life time of Evaluation stack is life time of method. Since this is also a stack follows LIFO (Last in First out) which is what Joel showed with example above.

    Each time when thread has been created a reserved region of memory , 1 MB of size, will be committed ( means 1 MB of memory is committed even though there is no 1 MB data) this converts if there are 100 threads will take minimum 100MB of memory only for thread stack. At a min thread stack is used to hold the location of function calls in order to allow return statements return to correct location.

    Hence thread stack memory will be freed when the thread  exits.

    I hope this helps you to understand...


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".


    Sunday, April 15, 2012 6:25 PM
  • Lets make the call stack even simpler to understand.  It is the memory reserved to put the the variables/objects in the call list plus the return variable/object.  I've never programed in CIL, but have programs in lots of assembly languages and recognized the code that Kris posted immediately.  Also took quite a few assembly language cources in college.  If the total number of bytes in the parameter list plus the numnber of bytes in the return object.  Kris example the total is 8 bytes.


    jdweng

    Sunday, April 15, 2012 8:08 PM