concurrency
Introduction
- 操作系统(OS)的涉及围绕processes and threads的管理展开
- 这些领域的核心就是concurrecy(并行)
- Concurrency涉及以下问题
- communication ampng processes
- sharing ofand cmpeting for resources
- synchronization of the activities
- (…)
- concurrent processes的基础要求
- 与concurrency相关的key term
- atomic operation
- critical secion
- deadlock
- livelock
- mutual exclusion
- race condition
- starvation
Process Interaction
(…)
- competition among process for resource: 如果缺乏交流就会互相竞争资源
- cooperation among processes by sharing: 互相合作确保数据/资源的分配
- cooperation among processes through communication:
Semaphores
- 抽象数据结构,仅能通过不可打断的加减操作进行变动,当semaphore小于0时代表阻塞
Binary semaphore
- 只有1和0两种状态
- 1代表资源空闲
- 0代表资源被占用
concurerency: deadlock and starvation
deadlock
- key elements to handle deadlocks: 没有单一的有效策略可以解决所有的deadlock问题
- prevention
- avoidance
- detection
- resource allocation graphs
- conditions for deadlock
- mutual exclusion
- hold and wait
- no preemption
- circluar wait
- 前三种是充分但不必要的条件