Difference between revisions of "RealtimeThreads"

From Suhrid.net Wiki
Jump to navigationJump to search
Line 37: Line 37:
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
* DL Miss handler can be defined as part of Release Parameters. If no DL Handler is defined, missed DL count is kept.
 +
 +
* The behaviour of waitForNextPeriod (WFNP) can be described in terms of:
 +
** lastReturn: indicates last return value from wFNP.
 +
** missCount : DL miss count.
 +
** descheduled: should thread be descheduled at end of current release.

Revision as of 08:28, 1 January 2012

Intro

  • Java has threads but they are not expressive enough to capture properties of real time activities. (e.g. deadline, cost, value etc.)
  • RT threads are also characterized by their execution patterns - periodic, sporadic, aperiodic. This has to be manually coded in standard Java threads.
  • Supporting RT Threads requires fundamental changes to the JVM.
  • Two classes: RealtimeThread and NoHeapRealtimeThread.

Periodic RT Thread

  • waitForNextPeriod() : Causes the current real-time thread to be suspended until the beginning of the next period. Each time it is called this method will block until the start of the next period unless the thread is in a deadline miss condition. In that case the operation of waitForNextPeriod is controlled by this thread's scheduler. Returns True (when the thread is next released ) when the thread is not in a deadline miss condition. Otherwise the return value is governed by this thread's scheduler.
  • The deschedulePeriodic() method will cause the associated thread to block (to be descheduled) at the end of its current release (when it calls waitForNextPeriod). It will then remain descheduled until schedulerPeriodic() is called.
public class PeriodicRT1 {

	public static void main(String[] args) {
		
		ReleaseParameters rp = new PeriodicParameters(new RelativeTime(3000,0));
		
		RealtimeThread prt = new RealtimeThread(null, rp) {
			boolean go = true;
			public void run() {
				while(go) {
					System.out.println("PRT computing");
					System.out.println("Calling WFNP @ " + System.currentTimeMillis());
					go = waitForNextPeriod();
					System.out.println("WFNP Returned @ " + System.currentTimeMillis());
				}
			}
		};
		
		prt.start();
		
	}
}
  • DL Miss handler can be defined as part of Release Parameters. If no DL Handler is defined, missed DL count is kept.
  • The behaviour of waitForNextPeriod (WFNP) can be described in terms of:
    • lastReturn: indicates last return value from wFNP.
    • missCount : DL miss count.
    • descheduled: should thread be descheduled at end of current release.