TEMU  4.4
The Terma Emulator
Scheduler.h File Reference
#include <stdint.h>
#include "temu-c/Support/Attributes.h"
Include dependency graph for Scheduler.h:

Go to the source code of this file.

Typedefs

typedef struct temu_TimeSource temu_TimeSource
 
typedef struct temu_Object temu_Object
 
typedef enum temu_ExecutionState temu_ExecutionState
 

Enumerations

enum  temu_ExecutionState { teES_Stopped, teES_Running, teES_Stepping }
 

Functions

TEMU_API void temu_runForSteps (int64_t steps)
 
TEMU_API void temu_runForTime (double secs)
 
TEMU_API void temu_run ()
 
TEMU_API void temu_step (temu_TimeSource *cpu, int steps)
 
TEMU_API void temu_stop ()
 
TEMU_API void temu_asyncStop ()
 
TEMU_API temu_ExecutionState temu_getExecutionState ()
 
TEMU_API unsigned temu_getScheduledProcessorCount ()
 
TEMU_API temu_TimeSourcetemu_getScheduledProcessor (unsigned cpu)
 
TEMU_API void temu_serializeOnNotification (temu_Object *notificationSource, const char *notificationName, double seconds)
 
TEMU_API uint64_t temu_schedulerGetAccumulatedTime ()
 
TEMU_API uint64_t temu_schedulerGetSyncTime (unsigned threadId)
 
TEMU_API uint64_t temu_schedulerGetWaitTime (unsigned threadId)
 
TEMU_API void temu_schedulerSetAffinity (unsigned threadId, int hostCore)
 
TEMU_API int64_t temu_schedulerGetAffinity (unsigned threadId)
 

Typedef Documentation

◆ temu_ExecutionState

◆ temu_Object

typedef struct temu_Object temu_Object

◆ temu_TimeSource

Enumeration Type Documentation

◆ temu_ExecutionState

Enumerator
teES_Stopped 
teES_Running 
teES_Stepping 

Function Documentation

◆ temu_asyncStop()

TEMU_API void temu_asyncStop ( )

Stop the current scheduler

The function returns immediately, before the scheduler has stopped. The function is suitable for use in e.g. signal handlers.

◆ temu_getExecutionState()

TEMU_API temu_ExecutionState temu_getExecutionState ( )

Get the current execution status of TEMU

Returns
Current execution status

◆ temu_getScheduledProcessor()

TEMU_API temu_TimeSource* temu_getScheduledProcessor ( unsigned  cpu)

Get processor in global scheduler

Parameters
cpuProcessor number to get
Returns
Processor pointer as a time source.

◆ temu_getScheduledProcessorCount()

TEMU_API unsigned temu_getScheduledProcessorCount ( )

Get the number of processors in the global scheduler.

Returns
Number of processors in global scheduler.

◆ temu_run()

TEMU_API void temu_run ( )

Run the current scheduler forever

◆ temu_runForSteps()

TEMU_API void temu_runForSteps ( int64_t  steps)

Run the current scheduler for a fixed number of steps

Parameters
stepsTime in steps (in scheduler units).

◆ temu_runForTime()

TEMU_API void temu_runForTime ( double  secs)

Run the current scheduler for a fixed time

Parameters
secsTime in simulated seconds

◆ temu_schedulerGetAccumulatedTime()

TEMU_API uint64_t temu_schedulerGetAccumulatedTime ( )

Experimental function to get the accumulated nanoseconds for the scheduler.

To enable sampling the Scheduler-object's measureTime property must be set.

Returns
Accumulated nanoseconds of which temu_run* functions have run.

◆ temu_schedulerGetAffinity()

TEMU_API int64_t temu_schedulerGetAffinity ( unsigned  threadId)

Experimental function to get the thread affinity for the scheduler.

Parameters
threadIdThread ID starting with 0 to the number of threads set for the scheduler.
Returns
Affinity value, -1 implies not set. Other values indicate HOST CPUID.

◆ temu_schedulerGetSyncTime()

TEMU_API uint64_t temu_schedulerGetSyncTime ( unsigned  threadId)

Experimental function to get the accumulated nanoseconds for the scheduler synchronization.

To enable sampling, the Scheduler-object's measureTime property must be set.

Returns
Accumulated nanoseconds of which synchronisation code was run.

◆ temu_schedulerGetWaitTime()

TEMU_API uint64_t temu_schedulerGetWaitTime ( unsigned  threadId)

Experimental function to get the accumulated nanoseconds for the scheduler barrier waits.

The wait time, includes both the actual barrier and the synchronization time.

So the true wait time is the wait - sync time.

To enable sampling, the Scheduler-object's measureTime property must be set.

Returns
Accumulated nanoseconds of which the wait was run.

◆ temu_schedulerSetAffinity()

TEMU_API void temu_schedulerSetAffinity ( unsigned  threadId,
int  hostCore 
)

Experimental function to set thread affinity for the scheduler.

The function should be called before setting the number of threads, as threads automatically set the affinity if the hostCore is zero or above.

Parameters
threadIdThread ID starting with 0 to the number of threads set for the scheduler.
hostCoreHost core id to bind thread to. Negative to not set affintity.

◆ temu_serializeOnNotification()

TEMU_API void temu_serializeOnNotification ( temu_Object notificationSource,
const char *  notificationName,
double  seconds 
)

Serialize execution for some time when notification is triggered

Parameters
notificationSourceObject emitting notification.
notificationNameName of notification to intercept.
secondsNumber of seconds (simulated time, for which to serialize execution).

◆ temu_step()

TEMU_API void temu_step ( temu_TimeSource cpu,
int  steps 
)

Step a processor in the current scheduler

Note that, the other processors may run if the step exceeds the quanta. The step function currently runs processors in sequence, it is not running processors in parallel. This means that stepping is always deterministic.

Parameters
cpuThe processor to step
stepsThe number of steps or instructions to execute

◆ temu_stop()

TEMU_API void temu_stop ( )

Stop the current scheduler

The function signals the scheduler to stop, and then waits until the scheduler is in the stopped state.