file name: general.hpp, general.cpp
classification: simulation
contents: some general enumerations and global functions
use: provides enums and functions that are used in several classes
Note: where the implementation for pure and hardware-based simulation
defers, the implementation can be found in impl_sw.cpp
or impl_hw.cpp.
global items used:
local items used:
const INT32
InterruptMask: for modifying the interrupt mask of the task mode in
functions En-/DisableInterrupts().
enumerations:
enum EAlgorithmType:
FreeRun, FaultTolerantAverage, Midpoint, Fetzer, OP, Marzullo, Rate, FaultTolerantIntersection
All possible clock synchronization algorithms.
enum EArrival:
Early, InTime, Late
All possibilities for message arrivals.
enum EDistribution:
Uniform, Normal, Exponential, Gamma, Weibull, Generic
All possible distribution functions used for drawing random numbers.
enum ENetworkType:
Broadcast
All possible network types.
enum EProbabilityType:
PCrash, PRecover, PEarly, PLate
All accessible probability types for fault injection.
global functions:
EBool CastDice
(double prob): Returns True with the probability prob, False
with probability 1-prob. If prob is not in the interval
[0, 1], an assert fails.
INT32 DisableInterrupts
(): Calls the pSOS function t_mode() to raise the interrupt
level in the task mode to mask out all interrupts. Returns the old value
of the task mode.
void EnableInterrupts
(INT32 tmode): Sets the task mode (only the interrupt bits) to tmode.
Note: normally, the function will be called when leaving a critical
section, and tmode will be the value returned by a former call
to DisableInterrupts().
double GetClockFrequency
(SINT32 nodeID, int area, double frequency): Returns the oscillator
frequency of a clock. The function is called by the simulation controller
whenever a new CSA is created. If no frequency is stored, a default value
(25 MHz) is returned.
Note: the function implementations for pure and hardware-based
simulation differ.
double GetGlobalTime
(): Returns the global time (in seconds).
Note: the function implementations for pure and hardware-based
simulation differ.
void GetPosition
(SMsgPosition *data, SINT32 nodeID, SINT32 networkID): Puts the length
and position of all data that is automatically added to a message by the
network into the appropriate fields of data. If there is no data
stored, the function returns a default, where the additional data is put
in front of the message and has the structure {INT32 area; ti_acx time;};
Note: the function implementations for pure and hardware-based
simulation differ.
double GetSnapshotTime
(): Returns the (global) time of the last snapshot (in seconds).
Note: the function implementations for pure and hardware-based
simulation differ.
void GetTransmitTimestamp
(const CAddr& address, int area, const CClock *clock, STimestamp&
time): The function is needed for measuring transmission delays in
hardware-based simulation. There, whenever a node sends a timestamped message,
it triggers the sampling of the clock value of all remote clocks into a
register dedicated to the node address and area of the sender. Thus, when
the message is received, the difference between the receive timestamp and
this sampled clock value denotes the transmission delay of the message.
Note: the function implementations for pure and hardware-based
simulation differ.
char *itoa
(int value, char *buffer, int radix): Converts the value value
in base radix to a string and writes the result into buffer.
A pointer to the buffer is returned. If radix is less than 2 or
greater than 36, NULL is returned and nothing happens.
Note: the function is available in DOS, but not in Linux and
pSOS. So the implementation is only needed in the latter two operating
systems, i.e., if DOS_SIM is not
defined.
void MakeSystemSnapshot():
Triggers a system snapshot on all clocks.
Note: the function implementations for pure and hardware-based
simulation differ.
void SetClockFrequency
(SINT32 nodeID, int area, double frequency): Stores the oscillator
frequency of a clock. The frequencies of all clocks should be set after
the program is started (when calling the other initialization functions).
Note: the function implementations for pure and hardware-based
simulation differ.
void SetPosition
(const SMsgPosition& data, SINT32 nodeID, SINT32 networkID): Stores
the length and position of all data that is automatically added to a message
by the network.
Note: the function implementations for pure and hardware-based
simulation differ.