0
$\begingroup$

This semester we have a class related to Operating Systems.The class itself is not obligatory but the class is done at the same time with a core class and I will simply not waste a year for 1 class so I have decided to access the resources of the Operating Systems class and study on my own.

A process is any program loaded into the main memory currently being executed or which awaits execution.Any process is made of :the code where the instructions are stored , the call stack and the data field.However what exactly is the data field.After a brief search the data field stores any process related data(input or output) so I guess it stores any parameters or temporary variables used by the process?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

"Data field" is not the usual term. The usual term that we use is "segment".

There are essentially five kinds of "data" that a process can use:

  • Stack. You know what the stack is: it's memory that is implicitly or explicitly allocated by the program as calls occur. This can be a little more complex in its detail than some textbooks would have you believe, because of multithreading, but let's not get into that.
  • Heap. This is memory that is explicitly allocated by the program using system calls. You probably know what heap is.
  • Read-only data. This is data (i.e. not executable code) that is loaded from the executable file, and cannot be modified by the program. Examples include static strings, run-time type information, and virtual function dispatch tables.
  • Read-write data. This is data that is loaded from the executable file, but can be modified by the program. This is, typically, initialised global variables.
  • BSS. This is an archaic term, but it's stuck. It means data that can be modified by the program, but doesn't need to be stored in the executable file because it is initialised to zero bytes. This is, typically, uninitialised global variables.

So, in summary:

  • Read-only data is loaded from the executable file, and is typically mapped by a modern operating system as being read-only and non-executable. Different instances of the same program can share these pages.
  • Read-write data is loaded from the executable file, and is typically mapped by a modern operating system as being read-write and non-executable. Different instances of the same program might share these pages, if they are copy-on-write.
  • BSS data is not loaded from the executable file, and is typically mapped by a modern operating system as zero-fill pages.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.