📄 main.cpp
字号:
/////////////////////////////////////////////////////////////////////
// Quantum Dining Philosophers Win32 version
// Copyright (c) 2002 Miro Samek, Palo Alto, CA.
// All Rights Reserved.
/////////////////////////////////////////////////////////////////////
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include "qassert.h"
#include "port.h"
DEFINE_THIS_FILE;
int astack[N + 1][1024];
static Table aTable;
static Philosopher aPhil[N] = { 0, 1, 2, 3, 4 };
static QEvent *tableQueueSto[N];
static QEvent *philQueueSto[N][N];
static TableEvt regPoolSto[N*N];
static QSubscrList subscrSto[MAX_SIG];
extern "C" void onAssert__(char const *file, unsigned line) {
fprintf(stderr, "Assertion failed in %s, line %d", file, line);
exit(-1);
}
extern "C" void timer5_Init();
int main()
{
QF::init(subscrSto, MAX_SIG);
QF::poolInit(regPoolSto, DIM(regPoolSto), sizeof(TableEvt));
for (unsigned n = 0; n < N; ++n) {
aPhil[n].start( n+1, philQueueSto[n], DIM(philQueueSto[n]),
astack[n+ 1] , 1024);
}
aTable.start(6, tableQueueSto, DIM(tableQueueSto), astack[N+ 1] , 1023);
timer5_Init();
OSStart();
QF::cleanup();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -