-1

Can some body help, does all segments belongs to process are contiguous in the memory? if yes then why those should be in contiguous?.

as per my understanding stack comes down and heap grows up(depends on CPU architecture) that shows all segments lay one by one(tightly coupled).

Joe
  • 41,484
  • 20
  • 104
  • 125
user2927486
  • 111
  • 2
  • 8
  • they are contiguous, read here http://cs-fundamentals.com/c-programming/memory-layout-of-c-program-code-data-segments.php – Haris Oct 13 '14 at 15:32
  • 1
    You might want to do a search on the memory architecture of your hardware and OS of interest. For example, on Windows memory is not physically contiguous, per se. However, the virtual memory system makes it look contiguous to processes. This might be different on other OS's and architectures. – rashmatash Oct 13 '14 at 15:34

2 Answers2

0
  1. Segments themselves are architecturally dependent. Few processors other than Intel use segments. In addition, there are no segments in 64-bit mode on Intel processors.

  2. If you are on an intel processor, not-64-bit-mode, the segments are virtually contiguous. The heap does not interleaves with the code. However, their may be discontinuities in the virtual memory within a segment in systems that support that.The segments do not have to be contiguous with each other.

  3. If you are running on a system without segments, the code, heap, and data can be interleaves. However, each stack must be contiguous.

user3344003
  • 20,574
  • 3
  • 26
  • 62
0

On x86 in virtual memory yes they are contiguous from processes point of view but the portions of these segments can be mapped to any random physical memory portions.

anurag-jain
  • 1,380
  • 2
  • 11
  • 31
  • Anyurag, thanks for the reply. why they suppose to be contiguous is there any reason behind this? – user2927486 Oct 13 '14 at 15:58
  • My reason would be if its continuous you can jump from one segment to another with just one start address and respective offsets easily without maintaining any look up tables. That was the reason paging was introduced and virtual memory was introduced in first place. In virtual memory, a process thinks that it can access all the memory available in the system, but in reality can access limited number of pages backing portions its virtual address space with physical memory pieces which may not be contiguous. I'd suggest a CS Operating system course to gain deeper understanding. – anurag-jain Oct 13 '14 at 16:59