⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 MICO2.3.13 corba 环境平台
💻
字号:
This is a more complex example. It implements the Dining Philosophers.If you do not know that scenario, it's simple. Philosophers sit arounda round (circular) table. Between each pair is a fork, so there is anequal number of philosophers and forks. Philosophers think until theybecome hungry, then they need both forks (the one on their left and theone on their right side) in order to eat. Obviously, this can causesome conflicts, because there are not enough forks for all philosophersto eat at the same time.The goal is to implement philosopher components that do not die fromstarvation.The classic deadlock scenario is that if philosophers are programmed topick up the left fork, and then to wait for the right fork to becomeavailable, it can happen that each philosopher picks up its left forkat the same time, so that nobody can eat.To avoid deadlocking, philosophers must sometimes release the fork thatthey are holding if the other fork is not available.However, this can result in the classic livelock scenario, where allphilosophers simultaneously pick up the left fork, recognize that theright one is not available, drop their left fork again, and then thecycle repeats. This is not a deadlock because something is happening,but the philosophers are still starving, hence the word "livelock".In this example, philosophers and forks are components, there is anadditional component for a registration that deals out unique names toeach philosopher. Philosophers have two receptacles for their left andright fork, plus a receptacle for the registration. They publish theircurrent state (forks they hold and how hungry they are) as an event;another Observer component displays these events.The Philosopher component overloads ccm_activate and ccm_passivate tobe notified of its activation. Upon activation, it registers with theMICO Dispatcher to be called regularly. All the interesting work isdone in this Timer callback.There, the philosopher becomes more hungry, then tries to aquire bothforks and eats if he has both. To prevent deadlocks, philosopherssometimes drop one fork if they cannot get the other. To preventlivelocks, each philosopher has its own random metabolic rate.The "client" in this example is more a configurator. It contacts eachhome to create the registration, an observer, the required philosopherand fork instances, and then interconnects them. Once this is done,the client exits, and all components continue to run in theirrespective server.You can start the demo by running ./philo. You may also give a number ofphilosophers on the command line, the default is 3.There is also a more fancy graphical observer, `tkobserver'. It requiresTcl/Tk and must be compiled separately (there's a rule in the Makefilethat you might need to edit for its path names and version numbers). TheThe client checks whether the graphical client is available (by lookingfor an entry in the Naming Service), and if yes, configures it as aconsumer for the philosophers' StatusInfo events.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -