Unix/Linux OS/how stack memory is allocated for a process
stack memory allocated for a process is different where as heap is the common for all processes in multiprocessing environment.is this true?if so is there any chance of exhausting of stack memory during run time?who decides how much stack memory ll be allocated to a process?is there any link of these two types of memory with virtual memory.?
1. Well, not really. Unless you mean "thread", when you say "process". Each process has its own memory blocks/segments/sections: stack, heap, text. All threads of one process share heap and can access each other's stacks.
2. Of course. No memory is infinite, stack included.
3. Initial allocation and expansion of allocated memory are done by the OS. EXE (or ELF) file, containing the runtime of the process, can contain hints and requirements for the memory sizes, but in the end it is the job of process loader to request memory allocation from the memory manager of OS.
4. Virtual Memory is a term used to explain how modern OSes, supported by modern hardware manage memory of a process. It allows process to have a unified chunk of memory, which may actually be swapped out to disk. Stack, heap and text live inside that block and process will not know which parts are actually swapped out.