use of joprt.RtThread in project jop by jop-devel.
the class MainSlip method main.
/**
* Start network and enter forever loop.
*/
public static void main(String[] args) {
Dbg.init();
//
// start TCP/IP and all (four) threads
//
net = Net.init();
// don't use CS8900 when simulating on PC or for BG263
// LinkLayer ipLink = CS8900.init(Net.eth, Net.ip);
// don't use PPP on my web server
// Ppp.init(Const.IO_UART_BG_MODEM_BASE);
ser = new Serial(Const.IO_UART1_BASE);
ipLink = Slip.init(ser, (192 << 24) + (168 << 16) + (1 << 8) + 2);
//
// start device driver threads
//
new RtThread(5, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
net.loop();
}
}
};
// Slip timeout (for windoz slip reply) depends on
// period (=100*period) !
new RtThread(9, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ipLink.loop();
}
}
};
new RtThread(10, 3000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ser.loop();
}
}
};
//
// WD thread has lowest priority to see if every timing will be met
//
RtThread.startMission();
forever();
}
use of joprt.RtThread in project jop by jop-devel.
the class HelloCspSpm method main.
/**
* @param args
*/
public static void main(String[] args) {
int start = 0;
int stop = 0;
int time = 0;
System.out.println("Csp Hello World");
int nrCpu = Runtime.getRuntime().availableProcessors();
if (nrCpu < 3) {
throw new Error("Not enogh CPUs");
}
Runnable sender = new Runnable() {
public void run() {
PrivateScope scope = new PrivateScope(1000);
Runnable r = new Runnable() {
public void run() {
int[] buffer = new int[CNT];
for (int i = 0; i < CNT; ++i) {
buffer[i] = i;
}
while (NoC.isSending()) {
// wait
}
Native.wr(2, NoC.NOC_REG_SNDDST);
// there is no send function in NoC :-(
Native.wr(CNT, NoC.NOC_REG_SNDCNT);
for (int i = 0; i < CNT; ++i) {
Native.wr(buffer[i], NoC.NOC_REG_SNDDATA);
}
}
};
scope.enter(r);
}
};
Runnable receiver = new Runnable() {
public void run() {
PrivateScope scope = new PrivateScope(1000);
Runnable r = new Runnable() {
public void run() {
// int buffer[] = new int[CNT];
int[] buffer = new int[CNT];
while (!NoC.isReceiving()) {
// wait
}
for (int i = 0; i < CNT; ++i) {
buffer[i] = Native.rd(NoC.NOC_REG_RCVDATA);
}
NoC.writeReset();
finished = true;
}
};
scope.enter(r);
}
};
// ni must be translated from proc index to NoC address!
new RtThread(sender, 1, 1000).setProcessor(1);
new RtThread(receiver, 1, 1000).setProcessor(2);
// start the other CPUs
System.out.println("starting cpus.");
RtThread.startMission();
start = (int) System.currentTimeMillis();
while (!finished) {
;
}
// End of measurement
stop = (int) System.currentTimeMillis();
System.out.println("StartTime: " + start);
System.out.println("StopTime: " + stop);
time = stop - start;
System.out.println("TimeSpent: " + time);
}
use of joprt.RtThread in project jop by jop-devel.
the class LocalScope method main.
/**
* @param args
*/
public static void main(String[] args) {
int[] ia = IOFactory.getFactory().getScratchpadMemory();
for (int i = 0; i < 256; ++i) {
ia[i] = i + 1;
}
for (int i = 0; i < 256; ++i) {
if (ia[i] != i + 1) {
System.out.println("shit at " + i);
}
}
// This was my version with automatic sizing
// final ScopedMemory scope = new ScratchpadScope();
// a RTSJ like version
// final ScopedMemory scope = new LTPhysicalMemory(PhysicalMemoryManager.ON_CHIP_PRIVATE, 1000);
// Andy's version
// ThreadLocalScope scope = new ThreadLocalScope(1000);
final Runnable run = new Runnable() {
public void run() {
// just generate garbage
for (int i = 0; i < 3; ++i) {
// this line generates a LOT of garbage!
// loop count of 4 does NOT fit into our 1 KB SPM
System.out.println("i=" + i);
}
}
};
RtThread rtt1 = new RtThread(10, 10000) {
public void run() {
PrivateScope scope = new PrivateScope(1000);
System.out.print("Size of the scratchpad RAM is ");
System.out.println(scope.size());
for (int i = 0; i < 3; ++i) {
System.out.println("enter A");
scope.enter(run);
waitForNextPeriod();
}
}
};
RtThread rtt2 = new RtThread(10, 10000) {
public void run() {
PrivateScope scope = new PrivateScope(1000);
System.out.print("Size of the scratchpad RAM is ");
System.out.println(scope.size());
for (int i = 0; i < 3; ++i) {
System.out.println("enter B");
scope.enter(run);
waitForNextPeriod();
}
}
};
rtt1.setProcessor(0);
// second thread on second CPU, but we will not see the
// output
rtt2.setProcessor(1);
RtThread.startMission();
}
use of joprt.RtThread in project jop by jop-devel.
the class Event method main.
public static void main(String[] args) {
// use serial line for debug output
Dbg.initSerWait();
result = new int[CNT];
sev = new SwEvent(11, 10000) {
public void handle() {
f_tim = Native.rd(Const.IO_CNT);
}
};
RtThread rt = new RtThread(10, 10000) {
public void run() {
int i, ts;
for (i = 0; i < CNT; ++i) {
waitForNextPeriod();
ts = Native.rd(Const.IO_CNT);
sev.fire();
result[i] = f_tim - ts;
}
result();
}
void result() {
int max = 0;
int min = 999999999;
int i;
for (i = 0; i < CNT; ++i) {
int diff = result[i];
if (diff < min)
min = diff;
if (diff > max)
max = diff;
Dbg.intVal(diff);
Dbg.wr('\n');
}
Dbg.intVal(min);
Dbg.intVal(max);
Dbg.wr('\n');
for (; ; ) waitForNextPeriod();
}
};
RtThread.startMission();
for (; ; ) {
// busy do nothing
;
}
}
use of joprt.RtThread in project jop by jop-devel.
the class Event method main.
public static void main(String[] args) {
sev = new SwEvent(2, 10000) {
public void handle() {
System.out.println("fire!");
}
};
RtThread rt = new RtThread(1, 100000) {
public void run() {
int i;
for (i = 0; i < CNT; ++i) {
waitForNextPeriod();
System.out.println("befor");
sev.fire();
System.out.println("after");
}
for (; ; ) waitForNextPeriod();
}
};
RtThread.startMission();
for (; ; ) {
// busy do nothing
;
}
}
Aggregations