• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

J4 ›› 2016, Vol. 38 ›› Issue (02): 269-276.

• 论文 • Previous Articles     Next Articles

Implementation of an algorithm for the
dining philosophers problem 

GAO Sheng,CHEN Yuefeng   

  1. (College of Information,Guangdong Ocean University,Zhanjiang 524088,China)
  • Received:2015-04-29 Revised:2015-07-17 Online:2016-02-25 Published:2016-02-25

Abstract:

Aiming at the dining philosophers problem, a wellknown classical example of the inter process of communication in the operating system field, this paper designs and presents a technical implementation scheme for a representative algorithm. The scheme takes Linux as its supporting platform, and the scheme reflects the characteristics of the concurrent behaviors of philosophers through processes rather than threads. The state of the philosophers and the switch between two states are emulated and controlled by the combination of automatic and random modes, which is a flexible and natural humancomputer interaction mode. Two forms of state monitoring programs are presented, which can express the state of philosophers in a vivid, direct and accurate way. The characterbased monitoring program can be used in both the character terminal and the graphic terminal, and is mainly used for those users who log in the multiuser Linux systems. The animationbased monitoring program is suitable for the desktop Linux users with graphic terminal.

Key words: operating system;process synchronization and mutual exclusion;semaphore;shared memory;dining philosophers problem;state monitoring program