正在加载图片...
5.3.2 Two Uses of Semaphores(6/18 ·2. Synchronization Enforcing some order between threads Semaphore usually has an initial value of o semaphore wait_left =0; wait left =0 semaphore wait_ right =0; wait_right =0 Left PawoI Right Paw( i slide_ left( P(wait left) W(wait_left); slide_lefto; P(wait_ right); slide- right( slide- right(; v(wait_right); ait5.3.2 Two Uses of Semaphores(6/18) • 2. Synchronization • Enforcing some order between threads • Semaphore usually has an initial value of 0 * semaphore wait_left = 0; semaphore wait_right = 0; Left_Paw() { Right_Paw() { slide_left(); P(wait_left); V(wait_left); slide_left(); P(wait_right); slide_right(); slide_right(); V(wait_right); } } wait wait_left = 0 wait_right = 0
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有