Bloomberg LP Interview Question
Software Engineer / DevelopersTeam: Price history
Country: United States
Interview Type: In-Person
Let us first understand the structure of a process. A process contains text section which contains the program code, a data section that contains global variables, Heap ,which is memory that is dynamically allocated during process runtime and a process stack which contains temporary data like function parameters ,return addressand local variables.
Now although two process may be associated with the same program they are always two separate execution. Text sections(program code) will be same but data,heap,stack section may vary.
No memory will be shared even if we run the same program twice. process and programs are different. whenever a process completes, the cpu will release its resources (includes memory) and remove another process from queue which might get the memory of the previous process. it depends on policy of cpu(e.g. LRU etc). i am not sure what you mean by text portion of memory
The text segment contains machine instructions and is read-only and shared by concurrent instances of the same process. The physical memory would not be shared (re-used?) if a process starts up and then closes down since the original physical memory could be reallocated to any task between the first process shutting down and the second starting up.
The physical pages associated with shared libraries and the text segment are mapped into the virtual address space of both processes. Pages that are copy-on-write, until modified. Plus, any explicitly shared memory segments as well - mmap().
- yeah... September 30, 2014