7.7.4 sg::SchedulerRunnable class

This section describes the SchedulerRunnable class.

sg::SchedulerRunnable - about

This class is a thread interface on the runnable side. The modeling components create and implement SchedulerRunnable objects and pass a pointer to a SchedulerRunnable interface to SchedulerInterfaceForComponents::createThread(). The scheduler uses this interface to run the thread.

sg::SchedulerRunnable::breakQuantum

This function breaks the quantum. ARM deprecates this v0 function.

sg::SchedulerRunnable::clearStopRequest

This function clears stop request flags.

void clearStopRequest();

Only SchedulerInterfaceForComponents::stopAcknowledge() calls this function, so calls are always from the simulation thread.

sg::SchedulerRunnable::getName

This function returns the name of the instance that owns the object.

const char *getName() const;

By convention, this is the name that createThread() received. SchedulerRunnable inherits this function from sg::SchedulerObject.

sg::SchedulerRunnable::setThreadProperty, sg::SchedulerRunnable::getThreadProperty

These functions set and get thread properties.

bool setThreadProperty(ThreadProperty property, uint64_t value);
bool getThreadProperty(ThreadProperty property, uint64_t &valueOut);
Scheduler-configures-runnable properties
TP_BREAK_QUANTUM
ARM deprecates this property. SchedulerInterfaceForComponents::getNextSyncPoint() gives the next quantum size.
TP_DEFAULT_QUANTUM_SIZE
ARM deprecates this property. Use SchedulerInterfaceForComponents::set/getGlobalQuantum().
TP_COMPILER_LATENCY
set
Compiler latency, the maximum interval in which generated straight-line code checks for signals and the end of the quantum.
get
Compiler latency.
default
1024 instructions.
TP_MIN_SYNC_LATENCY
set
Synchronization latency, the minimum interval in which generated straight-line code inserts synchronization points.
get
Synchronization latency.
default
64 instructions.
TP_MIN_SYNC_LEVEL
set
syncLevel to at least N (0-3).
get
Minimum syncLevel.
default
min_sync_level CADI parameter and the syncLevel* registers also determine the syncLevel. If nothing else is set, the default is 0 (SL_OFF).
TP_LOCAL_TIME
set
Local time of temporally decoupled thread.
get
Current local time.
TP_LOCAL_QUANTUM
set
Local quantum of temporally decoupled thread.
get
Current local quantum.

Note:

The temporally decoupled thread usually retrieves the local quantum by calling SchedulerInterfaceForComponents::getNextSyncPoint().
Runnable-configures-scheduler properties
TP_STACK_SIZE
set
Return false and ignore the value. Not for a scheduler to call.
get
Intended stack size for the thread in bytes. If this field returns false or a low value, this field uses the default stack size that the scheduler determines. Not all schedulers use this field. If a scheduler supports setting the stack size, it requests this field from SchedulerInterfaceForComponents::createThread() or SchedulerThread::start(). Is to return a constant value.
default
2MB.

Schedulers need not use all fields, and runnable objects need not provide all fields. If a runnable object does not support a property or value, it must return false.

sg::SchedulerRunnable::stopRequest

This function requests the simulation of the whole system to stop (pause) as soon as possible by setting a request flag. This might be to inspect a runnable, for example to pause at an instruction boundary to inspect a processor component with a debugger.

bool stopRequest();

You can call this function from any host thread, whether the simulation is running or not. The function returns immediately, before the simulation stops. This function will not block the caller until the simulation stops. The simulation stops as soon as possible, depending on the syncLevel of the runnable.The simulation calls the function SchedulerInterfaceForComponents::stopAcknowledge(), which blocks the simulation thread to pause the simulation. The function must not call stopAcknowledge() directly but only set up a state such that the simulation stops at the next sync point, defined by the syncLevel of this runnable. Reset this state with stopAcknowledge(), which calls clearStopRequest().

Modeling components use this function to stop the simulation from within the simulation thread (for example for external breakpoints) and also asynchronously from from the debugger thread. Calling this function again (from any host thread) before stopAcknowledge() has reset the stop request using clearStopRequest() is harmless. The simulation only stops once.

Returns true when the runnable accepts the stop request and will stop later. Returns false when the runnable does not accept the stop request. In this case, the scheduler must stop the simulation when the runnable returns control to the scheduler (for example, by use of wait()).

sg::SchedulerRunnable::threadProc

This is the main thread function, the thread entry point.

void threadProc();

When threadProc() returns, the thread no longer runs and this SchedulerThread instance will not call threadProc() again. The thread usually does not return from this function while the thread is running.

threadProc() is to call SchedulerInterfaceForComponents::wait(0, ...) after completing initialization. threadProc() is to call SchedulerInterfaceForComponents::wait(t>=0, ...) after completing t ticks worth of work.

Do not create/destroy any other threads or scheduler objects within the context of this function.

Non-ConfidentialPDF file icon PDF versionARM 100965_1101_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.