1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Memory Segments Queries

Discussion in 'C' started by kanaks_go4ex, Nov 5, 2008.

Thread Status:
Not open for further replies.
  1. kanaks_go4ex

    kanaks_go4ex New Member

    Analyzing the memory layout for my sample program in Linux Environment.

    ----------------------------------
    Code:
    #include<stdio.h>
    
    int test_g = 1; // Data or BSS ? Data section Right ?
    int test_h; // Data or BSS ? BSS section Right ?
    
    static int test_s = 1;
    static int test_q;
    
    
    int func1(bool a ,bool b)
    {
    short temp;
    static int var_temp; // Stack or BSS ?
    return 0;
    
    }
    
    int main(void)
    {
    int m_var = 0; // Will be assigned in Stack section Right ?
    static int main_temp = 0 ; Which section Data or BSS ?
    m_var = func(true,true);// Will be assigned in Stack section Right ?
    
    return m_var;
    
    }
    
    
    help me for the queries added as comments in 'C' Program.
    ------------------------------------


    My Qs Is :

    What are all the sections shared during ,when the function call func1 made from the main?

    Generally every function call has its own stack.Other sections bss , data . text are shared between the multiple process or threads ?.
    will the heap shared ?



    Will the compiler assign the sections during the program compilation itself?
     
    Last edited by a moderator: Nov 6, 2008
  2. shabbir

    shabbir Administrator Staff Member

Thread Status:
Not open for further replies.

Share This Page