This discussion is archived
0 Replies Latest reply: Feb 20, 2011 4:20 PM by 841278 RSS

NHRT and illegal memory parameter

841278 Newbie
Currently Being Moderated
Hi
I'm trying to make a set of NHRTs by calling them from the Main class as shown below:-

PeriodicThread Class:-
--------------------------------
package task_set;
import javax.realtime.*;
import java.io.StringWriter;

public class PeriodicThread extends NoHeapRealtimeThread {

// The following parameters and constructor for Priority_based scheduler
int p; //Priority relative to min priority
PriorityScheduler ps;
ReleaseParameters rp;
StringWriter st;
Clock cl;
PeriodicThread(int p_in,ReleaseParameters rp_in,PriorityScheduler ps_in,StringWriter st_in,Clock cl_in){
super(new PriorityParameters(ps_in.getMinPriority()+p_in),rp_in,ImmortalMemory.instance());
p=p_in;
rp=rp_in;
ps=ps_in;
st=st_in;
cl=cl_in;
}
public void run(){
try{
st.write("ID:"+this.getId()+",Priority:"+this.getPriority()+",Cost"+this.getProcessingGroupParameters().getCost()+",R_Deadline:"+this.getProcessingGroupParameters().getDeadline()+",Period:"+this.getProcessingGroupParameters().getPeriod()+",Start:"+this.getProcessingGroupParameters().getStart()+",Now:"+cl.getTime());
}catch(Exception e){
e.printStackTrace();
}
}
}

Main Class
------------------
package task_set;
import javax.realtime.*;
import java.io.StringWriter;

public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int pri=4; //priority
Clock cl=Clock.getRealtimeClock();
PriorityScheduler ps=(PriorityScheduler)Scheduler.getDefaultScheduler();
PeriodicParameters rp=new PeriodicParameters(cl.getTime().add(1000, 0),new RelativeTime(10,0),new RelativeTime(5,0),new RelativeTime(10,0),null,null);
StringWriter sw= new StringWriter(5000);
//MemoryArea ma=RealtimeThread.getCurrentMemoryArea();
try{
PeriodicThread pt1=new PeriodicThread(pri,rp,ps,sw,cl);
pt1.start();
}catch(Exception e){
e.printStackTrace();
}
}
}

Program compiles without errors, but when run gives the following error:-

java.lang.IllegalArgumentException: Illegal Memory Area Passed or argument allocated in heap
at javax.realtime.NoHeapRealtimeThread.<init>(NoHeapRealtimeThread.java:219)
at javax.realtime.NoHeapRealtimeThread.<init>(NoHeapRealtimeThread.java:196)
at javax.realtime.NoHeapRealtimeThread.<init>(NoHeapRealtimeThread.java:130)
at task_set.PeriodicThread.<init>(PeriodicThread.java:23)
at task_set.Main.main(Main.java:27)

I tried to look for on line code examples for NHRTs to see what the wrong with "memory" parameter is but there are few examples and do not mention more information about memory parameters.

Please help.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points