正在加载图片...
} 进程:writer-写者进程,reader-读者进程 reader~(读者进程): while (true) bulletin.enter(); bulletin.start_read(); read(); bulletin.end_read(); bulletin.leave(); } writer-(写者进程): { while (true) bulletin.enter(); bulletin.start write(); write(); bulletin.end_write(); bulletin.leave(); 3.哲学家问题 问题描述:(见信号量部分) 解答: 管程:dining=MODULE: (假设已实现一基本管程monitor,提供enter,.leave,,signal,wait等操作) queue:array [0..4]of condition; 一控制哲学家能否进食: fork:array[0..4]of (free,use); 一当前各个叉子的状态 define pickup,test,putdown; use monitor.enter,monitor.leave,monitor.wait,monitor.signal;} 进程:writer - 写者进程,reader - 读者进程 reader - (读者进程): { while (true) { bulletin.enter(); bulletin.start_read(); read(); bulletin.end_read(); bulletin.leave(); } } writer - (写者进程): { while (true) { bulletin.enter(); bulletin.start_write(); write(); bulletin.end_write(); bulletin.leave(); } } -------------------------------------------------------------------------------- 3. 哲学家问题 问题描述:(见信号量部分) 解答: 管程:dining=MODULE; (假设已实现一基本管程 monitor,提供 enter,leave,signal,wait 等操作) queue:array [0..4] of condition; — 控制哲学家能否进食; fork:array[0..4] of (free,use); — 当前各个叉子的状态 define pickup,test,putdown; use monitor.enter,monitor.leave,monitor.wait,monitor.signal;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有