操作系统之进程同步
来源:互联网 发布:java 图片透明度处理 编辑:程序博客网 时间:2024/05/16 23:56
1.不行
if (!lock) {
if (!lock) {
lock = true;
// critical section
lock = false;
}
Context switch after the
testing and before the
locking
2.不行,直接跳过了了某一个的临界区
Lock before testing? How?
lockA = true; lockB = true;
if (!lockB) { if (!lockA) {
// critical section // critical section
} }
lockA = false; lockB = false;
Context switch after the locking and before the testing
3 不行
Lock before testing? How?
lockA = true; lockB = true;
while (lockB); //X if (!lockA) { //Y
// critical section /* critical section */}
lockA = false; lockB = false;
It works!
at X: if B is not locked, enter CS; otherwise wait;
at Y: if A is not locked, enter CS; otherwise leave
Not symmetric!
4 可以
Peterson’s algorithm
while (true) {
lock[i] = true;
turn = j;
while (lock[j] && turn == j);
// critical section
lock[i] = false;
// remain section
}
It works, but rathercomplicated!
- 操作系统之进程同步
- 操作系统之进程同步
- 操作系统之进程同步
- 操作系统之进程同步
- 操作系统之进程同步
- 操作系统之进程同步
- 操作系统实验四之进程同步实验
- 操作系统原理读书笔记之进程同步
- 操作系统之经典进程同步问题
- 计算机操作系统笔记(4)--进程管理之进程同步
- 操作系统进程同步问题
- 操作系统--进程同步
- 操作系统中的进程同步
- 进程同步(操作系统)
- 【操作系统原理】进程同步
- 操作系统 进程同步
- 进程同步(操作系统)
- 2.学习操作系统之进程控制与同步
- sgu 230
- Android开发中执行方法中含有监听时的处理
- 另外一篇关于Linux库的文章(静态库,动态库)
- HDU 2940 Hex Factorial (简单高精度)
- OJ输出日期时间--友元类
- 操作系统之进程同步
- Struts2(六)手工编码方式进行输入校验
- POJ 1260 && HDU 1300 Pearls(dp)
- leetcode Longest Valid Parentheses
- 黑马程序员--Java学习日记之基础知识(数据类型和运算符)
- html 与用户互动
- HDU 2424-Gary's Calculator
- iOS UIBezierPath类 介绍
- OJ比较大小-类模板