I have several questions regarding OS, which I'd like to verify:
a. Threads within the same process share the same memory space
b. Process and its child process share the same memory space
c. CPU execute only one thread at a time
d. Processes can communicate through pipes
I think that it is b
, because processes doesn't share the same memory space, every time we create a child process, it duplicated to its own PCB, and different registers.
Although, I understand that in Multi-Core CPU, we actually can run several threads at the same time...
I think that this one is true
because in kernel mode you act like the OS, and then you can access the memory of other processes.
Please help me understand if I was correct.
Thanks!
a. Threads within the same process share the same memory space
Mostly true (for most operating systems for normal usage). No strict requirement for it to be true (e.g. an OS could give each thread its own memory space, where some but not all is the same for different threads belonging to the same process - e.g. as a way to increase the amount of memory a process can use and/or to provide "thread specific storage" that other threads can't access).
Note that some operating systems, and some languages, and some environments, don't define "processes" and/or "threads" the same way as other operating systems/languages/environments. Examples include Erlang (where "process" is used more like "actor" in "actor model"); and Linux (where "process" and "thread" are emulated on top of a configurable "task" by specifying which things tasks do/don't share); and GPUs (which are mostly just CPUs with wider SIMD, where often "thread" is a synonym for "SIMD lane").
b. Process and its child process share the same memory space
Mostly false (for most operating systems for normal usage, but the note above applies). True for some cases (SASOS using managed languages to separate processes, small embedded systems that don't have an MMU, etc).
c. CPU execute only one thread at a time
Sort of true (if you ignore "CPU can execute zero threads", and GPUs).
d. Processes can communicate through pipes
Sort of true. In general there's no requirement for pipes to exist at all (and even if pipes seem like they exist they could just be emulated on top of something else, like message passing, so that it's possible to say processes communicate through something else without knowing it's not pipes).