⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

消费者

生产者

n位共享
缓冲区

P(mutex)
获取互斥锁

empty

初始为n

mutex

full

初始为0

P(full)
等待数据

V(mutex)
释放互斥锁

V(full)
增加数据

V(empty)
释放空位

P(empty)
获取空位

P操作

P(empty)
等待空位

P(mutex)
获取互斥锁

V(mutex)
释放互斥锁

生产数据

P(full)
获取数据

P(mutex)
获取互斥锁

V(mutex)
释放互斥锁

消费数据

P操作

P操作

V操作

V操作

P操作

V(empty)
增加空位

V(full)
增加数据

V操作

V操作