@@ -75,22 +75,29 @@ public static void checkpointDeadlock() {
75
75
final TestResult testResult = new TestResult (true , 0 );
76
76
77
77
Thread t1 = new Thread (() -> {
78
+ CRIUTestUtils .showThreadCurrentTime ("checkpointDeadlock.t1 started with testResult.lockStatus = "
79
+ + testResult .lockStatus .get ());
78
80
synchronized (lock ) {
79
81
testResult .lockStatus .set (1 );
80
- try {
81
- Thread .sleep (20000 );
82
- } catch (InterruptedException e ) {
83
- e .printStackTrace ();
82
+ CRIUTestUtils .showThreadCurrentTime ("checkpointDeadlock.t1 locked with testResult.lockStatus = "
83
+ + testResult .lockStatus .get ());
84
+ // Hold the lock until the lockStatus value is changed.
85
+ while (testResult .lockStatus .get () == 1 ) {
86
+ Thread .yield ();
84
87
}
85
88
}
89
+ CRIUTestUtils .showThreadCurrentTime ("checkpointDeadlock.t1 finished with testResult.lockStatus = "
90
+ + testResult .lockStatus .get ());
86
91
});
87
92
88
93
t1 .start ();
89
94
90
95
CRIUSupport criuSupport = new CRIUSupport (path );
91
96
criuSupport .registerPreCheckpointHook (() -> {
92
97
synchronized (lock ) {
93
- System .out .println ("Precheckpoint hook inside monitor" );
98
+ CRIUTestUtils .showThreadCurrentTime ("Precheckpoint hook inside monitor with testResult.lockStatus = "
99
+ + testResult .lockStatus .get ());
100
+ testResult .lockStatus .set (2 );
94
101
testResult .testPassed = false ;
95
102
}
96
103
});
@@ -101,7 +108,11 @@ public static void checkpointDeadlock() {
101
108
102
109
try {
103
110
System .out .println ("Pre-checkpoint" );
111
+ CRIUTestUtils .showThreadCurrentTime ("Pre-checkpoint with testResult.lockStatus = "
112
+ + testResult .lockStatus .get ());
104
113
CRIUTestUtils .checkPointJVM (criuSupport , path , true );
114
+ CRIUTestUtils .showThreadCurrentTime ("Post-restore with testResult.lockStatus = "
115
+ + testResult .lockStatus .get ());
105
116
testResult .testPassed = false ;
106
117
} catch (JVMCheckpointException e ) {
107
118
/*
@@ -122,10 +133,18 @@ public static void checkpointDeadlock() {
122
133
at java.base/openj9.internal.criu.InternalCRIUSupport.lambda$registerCheckpointHookHelper$2(InternalCRIUSupport.java:697)
123
134
*/
124
135
if (!e .getCause ().getCause ().getMessage ().contains ("Blocking operation is not allowed in CRIU single thread mode" )) {
136
+ CRIUTestUtils .showThreadCurrentTime ("checkpointDeadlock test failed with testResult.lockStatus = "
137
+ + testResult .lockStatus .get ());
125
138
testResult .testPassed = false ;
126
139
e .printStackTrace ();
127
140
}
128
141
}
142
+ testResult .lockStatus .set (3 );
143
+ try {
144
+ t1 .join ();
145
+ } catch (InterruptedException e ) {
146
+ e .printStackTrace ();
147
+ }
129
148
130
149
if (testResult .testPassed ) {
131
150
System .out .println ("TEST PASSED" );
0 commit comments