Thread: How is the Extra segment used?

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    69

    How is the Extra segment used?

    I understand that there are four different primary memory segments that are allocated when a program is loaded into memory: (1) code, (2) data, (3) stack, and (4) extra. Can someone please explain what the extra segment is used for? Thanks in advance.

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    22
    Extra Segment is generally used for storing the temparory data in various operation (in memcpy( ), to store DS data temporarily.

    ---------------------------
    Bhupesh

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    > I understand that there are four different primary memory segments that are allocated
    > when a program is loaded into memory:
    Only if you're using a 16-bit x86 compiler.

    For 32-bit x86 systems, and lots of other platforms, segment registers are nowhere to be found since memory is just a single contiguous address space.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ok, so in 16-bit code, the ES segment is NECESSARY to copy from one segment to another, e.g. in a memcpy() where the arguments aren't in the same segment (e.g. global to local variables, variable in the heap, etc).

    I don't quite agree with Salem. Yes, segments are not involved in the effective address of the data- or code-access, but the segment registers are actually still needed. It's just that all segments have a base-address of 0 and a size of 4GB (or however large you want the memory to be). So, whilst segments are still there, they are essentially never loaded with different values, just set once and for all in the startup of each process.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. buffer has extra contents in gtk+ 2.0
    By MK27 in forum Linux Programming
    Replies: 5
    Last Post: 08-04-2008, 11:57 AM
  3. execute a code in data segment...
    By ravindragjoshi in forum Windows Programming
    Replies: 1
    Last Post: 06-12-2007, 11:43 PM
  4. Declare an array in the BSS segment
    By ^xor in forum C Programming
    Replies: 1
    Last Post: 05-27-2005, 05:12 PM
  5. LISP (DrScheme) any one?
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-31-2004, 12:52 PM