After thinking about the concept of shared memory, the question arose:
can two processes share the same shared memory segment? can two threads share the same shared memory?
Thinking about this a little more clearly, I am pretty sure that two processes can share the same shared memory segment, where the first is the father and the second is the son that was created using fork(), but what about the two threads?
fork()
thank
can two processes share the same shared memory segment?
. , , "copy- on-write" . , , , , , . , , .
, . - , , , , .
. , -. , .
?
. , "" . , .
, /. .
, ! , , , . , , , segFault/AV, , UB, .
, . , , - IPC ( ).
, , , , , ( -, , ).
, , ( , ). , , . ( " " VAX/VMS - ). . // (, /), , , , .
Within a process, each thread has access to the exact same memory space as all other threads in the same process. The only thing a thread has is unique to itself is the "execution context", of which its stack is a part (although nothing prevents one thread from accessing or manipulating the stack "belonging" to another thread of the same process).