C variable Storage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Santy

    #1

    C variable Storage

    Hello Friends,

    I want to know some details regarding the C programming.
    When we run the program exe then how the variable are stored in the
    memory area
    according to their Storage classes and all.

    also how the memory mgmt is done while execution.

    if their is any book which can be refered.

    Thanks
    Santosh

  • Christopher Layne

    #2
    Re: C variable Storage

    Santy wrote:
    Hello Friends,
    >
    I want to know some details regarding the C programming.
    When we run the program exe then how the variable are stored in the
    memory area
    according to their Storage classes and all.
    When, oh when, will these "Please do the work for me" questions stop coming
    in?

    <preaching to the choir>

    Comment

    • jacob navia

      #3
      Re: C variable Storage

      Santy wrote:
      Hello Friends,
      >
      I want to know some details regarding the C programming.
      When we run the program exe then how the variable are stored in the
      memory area
      according to their Storage classes and all.
      >
      also how the memory mgmt is done while execution.
      >
      if their is any book which can be refered.
      >
      Thanks
      Santosh
      >
      This is easy to do:

      1) OPEN YOUR TEXT BOOK
      2) READ IT!!!!
      3) ANSWER THE EXERCISES.

      Comment

      • Cong Wang

        #4
        Re: C variable Storage


        Santy wrote:
        Hello Friends,
        >
        I want to know some details regarding the C programming.
        When we run the program exe then how the variable are stored in the
        memory area
        according to their Storage classes and all.
        >
        also how the memory mgmt is done while execution.
        >
        if their is any book which can be refered.
        >
        Thanks
        Santosh
        Maybe the book "Computer Systems: A Programmer's Perspective" is
        helpful for you. ;-p

        Comment

        • Kenneth Brody

          #5
          Re: C variable Storage

          jacob navia wrote:
          >
          Santy wrote:
          Hello Friends,

          I want to know some details regarding the C programming.
          When we run the program exe then how the variable are stored in the
          memory area
          according to their Storage classes and all.

          also how the memory mgmt is done while execution.

          if their is any book which can be refered.
          >
          This is easy to do:
          >
          1) OPEN YOUR TEXT BOOK
          2) READ IT!!!!
          3) ANSWER THE EXERCISES.
          Actually, isn't the answer "it's all implementation dependant"?
          AFAIK (and I've been wrong before), the standard doesn't impose
          any limits on how/where/why "variables are stored". The system
          could, if the implementor so chooses, group all variables of the
          same type together and sort them alphabetically.

          --
          +-------------------------+--------------------+-----------------------+
          | Kenneth J. Brody | www.hvcomputer.com | #include |
          | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
          +-------------------------+--------------------+-----------------------+
          Don't e-mail me at: <mailto:ThisIsA SpamTrap@gmail. com>

          Comment

          • Richard Heathfield

            #6
            Re: C variable Storage

            Kenneth Brody said:
            jacob navia wrote:
            >Santy wrote:
            I want to know some details regarding the C programming.
            When we run the program exe then how the variable are stored in the
            memory area
            according to their Storage classes and all.
            [...]
            >This is easy to do:
            >>
            >1) OPEN YOUR TEXT BOOK
            >2) READ IT!!!!
            >3) ANSWER THE EXERCISES.
            >
            Actually, isn't the answer "it's all implementation dependant"?
            Yes, any book that answers these questions in some more specific way than
            that is unlikely to be a very good C book. (It's not impossible, just very
            unlikely.) And there may not be a textbook available that gives such
            architectural details for the OP's platform (which was not stated). So
            "open your text book" is a bit of a silly answer.

            <snip>

            --
            Richard Heathfield
            "Usenet is a strange place" - dmr 29/7/1999

            email: rjh at above domain (but drop the www, obviously)

            Comment

            • Santy

              #7
              Re: C variable Storage

              but still there are some methods that might be there
              as in interviews they ask about the things as:
              ---- where the static varibles are stored ?
              ---- how the execution of the C program ?
              etc?

              so how can i answer them ,please help to give me the low level details
              of the C programming.

              Thanks
              Santosh

              Richard Heathfield wrote:
              Kenneth Brody said:
              jacob navia wrote:
              Santy wrote:
              I want to know some details regarding the C programming.
              When we run the program exe then how the variable are stored in the
              memory area
              according to their Storage classes and all.
              [...]
              This is easy to do:
              >
              1) OPEN YOUR TEXT BOOK
              2) READ IT!!!!
              3) ANSWER THE EXERCISES.
              Actually, isn't the answer "it's all implementation dependant"?
              >
              Yes, any book that answers these questions in some more specific way than
              that is unlikely to be a very good C book. (It's not impossible, just very
              unlikely.) And there may not be a textbook available that gives such
              architectural details for the OP's platform (which was not stated). So
              "open your text book" is a bit of a silly answer.
              >
              <snip>
              >
              --
              Richard Heathfield
              "Usenet is a strange place" - dmr 29/7/1999

              email: rjh at above domain (but drop the www, obviously)

              Comment

              • Richard Heathfield

                #8
                Re: C variable Storage

                Santy said:
                but still there are some methods that might be there
                as in interviews they ask about the things as:
                ---- where the static varibles are stored ?
                If I were asked that in an interview, I'd say: "It depends on the computer
                and the compiler, and nobody can be expected to be an expert on all
                architectures. But it would be easy enough to find out, for a given system,
                by consulting its documentation."
                ---- how the execution of the C program ?
                I can't even begin to interpret that as a question. Sorry.

                --
                Richard Heathfield
                "Usenet is a strange place" - dmr 29/7/1999

                email: rjh at above domain (but drop the www, obviously)

                Comment

                • klakkamr

                  #9
                  Re: C variable Storage


                  Santy wrote:
                  Hello Friends,
                  >
                  I want to know some details regarding the C programming.
                  When we run the program exe then how the variable are stored in the
                  memory area
                  according to their Storage classes and all.
                  >
                  also how the memory mgmt is done while execution.
                  >
                  if their is any book which can be refered.
                  >
                  Thanks
                  Santosh
                  Hi Santhosh

                  Hope the following link will be useful.


                  Thanks
                  Kishore

                  Comment

                  • Ancient_Hacker

                    #10
                    Re: C variable Storage


                    Santy wrote:
                    Hello Friends,
                    >
                    I want to know some details regarding the C programming.
                    When we run the program exe then how the variable are stored in the
                    memory area

                    The C standard doesnt say much about this, it just requests that static
                    and global variables hold their values.

                    The compiler is free to put the variables wherever it wants-- sometimes
                    in specific fixed locations in memory, sometimes in registers,
                    sometimes in temporary areas on the stack.
                    For that matter, it could just as well allocate them in a database, in
                    a file, in virtual memory, as symbols in the program's environment, or
                    most anywhere.

                    One way to learn the nitty-gritty is to compile a small C program and
                    specify the "-S" option, or whatever options writes out an assembly
                    language source file. The either learn asm, or find a book or person
                    that understands it. You should see places in the asm code where
                    global variables are defined, where local variables are accessed as
                    offsets from the stack or base pointer, and where some inner-loop
                    variables are held in registers. Can be a fascinating journey.

                    Comment

                    • Kenneth Brody

                      #11
                      Re: C variable Storage

                      Santy wrote:
                      >
                      but still there are some methods that might be there
                      as in interviews they ask about the things as:
                      ---- where the static varibles are stored ?
                      In some place that will be accessible for the duration of the
                      execution of the program. Where, exactly, that is, is entirely
                      up to the system (a combination of what the hardware can do, what
                      the O/S will allow a program to do, and what the implementor of
                      the C envinronment chose to do).
                      ---- how the execution of the C program ?
                      I don't understand what you're asking, but there's really nothing
                      to be said beyond "the O/S and runtime library startup code do
                      some magic, and then call main(), and when main() returns, do some
                      more magic". (Well, you could get into "exit()", "abort()" and
                      things like Unix "segmentati on violations" if you wanted to get
                      even further into the mess.)
                      etc?
                      >
                      so how can i answer them ,please help to give me the low level details
                      of the C programming.
                      [...]

                      --
                      +-------------------------+--------------------+-----------------------+
                      | Kenneth J. Brody | www.hvcomputer.com | #include |
                      | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
                      +-------------------------+--------------------+-----------------------+
                      Don't e-mail me at: <mailto:ThisIsA SpamTrap@gmail. com>


                      Comment

                      • Santy

                        #12
                        Re: C variable Storage

                        Hi Kishore,
                        Yes this link contains some imp information i need.
                        if u know such links regarding C C++ ,please do forward me.

                        thank you very much.

                        Thanks
                        Santosh

                        klakkamr wrote:
                        Santy wrote:
                        Hello Friends,

                        I want to know some details regarding the C programming.
                        When we run the program exe then how the variable are stored in the
                        memory area
                        according to their Storage classes and all.

                        also how the memory mgmt is done while execution.

                        if their is any book which can be refered.

                        Thanks
                        Santosh
                        >
                        Hi Santhosh
                        >
                        Hope the following link will be useful.

                        >
                        Thanks
                        Kishore

                        Comment

                        • Richard Bos

                          #13
                          Re: C variable Storage

                          "klakkamr" <kishorelr@gmai l.comwrote:
                          Santy wrote:
                          I want to know some details regarding the C programming.
                          When we run the program exe then how the variable are stored in the
                          memory area according to their Storage classes and all.

                          also how the memory mgmt is done while execution.
                          Hope the following link will be useful.
                          http://www.cs.uml.edu/~kfawcett/cs1/Stack_add.c.html
                          Or perhaps not, since it is highly (and explicitly, though from the
                          looks of it only by accident) UNIX-specific, and not very well written
                          either.

                          Richard

                          Comment

                          • santosh

                            #14
                            Re: C variable Storage

                            Santy wrote:
                            klakkamr wrote:
                            Santy wrote:
                            Hello Friends,
                            >
                            I want to know some details regarding the C programming.
                            When we run the program exe then how the variable are stored in the
                            memory area
                            according to their Storage classes and all.
                            >
                            also how the memory mgmt is done while execution.
                            >
                            if their is any book which can be refered.
                            Hi Santhosh

                            Hope the following link will be useful.
                            http://www.cs.uml.edu/~kfawcett/cs1/Stack_add.c.html
                            >
                            Hi Kishore,
                            Yes this link contains some imp information i need.
                            if u know such links regarding C C++ ,please do forward me.
                            >
                            thank you very much.
                            Just wanted to let you know that top-posting, (which I have taken the
                            liberty to fix in this instance), and SMS style abbreviations are not
                            well recieved, (and for good reasons, I might add), in this group. To
                            rid yourself of this blight of character read the information at the
                            following URLs.

                            <http://cfaj.freeshell. org/google/>
                            <http://www.safalra.com/special/googlegroupsrep ly/>

                            <http://clc-wiki.net/wiki/Introduction_to _comp.lang.c>
                            <http://en.wikipedia.or g/wiki/USENET>
                            <http://en.wikipedia.or g/wiki/Netiquette>

                            Comment

                            • Kenneth Brody

                              #15
                              Re: C variable Storage

                              (Top-posting corrected.)

                              Santy wrote:
                              klakkamr wrote:
                              Santy wrote:
                              Hello Friends,
                              >
                              I want to know some details regarding the C programming.
                              When we run the program exe then how the variable are stored in the
                              memory area
                              according to their Storage classes and all.
                              >
                              also how the memory mgmt is done while execution.
                              >
                              if their is any book which can be refered.
                              Hope the following link will be useful.
                              >
                              Hi Kishore,
                              Yes this link contains some imp information i need.
                              if u know such links regarding C C++ ,please do forward me.
                              >
                              thank you very much.
                              Well, it may include "imp information" to you, but you have to
                              realize that the page does _not_ explain where "C" will put
                              things, but rather how the particular C compiler used at the
                              Computer Science department at UMass Lowell puts things.

                              --
                              +-------------------------+--------------------+-----------------------+
                              | Kenneth J. Brody | www.hvcomputer.com | #include |
                              | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
                              +-------------------------+--------------------+-----------------------+
                              Don't e-mail me at: <mailto:ThisIsA SpamTrap@gmail. com>

                              Comment

                              Working...