OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/safepoint.h" | 5 #include "vm/safepoint.h" |
6 | 6 |
7 #include "vm/thread.h" | 7 #include "vm/thread.h" |
8 #include "vm/thread_registry.h" | 8 #include "vm/thread_registry.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 } else { | 90 } else { |
91 current->SetAtSafepoint(true); | 91 current->SetAtSafepoint(true); |
92 } | 92 } |
93 current = current->next(); | 93 current = current->next(); |
94 } | 94 } |
95 } | 95 } |
96 // Now wait for all threads that are not already at a safepoint to check-in. | 96 // Now wait for all threads that are not already at a safepoint to check-in. |
97 { | 97 { |
98 MonitorLocker sl(safepoint_lock_); | 98 MonitorLocker sl(safepoint_lock_); |
| 99 intptr_t num_attempts = 0; |
99 while (number_threads_not_at_safepoint_ > 0) { | 100 while (number_threads_not_at_safepoint_ > 0) { |
100 sl.Wait(); | 101 Monitor::WaitResult retval = sl.Wait(1000); |
| 102 if (retval == Monitor::kTimedOut) { |
| 103 num_attempts += 1; |
| 104 OS::Print("Attempt:%" Pd " waiting for %d threads to check in\n", |
| 105 num_attempts, |
| 106 number_threads_not_at_safepoint_); |
| 107 } |
101 } | 108 } |
102 } | 109 } |
103 } | 110 } |
104 | 111 |
105 | 112 |
106 void SafepointHandler::ResumeThreads(Thread* T) { | 113 void SafepointHandler::ResumeThreads(Thread* T) { |
107 // First resume all the threads which are blocked for the safepoint | 114 // First resume all the threads which are blocked for the safepoint |
108 // operation. | 115 // operation. |
109 MonitorLocker sl(threads_lock()); | 116 MonitorLocker sl(threads_lock()); |
110 Thread* current = isolate()->thread_registry()->active_list(); | 117 Thread* current = isolate()->thread_registry()->active_list(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 while (T->IsSafepointRequested()) { | 172 while (T->IsSafepointRequested()) { |
166 T->SetBlockedForSafepoint(true); | 173 T->SetBlockedForSafepoint(true); |
167 tl.Wait(); | 174 tl.Wait(); |
168 T->SetBlockedForSafepoint(false); | 175 T->SetBlockedForSafepoint(false); |
169 } | 176 } |
170 T->SetAtSafepoint(false); | 177 T->SetAtSafepoint(false); |
171 } | 178 } |
172 } | 179 } |
173 | 180 |
174 } // namespace dart | 181 } // namespace dart |
OLD | NEW |