高级操作系统高级操作系统 (36).pdf
《高级操作系统高级操作系统 (36).pdf》由会员分享,可在线阅读,更多相关《高级操作系统高级操作系统 (36).pdf(17页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、第 14 讲:Concurrency in OS Kernel第二节:Scalable Concurrency Lock.ResourceReference:”Is Parallel Programming Hard,And,If So,What Can You Do About It?”,Paul McKenney;”C+Concurrency in Action”,ANTHONY WILLIAMS;”CS510-Advanced Topics in Concurrency”,Jonathan Walpole;Adam Belay from MIT PDOS清华大学)第 14 讲Scalab
2、le LockingWhy do we need locking in the kernel?Which problems are we trying to solve?What implementation choices do we have?Is there a one-size-fits-all solution?ticket spinlockGoalCorrectness:Mutual exclusion,Progress,Bounded waitFairnessPerformanceticket spinlockIdea:reserve each threads turn to u
3、se a lockeach thread spins until their turnUse new atomic primitive:fetch-and-add(FAA)Spin while not threads ticket!=turnRelease:Advance to next turn.ticket spinlocktypedefstruct int ticket;int turn;lock_t;void lock_init(lock_t*lock)lock-ticket=0;lock-turn=0;void acquire(lock_t*lock)int myturn=FAA(&
4、lock-ticket);while(lock-turn!=myturn);/spinvoid release(lock_t*lock)lock-turn+=1;ticket spinlockTicket lock time analysisAtomic increment O(1)broadcast messageThen read-only spin,no cost until next releaserelease OP invalidates message sent to all cores,and O(N)findmessages,as they re-readBut fairne
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 高级操作系统高级操作系统 36 高级 操作系统 36
限制150内