-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
30 lines (28 loc) · 895 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <QCoreApplication>
#include "fork.h"
#include "philosopher.h"
int main(int argc, char *argv[])
{
Philosopher FirstPhilosopher(0);
Philosopher SecondPhilosopher(1);
Philosopher ThirdPhilosopher(2);
Philosopher FourthPhilosopher(3);
Philosopher FifthPhilosopher(4);\
Fork TableForks[5];
for (int i=0;i<5;i++)
{
TableForks[i].Owner=-1;
}
FirstPhilosopher.Distribution(&TableForks[0],&TableForks[1]);
SecondPhilosopher.Distribution(&TableForks[1],&TableForks[2]);
ThirdPhilosopher.Distribution(&TableForks[2],&TableForks[3]);
FourthPhilosopher.Distribution(&TableForks[3],&TableForks[4]);
FifthPhilosopher.Distribution(&TableForks[4],&TableForks[0]);
FirstPhilosopher.start();
SecondPhilosopher.start();
ThirdPhilosopher.start();
FourthPhilosopher.start();
FifthPhilosopher.start();
QCoreApplication a(argc, argv);
return a.exec();
}