信号量的死锁情况,不会翻译
laixintao opened this issue · 2 comments
There's more...
A particular use of semaphores is the mutex. A mutex is nothing but a semaphore with an internal variable initialized to the value 1, which allows the realization of mutual exclusion in access to data and resources.
Semaphores are still commonly used in programming languages that are multithreaded; however, using them you can run into situations of deadlock. For example, there is a deadlock situation created when the thread t1 executes a wait on the semaphore s1, while the t2 thread executes a wait on the semaphore s1, and then t1, and then executes a wait on s2 and t2, and then executes a wait on s1.
应该说的就是线程t1在等待信号量s1,然后会等待信号量s2,然后线程t2会先等待信号量s2,然后再等待信号量s1,这样就会发生死锁。也就是作者说的t1等待s2和t2吧,但是t2在等待s1。
@Microndgt 嗯我觉得这样没问题,就是最后一句 and then executes a wait on s1. 比较迷惑。