KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DEOS


1 //
2
// Copyright (C) 2005 United States Government as represented by the
3
// Administrator of the National Aeronautics and Space Administration
4
// (NASA). All Rights Reserved.
5
//
6
// This software is distributed under the NASA Open Source Agreement
7
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
8
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
9
// 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 /**
25  * DOCUMENT ME!
26  */

27 class DEOS {
28   // Type of timer changed to DecreasingTimer by ckong - June 25, 2001
29
static NewTimer theTimer;
30   static PeriodicClock thePeriodicClock;
31   static Clock systemClock;
32   static boolean abstraction = false;
33   static String JavaDoc indent = "";
34   static String JavaDoc INC = " ";
35
36   //static String INC = "";
37
public static void inc () {
38     //indent = INC + indent;
39
}
40
41   public static void main (String JavaDoc[] args) {
42     Verify.beginAtomic();
43
44     // To choose the abstracted version, call DEOS abstraction
45
if (args.length == 1) {
46       if (args[0].equals("abstraction")) {
47         abstraction = true;
48       }
49     }
50
51     System.out.println("JAVA - DEOS\n");
52
53     theTimer = new NewTimer();
54     thePeriodicClock = new PeriodicClock(Registry.uSecsInFastestPeriod);
55     systemClock = new Clock(thePeriodicClock, theTimer);
56
57     DEOSKernel.coldStartKernel();
58
59     int result = DEOSKernel.createThreadK("user1", 0, 21, 1);
60
61
62     //System.out.println("Thread created status = " + result);
63
result = DEOSKernel.createThreadK("user2", 0, 21, 1);
64
65     //System.out.println("Thread created status = " + result);
66
int tickResult = Clock.NOINTERRUPTS;
67
68     Verify.endAtomic();
69
70     while (true) {
71       Verify.beginAtomic();
72
73
74       // added ckong - June 21, 2001
75
DEOS.println("*************************");
76       DEOS.println("Current time: " + DEOS.systemClock.getCurrentTime());
77
78       DEOS.println(Scheduler.currentThread().toString() +
79                    " is the current thread");
80
81       tickResult = DEOS.systemClock.ticks();
82
83       Scheduler.currentThread().getBody().run(tickResult);
84
85       Verify.endAtomic();
86     }
87   }
88
89   public static void println (java.lang.String JavaDoc s) {
90     System.out.println(indent + s);
91   }
92 }
Popular Tags