InterviewSolution
| 1. |
What Are The Different Segments Of A Program? |
|
Answer» Memory Segments: Code segment This PHRASE used to refer to a portion of memory or of an object file that contains executable computer instructions. It is generally readonly segment. Data segment: This is one of the sections of a program in an object file or in memory, which contains the global variables that are INITIALIZED by the programmer. It has a fixed size, since all of the data in this section is set by the programmer before the program is loaded. However, it is not readonly, since the values of the variables can be altered at runtime. .bss: This segment of memory is part of data segment that contains uninitialized data (static variables). These are initialized to 0 and later assigned values during runtime. Stack segment: This segment of memory is a special stack which stores information about the active subroutines of a TASK. It contains the return address to be branched to after a subroutine has finished execution. It contains local variables of the subroutines and the parameters that are passed to those sub routines. HEAP segment: The segment of memory which is used for dynamic memory allocation is known as heap. It is the RESPONSIBILITY of the programmer to deallocate it after its use. Or alternatively it will be garbage collected by the OS. Memory Segments: Code segment This phrase used to refer to a portion of memory or of an object file that contains executable computer instructions. It is generally readonly segment. Data segment: This is one of the sections of a program in an object file or in memory, which contains the global variables that are initialized by the programmer. It has a fixed size, since all of the data in this section is set by the programmer before the program is loaded. However, it is not readonly, since the values of the variables can be altered at runtime. .bss: This segment of memory is part of data segment that contains uninitialized data (static variables). These are initialized to 0 and later assigned values during runtime. Stack segment: This segment of memory is a special stack which stores information about the active subroutines of a task. It contains the return address to be branched to after a subroutine has finished execution. It contains local variables of the subroutines and the parameters that are passed to those sub routines. Heap segment: The segment of memory which is used for dynamic memory allocation is known as heap. It is the responsibility of the programmer to deallocate it after its use. Or alternatively it will be garbage collected by the OS. |
|