Process Synchronization
Chapter 6 Process Synchronization 6.1 Background 6.1.1 Shared resources Def:
the resources (e.g., data, CPU, I/O ports, memory) that can be accessed by several cooperating processes concurrently the shared resources cannot be used by several processes simultaneously (or in parallel), only be used mutual exclusively(互斥) 信号量的三种用法:
资源互斥使用:资源只有1个实例,各个进程通过二元信号量mutex互斥地进入临界区,使用资源。 Mutex:代表资源的控制权,初值为1。 mutex = 1:buffer空闲 mutex = 0:buffer阻塞 资源竞争使用: 资源有多个实例,允许多个进程竞争使用资源。 多元信号量表示:(1)资源可用数目,(2)资源使用权 e.g. empty, full 进程间同步: 进程间的执行步骤需要有先后顺序关系 同步二元信号sync,初值为0 sync = 0:未开始跑 sync = 1:前面进程跑完 6.