01: //
02: // Copyright (C) 2005 United States Government as represented by the
03: // Administrator of the National Aeronautics and Space Administration
04: // (NASA). All Rights Reserved.
05: //
06: // This software is distributed under the NASA Open Source Agreement
07: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
08: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
09: // directory tree for the complete NOSA document.
10: //
11: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18: //
19: package DEOS;
20:
21: import gov.nasa.jpf.jvm.Verify;
22:
23: /**
24: * DOCUMENT ME!
25: */
26: class DEOS {
27: // Type of timer changed to DecreasingTimer by ckong - June 25, 2001
28: static NewTimer theTimer;
29: static PeriodicClock thePeriodicClock;
30: static Clock systemClock;
31: static boolean abstraction = false;
32: static String indent = "";
33: static String INC = " ";
34:
35: //static String INC = "";
36: public static void inc() {
37: //indent = INC + indent;
38: }
39:
40: public static void main(String[] args) {
41: Verify.beginAtomic();
42:
43: // To choose the abstracted version, call DEOS abstraction
44: if (args.length == 1) {
45: if (args[0].equals("abstraction")) {
46: abstraction = true;
47: }
48: }
49:
50: System.out.println("JAVA - DEOS\n");
51:
52: theTimer = new NewTimer();
53: thePeriodicClock = new PeriodicClock(
54: Registry.uSecsInFastestPeriod);
55: systemClock = new Clock(thePeriodicClock, theTimer);
56:
57: DEOSKernel.coldStartKernel();
58:
59: int result = DEOSKernel.createThreadK("user1", 0, 21, 1);
60:
61: //System.out.println("Thread created status = " + result);
62: result = DEOSKernel.createThreadK("user2", 0, 21, 1);
63:
64: //System.out.println("Thread created status = " + result);
65: int tickResult = Clock.NOINTERRUPTS;
66:
67: Verify.endAtomic();
68:
69: while (true) {
70: Verify.beginAtomic();
71:
72: // added ckong - June 21, 2001
73: DEOS.println("*************************");
74: DEOS.println("Current time: "
75: + DEOS.systemClock.getCurrentTime());
76:
77: DEOS.println(Scheduler.currentThread().toString()
78: + " is the current thread");
79:
80: tickResult = DEOS.systemClock.ticks();
81:
82: Scheduler.currentThread().getBody().run(tickResult);
83:
84: Verify.endAtomic();
85: }
86: }
87:
88: public static void println(java.lang.String s) {
89: System.out.println(indent + s);
90: }
91: }
|