top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why there is two part of data section (UnInitialized and Initialized) ??

+8 votes
584 views
Why there is two part of data section (UnInitialized and Initialized) ??
posted Oct 1, 2013 by Vikas Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes

Data section occupy the space of virtual address space of a process. All the global variables stored in data section. Some of the global variable initialized, some may not and some of them might be constant.
So data is divided into two category - initialized and uninitialized.
Constant variable must be initialized at the time of variable definition and they goes to initialized section.
Those data which can be modified during run time , we can leave it as uninitialized until and unless it is really required to initialize them with a particular value (eg. sometime global static need to initialize)

answer Oct 1, 2013 by Vimal Kumar Mishra
+2 votes

In a process we have two section bss and data, global and static variables are stored in the data segment, and uninitialized data are in the bss segment.
The .bss segment is an optimization. The entire .bss segment is described by a single number, probably 4 bytes or 8 bytes, that gives its size in the running process, whereas the .data section is as big as the sum of sizes of the initialized variables. Thus, the .bss makes the executables smaller and quicker to load.
I hope this clarifies the doubt.

answer Oct 1, 2013 by anonymous
Similar Questions
+5 votes

What is structure padding and how it is used at processor level?

+3 votes

What is the difference between Pipe and FIFO?

...