Top Up Prev Next Bottom Contents Index Search

4.2 Class Scheduler

Scheduler objects determine the order of execution of Stars. As a rule, they are created and managed by Targets. Some schedulers, such as those for the SDF domain, completely determine the order of execution of blocks before any blocks are executed; others, such as those for the DE domain, supervise the execution of blocks at run time. The Scheduler class is an abstract base class; you can't have an object of class Scheduler. All schedulers have a pointer to the Target that controls them as well as to a Galaxy. Usually the Galaxy will be the same one that the Target points to, but this is not a requirement. The Scheduler constructor just zeros its target, galaxy pointers. The destructor is virtual and do-nothing.

4.2.1 Scheduler public members

virtual void setGalaxy(Galaxy& g); 
This function sets the galaxy pointer to point to g.

Galaxy* galaxy(); 
This function returns the galaxy pointer.

virtual void setup() = 0; 
This function (in derived classes) sets up the schedule. In compile-time schedulers such as those for SDF, a complete schedule is computed; others may do little more than minimal checks.

virtual void setStopTime(double limit)  =  0; 
Set the stop time for the scheduler. Schedulers have an abstract notion of time; this determines how long the scheduler will run for.

virtual double getStopTime() = 0; 
Retrieve the stop time.

virtual void resetStopTime(double limit); 
Reset the stopping condition for the wormhole containing this Scheduler. The default implementation simply calls setStopTime with the same argument. For some derived types of schedulers, additional actions will be performed as well by derived Scheduler classes.

virtual int run() = 0; 
Run the scheduler until the stop time is reached, an error condition occurs, or it stops for some other reason.

virtual void setCurrentTime(double val); 
Set the current time for the scheduler.

virtual StringList displaySchedule(); 
Return the schedule if this makes sense.

double now() const; 
Return the current time (the value of the protected member currentTime).

int stopBeforeDeadlocked() const; 
Return the value of the stopBeforeDeadFlag protected member. It is set in timed domains to indicate that a scheduler inside a wormhole was suspended even though it had more work to do.

virtual const char* domain() const; 
Return the domain for this scheduler. This method is no longer used and will be removed from future releases; it dates back to the days in which a given scheduler could only be used in one domain.

void setTarget(Target& t); 
Set the target pointer to point to t.

Target& target (); 
Return the target.

virtual void compileRun(); 
Call code-generation functions in the Target to generate code for a run. In the base class, this just causes an error.

The following functions now forward requests to SimControl, which is responsible for controlling the simulation.

static void requestHalt(); 
Calls SimControl::declareErrorHalt. NOTE: SimControl::requestHalt only sets the halt bit, not the error bit.

static int haltRequested(); 
Calls SimControl::haltRequested. Returns TRUE if the execution should halt.

static void clearHalt(); 
Calls SimControl::clearHalt. Clears the halt and error bits.

4.2.2 Scheduler protected members

The following two data members are protected.

// current time of the scheduler 
double currentTime;
// flag set if stop before deadlocked.
// for untimed domain, it is always FALSE.
int stopBeforeDeadlocked;

Top Up Prev Next Bottom Contents Index Search
Copyright © 1990-1997, University of California. All rights reserved.