In both the cases, OS responsibility to share the memory between the processes running in them, this will be achieved by allocating different memory for each, will be handled in MMU(Virtual address space). If the memory is shred between two threads, then it's the responsibility of the programmer synchronize