UNIX Semantics

UNIX semantics 把 shared file 視為 single shared image:一個 process 對 open file 的 write,會立即對其他已 open 同一 file 的 processes 可見。

直覺

若 A 和 B 同時 open 同一 file,A 寫入某 offset 後,B 之後讀同一 offset 應看到 A 的資料。Local FS 較容易做到,因為 single kernel / buffer cache 可集中管理 file contents 與 metadata。

File pointer note

某些 UNIX sharing mode 也會共享 current file pointer,例如 fork 後 parent / child 繼承同一 open file description。此時 A 的 read / write 推進 offset,B 下一次 operation 會從新 offset 開始。

Limitation

Immediate visibility 不等於沒有 race。Concurrent writers 的順序仍受 scheduling 影響;若需要嚴格協調,仍要 locks、atomic append、transactions 等。

Distributed FS 很難完整維持 UNIX semantics,因為 clients cache blocks / attributes;每次 write 都同步與 invalidate 其他 clients 成本高。NFS 因 caching / delayed writes 只提供較弱語意。