Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / parsim / cidealsimulationprot.h @ e1750c09

History | View | Annotate | Download (2.7 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  CIDEALSIMULATIONPROT.H - part of
3
//
4
//                  OMNeT++/OMNEST
5
//           Discrete System Simulation in C++
6
//
7
//  Author: Andras Varga, 2003
8
//          Dept. of Electrical and Computer Systems Engineering,
9
//          Monash University, Melbourne, Australia
10
//
11
//=========================================================================
12
13
/*--------------------------------------------------------------*
14
  Copyright (C) 2003-2008 Andras Varga
15
  Copyright (C) 2006-2008 OpenSim Ltd.
16

17
  This file is distributed WITHOUT ANY WARRANTY. See the file
18
  `license' for details on this and other legal matters.
19
*--------------------------------------------------------------*/
20
21
#ifndef __CIDEALSIMULATIONPROT_H__
22
#define __CIDEALSIMULATIONPROT_H__
23
24
#include "cparsimprotocolbase.h"
25
26
NAMESPACE_BEGIN
27
28
// forward declarations
29
class cCommBuffer;
30
31
/**
32
 * Implements the Ideal Simulation Protocol, described in the paper
33
 * "Performance Evaluation of Conservative Algoritms in Parallel
34
 * Simulation Languages" by Bagrodia et al.
35

36
 * This is not a real synchronization protocol, but rather a research
37
 * tool to measure efficiency of other synchonization protocols like
38
 * the null message algorithm.
39
 *
40
 * @ingroup Parsim
41
 */
42
class SIM_API cIdealSimulationProtocol : public cParsimProtocolBase
43
{
44
  public:
45
    // stores one external event, as needed for the ISP algorithm
46
    struct ExternalEvent {
47
        simtime_t t;    // time of event
48
        int srcProcId;  // origin of event
49
    };
50
51
  protected:
52
    bool debug;
53
    FILE *fin;  // the event log file
54
    ExternalEvent nextExternalEvent; // holds the next event
55
56
    // preloaded table of event times
57
    ExternalEvent *table; // array to hold values
58
    int tableSize;        // allocated size of table
59
    int numItems;         // num in items in table (numItems<tableSize possible)
60
    int nextPos;          // position of 1st unused item in table
61
62
  protected:
63
    // process cMessages received from other partitions; see same method in2
64
    // cISPEventLogger for more explanation
65
    virtual void processReceivedMessage(cMessage *msg, int destModuleId, int destGateId, int sourceProcId);
66
67
    // read an event from event log file
68
    virtual void readNextRecordedEvent();
69
70
  public:
71
    /**
72
     * Constructor.
73
     */
74
    cIdealSimulationProtocol();
75
76
    /**
77
     * Destructor.
78
     */
79
    virtual ~cIdealSimulationProtocol();
80
81
    /**
82
     * Called at the beginning of a simulation run.
83
     */
84
    virtual void startRun();
85
86
    /**
87
     * Called at the end of a simulation run.
88
     */
89
    virtual void endRun();
90
91
    /**
92
     * Scheduler function.
93
     */
94
    virtual cMessage *getNextEvent();
95
};
96
97
NAMESPACE_END
98
99
100
#endif