- 2
- 0
- 约1.5万字
- 约 43页
- 2018-03-28 发布于浙江
- 举报
[工学]6 Process Synchronization
wangfengyu 2008.9 Wang Fengyu 6. Process Synchronization Course Exercise in Operating System Sep. 26, 2010 Email:wangfengyu@sdu.edu.cn Contents Critical Section Semaphore Monitor Thread Synchronization in Nachos Critical Section Sharing in Concurrent Processes address space shared by concurrent threads in a process shared memory can be arranged and shared by UNIX processes although they do not share address spaces Problems with Shared Variables possible context switch by time-out at end of every instruction Data may become inconsistent if shared variables are updated without proper control. Critical Section example: two threads update a shared variable counter. Thread A Thread B { { . . . . . . counter++; --counter; . . . . . . } } the machine code translated by gcc for MIPS computer Process A Process B . . . . . . lw $2,counter lw $4,counter addu $3,$2,1 addu $5,$4,-1 sw $3,counter sw $5,counter . . . . . . Critical Section With counter=5 initially lw $2,counter addu $3,$2,1 lw $4,counter addu $5,$4,-1 sw $3,counter counter=6 sw $5,counter counter=4 Critical Section Critical Section A high-level language concept and structure to enable one thread to execute the code section while blocking other threads trying to execute it Code section to be executed by at most one process at a time Controlled by entry code for entering exit code after exiting Critical Section Common model of critical section repeat critical section remaining section until false; Critical Section Hardware Solution with Test-and-Set Instruction Test-and-Set instruction: an atomic instruction to do 1. read and return the Boolean value of the lock 2. set the value of the lock to be true Critical Section repeat while Test-and-Set(Lock) do no-op; critical section; Lock = false; remaining section; until false Problem Rely on busy-waiting, which wastes CPU cycles Hard to implement on multi-processor co
您可能关注的文档
- [工学]5 Translation of Sentences 1.ppt
- [工学]4静定刚架2-2012.ppt
- [工学]4非线性规划.ppt
- [工学]5 建设监理规划.ppt
- [工学]5--新7种质量管理工具和方法.ppt
- [工学]5-1通行能力分析.pdf
- [工学]5 频率特性法1203.ppt
- [工学]5-2压力控制阀.pdf
- [工学]5-34刚体的定轴转动.ppt
- [工学]5-3二元系相图.ppt
- 2023年度十大热点人物的素材解读与运用-2024年高考语文作文热点素材积累运用与(全国通用).pdf
- 格力室外机中央空调价格表.pdf
- 2026上半年贵州事业单位联考贵州省交通运输厅招聘84人备考题库完整答案详解.docx
- 2026上半年贵州事业单位联考贵州传媒职业学院招聘12人备考题库附参考答案详解(达标题).docx
- 2026上半年贵州事业单位联考贵州省住房和城乡建设厅招聘16人备考题库含答案详解(培优).docx
- 2026上半年贵州事业单位联考玉屏侗族自治县招聘41人备考题库及答案详解(夺冠系列).docx
- 通信原理实验2数字频带传输系统实验.pdf
- 2026上半年贵州事业单位联考贵州医科大学第二附属医院招聘22人备考题库含答案详解(能力提升).docx
- 2026上海复旦大学计算力学与人工智能交叉研究院(筹)招聘专任研究员2人备考题库完整答案详解.docx
- 2026上半年贵州事业单位联考贵州民族大学招聘52人备考题库附参考答案详解(研优卷).docx
最近下载
- ATW-R3210ATW-T3201盒式发射机ATW-T3202手持式发.PDF VIP
- CoDeSys编程手册范本.doc VIP
- T_SCNA 0001—2024(成人体外膜肺氧合(ECMO)技术护理规范).pdf VIP
- 2024版危重症患儿管饲喂养护理TCNAS 45─2024图文解读学习课件.pptx
- 包裹卡提效策略与实操路径白皮书 - 【私域运营】.pdf VIP
- 汽车制造工艺基础 教学课件 王永伦 汽车制造工艺基础课程教学大纲.pdf VIP
- 2025年无人机驾驶员执照飞行器运行术语术语考试实战演练专题试卷及解析.pdf VIP
- 大学生毕业论文写作教程PPT全套教学课件.pptx VIP
- 《生态环境材料》全套教学课件.ppt
- 2026年吞咽障碍考试题含答案解析.docx VIP
原创力文档

文档评论(0)