SoOSiM-0.2.1.0: Abstract full system simulator

Safe HaskellNone

SoOSiM.Types

Contents

Synopsis

SoOSiM API Types

class ComponentInterface s whereSource

Type class that defines an OS component

Associated Types

type Send s Source

Type of messages send by the component

type Receive s Source

Type of messages received by the component

type State s Source

Type of internal state of the component

Methods

initState :: s -> State sSource

The minimal internal state of your component

componentName :: s -> ComponentNameSource

A function returning the unique global name of your component

componentBehaviour :: s -> State s -> Input (Receive s) -> Sim (State s)Source

The function defining the behaviour of your component

Instances

ComponentInterface HandlerStub 

newtype Sim a Source

The simulator monad used by the OS components offers resumable computations in the form of coroutines. These resumable computations expect a value of type Dynamic, and return a value of type a.

We need resumable computations to simulate synchronous messaging between two components. When a component synchronously sends a message to another component, we store the rest of the computation as part of the execution context in the simulator state. When a message is send back, the stored computation will continue with the message content (of type Dynamic).

To suspend a computation you simply do: 'request componentId'

Where the componentId is the ID of the OS component you are expecting a message from. The execute a resumeable computation you simply do: 'resume comp'

Constructors

Sim 

Fields

runSim :: SimInternal a
 

Instances

data Input a Source

Events send to components by the simulator

Constructors

Message a ReturnAddress

A message send another component: the field argument is the ComponentId of the sender, the second field the message content

Tick

Event send every simulation round

Instances

Show (Input a) 

newtype ReturnAddress Source

Constructors

RA 

type ComponentId = UniqueSource

type NodeId = UniqueSource

SoOSiM Internal Types

data ComponentContext Source

Context of a running component in the simulator.

We need existential types because we need to make a single collection of several component contexts, each having their own type representing their internal state.

Constructors

forall s . (ComponentInterface s, Typeable (Receive s)) => CC 

Fields

componentIface :: s

Interface type

componentId :: ComponentId

ComponentId of this component

creator :: ComponentId

ComponentId of the component that created this component

currentStatus :: TVar (ComponentStatus s)

Status of the component

componentState :: TVar (State s)

State internal to the component

msgBuffer :: TVar [Input Dynamic]

Message waiting to be processed by the component

traceMsgs :: [String]

Trace message buffer

simMetaData :: TVar SimMetaData

Statistical information regarding a component

data ComponentStatus a Source

Status of a running component

Constructors

ReadyToIdle

Component is doing nothing

WaitingFor ComponentId (() -> Sim (State a))

Component is waiting for a message from ComponentId, will continue with computation ('(' -> SimM a) once received

ReadyToRun

Component is busy doing computations

Killed

Module scheduled for deletion

data RequestOrYield request response x Source

Constructors

Request request (response -> x) 
Yield x 
Kill 

data Node Source

Nodes represent computing entities in the simulator, and host the OS components and application threads

Constructors

Node 

Fields

nodeId :: NodeId

Globally Unique ID of the node

nodeInfo :: NodeInfo

Meta-data describing the node

nodeComponentLookup :: Map ComponentName ComponentId

Lookup table of OS components running on the node, key: the ComponentName, value: unique ComponentId

nodeComponents :: IntMap ComponentContext

Map of component contexts, key is the ComponentId

nodeMemory :: IntMap Dynamic

Node-local memory

nodeComponentOrder :: [ComponentId]
 

data SimMetaData Source

Constructors

SimMetaData 

Fields

cyclesRunning :: Int
 
cyclesWaiting :: Int
 
cyclesIdling :: Int
 
msgsReceived :: Map ComponentId Int

Key: senderId; Value: number of messages

msgsSend :: Map ComponentId Int

Key: receiverId: Value: number of messages

type SimMonad = StateT SimState STMSource

The internal monad of the simulator is currently a simple state-monad wrapping STM

data SimState Source

The internal simulator state

Constructors

SimState 

Fields

currentComponent :: ComponentId

The ComponentId of the component currently under evaluation

currentNode :: NodeId

The NodeId of the node containing the component currently under evaluation

nodes :: IntMap Node

The set of nodes comprising the entire system

uniqueSupply :: Supply

Unlimited supply of unique values

data NodeInfo Source

Meta-data describing the functionaly of the computing node, currently just a singleton type.

Constructors

NodeInfo