ubuntu - File Access (read/write) synchronization between 'n' processes in Linux -


i studying operating systems semester , wondering how linux handles file access (read/write) synchronization, default implementation use semaphores, mutexes or monitors? , can please tell me find in source codes or own copy of ubuntu , how disable it?

i need disable can check if own implementation of works, how add own implementation system.

here's current plan please tell me if okay:

  1. disable default implementation, add own. (recompile kernel if need be)
  2. my own version keep track of every incoming process , maintain list of files using adn whenever file repeat check if reader process or writer process
  3. i going reader preferred solution readers writers problem.

kernel doesn't impose process synchronization (it should performed processes while kernel provides tools that), can guarantee atomicity on operations: atomic operation can not interrupted , result cannot altered other operation running in parallel.

speaking of writing file, has atomicity guarantees. man -s3 write:

atomic/non-atomic: write atomic if whole amount written in 1 operation not interleaved data other process. useful when there multiple writers sending data single reader. applications need know how large write request can expected performed atomically. maximum called {pipe_buf}. volume of ieee std 1003.1-2001 not whether write requests more {pipe_buf} bytes atomic, requires writes of {pipe_buf} or fewer bytes shall atomic.

some discussion on so: atomicity of write(2) local filesystem.

to maintain atomicity, various kernel routines hold i_mutex mutex of inode. i.e. in generic_file_write_iter():

mutex_lock(&inode->i_mutex); ret = __generic_file_write_iter(iocb, from); mutex_unlock(&inode->i_mutex); 

so other write() calls won't mess call. readers, doesn't lock i_mutex, may invalid data. actual locking readers performed in page cache, page (4096 bytes on x86) minimum amount data guarantees atomicity in kernel.

speaking of recompiling kernel test own implementation, there 2 ways of doing that: download vanilla kernel http://kernel.org/ (or git), patch , build - easy. recompiling ubuntu kernels harder -- require working debian build tools: https://help.ubuntu.com/community/kernel/compile

i'm not clear trying achieve own implementation. if want apply strictier synchronization rules, maybe time @ txos?


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -