Shared Memory in Distributed System
It is similar to file system in a way that different processes are sharing pages instead of sending/receiving messages. It means to design a memory that allows processes to use same code as if they were all running over the same operating system/machine.
Page has two state: read, write
For concurrent read of pages. it is OK that many processes have their own copy of page in memory to concurrently access.
However, for concurrent modify/write of pages, it causes inconsistency between processes. Therefore, different approaches are used here.
Invalidate approach:
Like the name suggest, if one process would like to write a page, it should firstly multicast to other server to invalidate their read state. Then it become the owner of a page/file and change the file state to write .
Update approach:
Multiple processes are allowed to have page in write state. On write to a page, a multicast of the value of modification would be sent to all other holder of that page. Therefore, other holders can prevent dirty read and continue reading and writing page.
Update approach is preferable to invalidate approach:
- lots of sharing among processes (or lots of writes concurrently)
- writes are small
- Most operations on pages are reads
- page sizes is large. Other than that, Invalidate approach is a preferred option.
- 本文作者: Yu Wan
- 本文链接: https://cyanh1ll.github.io/2021/01/18/distributed-shared-memory/
- 版权声明: CYANH1LL