LinuxProgramming

[Linux] file synchronization

mintuchel 2023. 11. 4. 16:16

[Memory-File Synchronization]

secondary storage(HDD SSD)에 있는 파일들을 내 컴퓨터의 physical memory인 RAM에 올려 작업하는 일
file에 single process로 접근할때 쓰인다
목적은 RAM에 올려 작업한게 작업종료하면 secondary storage로 잘 반영시키는 것이다.
text editor, word, DB작업 등이 이에 해당한다.
 
MS_SYNC : file에 모두 다 쓰기 전까지는 return 안함. 작업 다 끝나기 전까지는 다음 코드 진행 안한다는 소리다
MS_ASYNC : synchronization을 background process로 돌림. 다음 코드 진행하면서 동기화함

 


[Interprocess Synchronization]

 
여러 process 간의 상호작용을 다루는 일
process 들의 race condition을 신경써줘야한다.
multi-process, 멀티쓰레드 단에서 작업한다
multi-thread applications, parallel processing, server-client archi가 이에 해당함.

 


[File Mapping Synchronization]

 
1. memory-file synchronization
Q : when are modified pages written to a file? 
A : randlomy. automatically by os. But we can use msync() to force synchronization
 
2. Interprocess synchronization
Q : when are page changes become visible to other processes?
A : immediatly visible to all involed processes