正在加载图片...
5.3.2 Two Uses of Semaphores(8/18 ·2. Synchronization Enforcing some order between threads Semaphore usually has an initial value of o semaphore wait_left=0; wait left=0→1 semaphore wait_ right =0; wait right =0 Left_ Paw(t Right_ Paw( i slide_ left(; P(wait left) v(wait left); slide_lefto; P(wait_ right); slide- right( slide- right(; W(wait_ right);5.3.2 Two Uses of Semaphores(8/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_left = 0→1 wait_right = 0
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有