main.cpp

来自「本程序将ucosii移入了QF框架」· C++ 代码 · 共 47 行

CPP
47
字号
/////////////////////////////////////////////////////////////////////
// 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 + =
减小字号Ctrl + -
显示快捷键?