歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> Inode 結構:inode synchronization

Inode 結構:inode synchronization

日期:2017/2/27 9:36:56   编辑:更多Linux

就跟super_block結構一樣,Kernel裡的重要結構在修改時,都必須做好synchronization的動作,以免產生race condition,造成系統出錯。因此,當我們要修改某個inode結構時,必須先確定沒有人在使用這個inode才行。這件事是使用semaphore和wait queue來完成的。     strUCt wait_queue *i_wait;     struct semaphore i_sem;     除了這兩個字段之外,新版的Kernel又多加了一個字段叫i_atomic_write,這也是一個semaphore,那它的用途又是什麼呢? 相信如果你用過pipe的話,一定知道當我們寫資料到pipe裡的時候,資料長度必須小於等於PIPE_BUF這個值,所以當寫入的資料小於等於PIPE_BUF時,Kernel要確保寫入的動作是atomic的,因此加了這個字段來做控制。     struct semaphore i_atomic_write;   




Copyright © Linux教程網 All Rights Reserved