I have a question actually I didn’t understand something about child and parent processes.When I change a global variable inside child process, these changes don’t effect parent process. I saw a sentence on this web site. It says: “modifying any variables in the parent or child will not see the changes also being made to the other one.” Could you please give more information? Thank you.
I have a question actually I didn’t understand something about child and parent processes.When
Share
I think you are getting confused with the difference between a process and a thread.
A process can contain multiple threads. A process has its own address space and system variables (such as file handles). Processes can only interact through IPC mechanisms, and cannot directly touch another processes variables otherwise. Every process has a PID that the OS uses to identify it (at least in linux). Processes can have many threads running on top of the process.
A thread is a unique construct that can run inside a process. Each thread has its own unique stack pointer (which points to the assembly executing) and unique registry values. When the OS switches between threads, it switches the current line of execution and restores all the resgistry values stored with that thread. However, threads in a process share all the same memory, which is why you can modify global and class variables between threads and they are affected.
If anyone wants to chime in they can. This is just a brief summary of what I think are some of the important points between understanding the difference between processes and threads.