CrazyEngineers
  • Each process is given a memory space like so :
    rfdfgdf
    When a process creates another process, the child process is given a memory space of its own too, but where? is it inside the memory space allocated to the parent or outside it? and if it's inside the parent's memory space, does it mean that the child shares a part (or the whole) of the parent's memory space with the parent?
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Nayan Goenka

    MemberAug 8, 2013

    When your child process was defined, it was already allocated some memory while compiling the code for the first time. So that comes into role. However if a process invokes another one, and in a loop, that is multiple times, then it will check if the child process is independent or dependent. If the child process is actually another module, it will have its private working like other processes. But if it is completely dependent on your main process, then it will acquire memory within the boundary or stack of main process and register itself as primary allocated memory for main process. So it all depends on type of process for which it takes corresponding memory location.
    Are you sure? This action cannot be undone.
    Cancel
  • rukawa

    MemberAug 8, 2013

    Nayan Goenka
    When your child process was defined, it was already allocated some memory while compiling the code for the first time. So that comes into role. However if a process invokes another one, and in a loop, that is multiple times, then it will check if the child process is independent or dependent. If the child process is actually another module, it will have its private working like other processes. But if it is completely dependent on your main process, then it will acquire memory within the boundary or stack of main process and register itself as primary allocated memory for main process. So it all depends on type of process for which it takes corresponding memory location.

    Say for example the child is completely dependant on the parent (I think this means that the child does exactly the same work as the parent), does it mean that all its memory space will be within the boundaries of the parent's memory space?
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberAug 9, 2013

    rukawa
    Say for example the child is completely dependant on the parent (I think this means that the child does exactly the same work as the parent), does it mean that all its memory space will be within the boundaries of the parent's memory space?


    Yes. While compiling itself the main program will have reserved some space for the child program. And apart from that, you cannot put a program into infinite loop. So there is some boundary. And the main program analyses it and allocated proper amount of memory beforehand. If the program uses linked list, then it is simpler. It goes into any memory block alloted and the main program keeps track of its pointer.
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberAug 9, 2013

    does it mean that all its memory space will be within the boundaries of the parent's memory space?
    YES.
    I don't think it is a complex scenario.
    When a process needs more memory (or say created a child process), system allocate this memory dynamically.
    If you watch closely running browser for long time it is consuming more and more memory. while webpages you are Login in are completely untouched by other browser sessions.

    One more basic example is Arraylist which grows dynamically when you add more elements.
    Are you sure? This action cannot be undone.
    Cancel
  • rukawa

    MemberAug 9, 2013

    Thank you for your answers. Say now the child is independent from the parent, like the shell for example, it creates a process in order to execute the command typed by the user and prints the output when the child is done. Does the child in this case have a bit of memory space that is out of the boundaries of the parent's own memory space?
    And what happens if the parent dies and leaves an orphan?
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberAug 9, 2013

    If the parent dies and leaves the child an orphan, You child program is useless. It wont run itself since it is invoked by the parent program. So no question of memory usage.

    All memory of a program executing has a confined block of usage. In case of iterative programs and functions, the main program maintains a record of the pointer. So nothing escapes.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register