A) I know that threads of a process share logical address space . Therefore they share data by default.

B) But if two threads of different processes want to share data ...then there are two options available ...message passing and shared memory

Are the synchronization methods (locks etc.) used for both types of communication? If they are only used for (B) then what about (A)? Two threads of same process can also lead to data inconsistency right ?


Both inter-thread communication (within one process) and inter-process communication can use similar sets of synchronization methods.

I say similar and not the same because inter-tread synchronization is so much more common that operating systems often provide two sets of synchronization methods. One set is optimized for use within one process (e.g. uses only RAM and assumes a single address space for all treads that use it) and one set that is also usable when there is not a single address space (but typically still requires all processes run on the same computer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.