正在加载图片...
7.Consider the analogy of a tunnel with only a single lane.To avoid a deadlock,cars must be prevented from entering the tunnel at both ends simultaneously.Once a car enters,other cars from the same direction may follow immediately.Ignoring the problem of starvation,write the code using semaphores to solve this problem. (a)Define the semaphores and set their initial values: (b)Implement the functions by filling the blanks. North({ if Enter Tunnel; if( SouthO{ /*Same with the North()*/ 7.The following diagrams show portions of several data structures of a file system.Each entry of the directory contains the symbolic name of a file,together with the index node number of the file. A卷总8_页第_6页A 卷 总 8 页 第 6 页 7. Consider the analogy of a tunnel with only a single lane. To avoid a deadlock, cars must be prevented from entering the tunnel at both ends simultaneously. Once a car enters, other cars from the same direction may follow immediately. Ignoring the problem of starvation, write the code using semaphores to solve this problem. (a)Define the semaphores and set their initial values: (b) Implement the functions by filling the blanks. North() { ___________________; ___________________; if (_____________________) _______________________; ____________________; Enter Tunnel; _____________________; _____________________; if (_____________________________) ___________________; _______________________________; } South(){ /*Same with the North() */ } 7. The following diagrams show portions of several data structures of a file system. Each entry of the directory contains the symbolic name of a file, together with the index node number of the file
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有