A data segment is a portion of virtual address space of a program, which contains the global variables and static variables that are initialized by the programmer. This size of this segment is determined by the values placed there by the programmer before the program was compiled or assembled, and does not change at run-time.

The data segment is read-write, since the values of the variables can be altered at run-time. This is in contrast to the Rodata (constant, read-only data) section, as well as the code segment (also known as the text segment) which is read-only on many architectures.

The PC architecture supports a few basic read-write memory regions in a program namely: Stack, Data and Code. The heap is another region of address space available to a program, from which memory can be dynamically allocated or freed by the operating system in response to system calls such as malloc and free.

Contents

Program memory [link]

The computer program memory is organized into the following:

Data [link]

The data area contains global and static variables used by the program that are explicitly initialized with a value. This segment can be further classified into a read-only area and read-write area. For instance, the string defined by char s[] = "hello world" in C and a C statement like int debug=1 outside the "main" would be stored in initialized read-write area. And a C statement like const char* string = "hello world" makes the string literal "hello world" to be stored in initialized read-only area and the character pointer variable string in initialized read-write area. Ex: both static int i = 10 and global int i = 10 will be stored in the data segment.

BSS [link]

The BSS segment, also known as uninitialized data, starts at the end of the data segment and contains all global variables and static variables that are initialized to zero or do not have explicit initialization in source code. For instance a variable declared static int i; would be contained in the BSS segment.

Heap [link]

The heap area begins at the end of the BSS segment and grows to larger addresses from there. The heap area is managed by malloc, realloc, and free, which may use the brk and sbrk system calls to adjust its size (note that the use of brk/sbrk and a single "heap area" is not required to fulfill the contract of malloc/realloc/free; they may also be implemented using mmap to reserve potentially non-contiguous regions of virtual memory into the process' virtual address space). The heap area is shared by all shared libraries and dynamically loaded modules in a process.

Stack [link]

The stack area traditionally adjoined the heap area and grew the opposite direction; when the stack pointer met the heap pointer, free memory was exhausted. (With modern large address spaces and virtual memory techniques they may be placed almost anywhere, but they still typically grow in opposite directions.)

The stack area contains the program stack, a LIFO structure, typically located in the higher parts of memory. On the standard PC x86 computer architecture it grows toward address zero; on some other architectures it grows the opposite direction. A "stack pointer" register tracks the top of the stack; it is adjusted each time a value is "pushed" onto the stack. The set of values pushed for one function call is termed a "stack frame"; A stack frame consists at minimum of a return address.

References [link]

See also [link]

External links [link]


https://wn.com/Data_segment

Data (disambiguation)

Data is uninterpreted information.

Data or DATA may also refer to:

  • Data (computing), in computer science, often distinguished from code or software
  • Data (Euclid), a book by Euclid
  • Data (moth), a moth genus
  • Data (Star Trek), a fictional android in the Star Trek universe
  • Data URI scheme
  • Design and Technology Academy, a school in San Antonio, Texas, USA
  • Durham Area Transit Authority, the public transit agency serving Durham, North Carolina, USA
  • Data, a character in The Goonies
  • DATA, a diaryltriazine, a class of organic molecules
  • DATA, a non-governmental organization founded by Bono
  • Draughtsmen's and Allied Technicians' Association, a defunct British trade union
  • Data (word), for the word "data" in English
  • Music

  • Data Records, a record label
  • DATA (band), a techno-pop band created by Georg Kajanus
  • DatA, French electro musician
  • Data, British drum and bass musician
  • DATA (band)

    DATA were an electronic music band created in the late 1970s by Georg Kajanus, creator of such bands as Eclection, Sailor and Noir (with Tim Dry of the robotic/music duo Tik and Tok). After the break-up of Sailor in the late 1970s, Kajanus decided to experiment with electronic music and formed DATA, together with vocalists Francesca ("Frankie") and Phillipa ("Phil") Boulter, daughters of British singer John Boulter.

    The classically orientated title track of DATA’s first album, Opera Electronica, was used as the theme music to the short film, Towers of Babel (1981), which was directed by Jonathan Lewis and starred Anna Quayle and Ken Campbell. Towers of Babel was nominated for a BAFTA award in 1982 and won the Silver Hugo Award for Best Short Film at the Chicago International Film Festival of the same year.

    DATA released two more albums, the experimental 2-Time (1983) and the Country & Western-inspired electronica album Elegant Machinery (1985). The title of the last album was the inspiration for the name of Swedish pop synth group, elegant MACHINERY, formerly known as Pole Position.

    Podcasts:

    PLAYLIST TIME:

    Wake Up Dead

    by: Megadeth

    I sneak in my own house
    It's four in the morning
    I had too much to drink
    Said I was out with the boys
    I creep in my bedroom
    I slip into bed,
    I know if I wake her,
    I'll wake up dead
    Chorus:
    I wonder, will she find out,
    About the other, other lover.
    Diana.
    Wake up dead, you die
    Wake up dead, and buried.
    Wake up dead, you die




    ×