comparison src/main/gov/nasa/jpf/vm/SyncPolicy.java @ 0:61d41facf527

initial v8 import (history reset)
author Peter Mehlitz <Peter.C.Mehlitz@nasa.gov>
date Fri, 23 Jan 2015 10:14:01 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:61d41facf527
1 /*
2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
4 * All rights reserved.
5 *
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0.
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package gov.nasa.jpf.vm;
20
21 /**
22 * a policy interface related to locking, blocking and thread lifetime
23 * events.
24 *
25 * As opposed to field access and SharednessPolicy, most of these events
26 * are of mandatory nature, but we want to support varying order and degrees of
27 * precision with respect to scheduling candidates
28 *
29 * NOTE - this interface is part of dividing the old SchedulerFactory (which was
30 * mostly concerned about scheduling order) into separate policy interfaces
31 * that allow control over
32 * - CG type
33 * - choice values
34 * - choice order
35 * based on operation (instruction type, MJI methods), which might require
36 * additional, policy related state (e.g. threads competing for the same object).
37 *
38 * Since the policies are interfaces kept at the same level, and are only
39 * accessed through ThreadInfo facades, they can be implemented by a single
40 * class/object
41 */
42 public interface SyncPolicy {
43
44 //--- system scheduling points
45 public static String ROOT = "ROOT";
46 public static String POST_FINALIZE = "POST_FINALIZE";
47
48 //--- thread sync and lifetime
49 public static String START = "START";
50 public static String BLOCK = "BLOCK";
51 public static String LOCK = "LOCK";
52 public static String RELEASE = "RELEASE";
53 public static String WAIT = "WAIT";
54 public static String JOIN = "JOIN";
55 public static String NOTIFY = "NOTIFY";
56 public static String NOTIFYALL = "NOTIFYALL";
57 public static String SLEEP = "SLEEP";
58 public static String YIELD = "YIELD";
59 public static String PRIORITY = "PRIORITY";
60 public static String INTERRUPT = "INTERRUPT";
61 public static String SUSPEND = "SUSPEND";
62 public static String RESUME = "RESUME";
63 public static String STOP = "STOP";
64 public static String PARK = "PARK";
65 public static String UNPARK = "UNPARK";
66 public static String BEGIN_ATOMIC = "BEGIN_ATOMIC";
67 public static String END_ATOMIC = "END_ATOMIC";
68 public static String RESCHEDULE = "SCHEDULE";
69 public static String TERMINATE = "TERMINATE";
70
71
72 /**
73 * called once per application, after the VM is fully initialized
74 */
75 void initializeSyncPolicy (VM vm, ApplicationContext appCtx);
76
77 /**
78 * called during ThreadInfo initialization, before Thread.start()
79 */
80 void initializeThreadSync (ThreadInfo tiCurrent, ThreadInfo tiNew);
81
82 /**
83 * set the very first CG, which is not optional
84 */
85 void setRootCG ();
86
87 //--- locks
88 boolean setsBlockedThreadCG (ThreadInfo ti, ElementInfo ei);
89 boolean setsLockAcquisitionCG (ThreadInfo ti, ElementInfo ei);
90 boolean setsLockReleaseCG (ThreadInfo ti, ElementInfo ei, boolean didUnblock);
91
92 //--- thread termination
93 boolean setsTerminationCG (ThreadInfo ti);
94
95 //--- java.lang.Object APIs
96 boolean setsWaitCG (ThreadInfo ti, long timeout);
97 boolean setsNotifyCG (ThreadInfo ti, boolean didNotify);
98 boolean setsNotifyAllCG (ThreadInfo ti, boolean didNotify);
99
100 //--- the java.lang.Thread APIs
101 boolean setsStartCG (ThreadInfo tiCurrent, ThreadInfo tiStarted);
102 boolean setsYieldCG (ThreadInfo ti);
103 boolean setsPriorityCG (ThreadInfo ti);
104 boolean setsSleepCG (ThreadInfo ti, long millis, int nanos);
105 boolean setsSuspendCG (ThreadInfo tiCurrent, ThreadInfo tiSuspended);
106 boolean setsResumeCG (ThreadInfo tiCurrent, ThreadInfo tiResumed);
107 boolean setsJoinCG (ThreadInfo tiCurrent, ThreadInfo tiJoin, long timeout);
108 boolean setsStopCG (ThreadInfo tiCurrent, ThreadInfo tiStopped);
109 boolean setsInterruptCG (ThreadInfo tiCurrent, ThreadInfo tiInterrupted);
110
111 //--- sun.misc.Unsafe
112 boolean setsParkCG (ThreadInfo ti, boolean isAbsTime, long timeout);
113 boolean setsUnparkCG (ThreadInfo tiCurrent, ThreadInfo tiUnparked);
114
115 //--- gov.nasa.jpf.vm.Verify
116 boolean setsBeginAtomicCG (ThreadInfo ti);
117 boolean setsEndAtomicCG (ThreadInfo ti);
118
119 //--- ThreadInfo reschedule request
120 boolean setsRescheduleCG (ThreadInfo ti, String reason);
121
122 //--- FinalizerThread
123 boolean setsPostFinalizeCG (ThreadInfo tiFinalizer);
124 }