Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_THREAD_STATE_H_ |
| 18 | #define ART_RUNTIME_THREAD_STATE_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
Andreas Gampe | 8764dc3 | 2019-01-07 15:20:12 -0800 | [diff] [blame] | 20 | #include <iosfwd> |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 21 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 22 | namespace art { |
| 23 | |
Hans Boehm | 230beda | 2019-05-03 16:06:52 -0700 | [diff] [blame] | 24 | // State stored in our C++ class Thread. |
| 25 | // When we refer to "a suspended state", or when function names mention "ToSuspended" or |
| 26 | // "FromSuspended", we mean any state other than kRunnable, i.e. any state in which the thread is |
| 27 | // guaranteed not to access the Java heap. The kSuspended state is merely one of these. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 28 | enum ThreadState { |
Hans Boehm | 230beda | 2019-05-03 16:06:52 -0700 | [diff] [blame] | 29 | // Java |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 30 | // Thread.State JDWP state |
Dave Allison | 0aded08 | 2013-11-07 13:15:11 -0800 | [diff] [blame] | 31 | kTerminated = 66, // TERMINATED TS_ZOMBIE Thread.run has returned, but Thread* still around |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 32 | kRunnable, // RUNNABLE TS_RUNNING runnable |
| 33 | kTimedWaiting, // TIMED_WAITING TS_WAIT in Object.wait() with a timeout |
| 34 | kSleeping, // TIMED_WAITING TS_SLEEPING in Thread.sleep() |
| 35 | kBlocked, // BLOCKED TS_MONITOR blocked on a monitor |
| 36 | kWaiting, // WAITING TS_WAIT in Object.wait() |
Alex Light | 77fee87 | 2017-09-05 14:51:49 -0700 | [diff] [blame] | 37 | kWaitingForLockInflation, // WAITING TS_WAIT blocked inflating a thin-lock |
| 38 | kWaitingForTaskProcessor, // WAITING TS_WAIT blocked waiting for taskProcessor |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 39 | kWaitingForGcToComplete, // WAITING TS_WAIT blocked waiting for GC |
| 40 | kWaitingForCheckPointsToRun, // WAITING TS_WAIT GC waiting for checkpoints to run |
| 41 | kWaitingPerformingGc, // WAITING TS_WAIT performing GC |
| 42 | kWaitingForDebuggerSend, // WAITING TS_WAIT blocked waiting for events to be sent |
| 43 | kWaitingForDebuggerToAttach, // WAITING TS_WAIT blocked waiting for debugger to attach |
| 44 | kWaitingInMainDebuggerLoop, // WAITING TS_WAIT blocking/reading/processing debugger events |
| 45 | kWaitingForDebuggerSuspension, // WAITING TS_WAIT waiting for debugger suspend all |
| 46 | kWaitingForJniOnLoad, // WAITING TS_WAIT waiting for execution of dlopen and JNI on load code |
| 47 | kWaitingForSignalCatcherOutput, // WAITING TS_WAIT waiting for signal catcher IO to complete |
| 48 | kWaitingInMainSignalCatcherLoop, // WAITING TS_WAIT blocking/reading/processing signals |
Sebastien Hertz | 138dbfc | 2013-12-04 18:15:25 +0100 | [diff] [blame] | 49 | kWaitingForDeoptimization, // WAITING TS_WAIT waiting for deoptimization suspend all |
Sebastien Hertz | bae182c | 2013-12-17 10:42:03 +0100 | [diff] [blame] | 50 | kWaitingForMethodTracingStart, // WAITING TS_WAIT waiting for method tracing to start |
Hiroshi Yamauchi | 0c8c303 | 2015-01-16 16:54:35 -0800 | [diff] [blame] | 51 | kWaitingForVisitObjects, // WAITING TS_WAIT waiting for visiting objects |
Mathieu Chartier | b43390c | 2015-05-12 10:47:11 -0700 | [diff] [blame] | 52 | kWaitingForGetObjectsAllocated, // WAITING TS_WAIT waiting for getting the number of allocated objects |
Mathieu Chartier | 90ef3db | 2015-08-04 15:19:41 -0700 | [diff] [blame] | 53 | kWaitingWeakGcRootRead, // WAITING TS_WAIT waiting on the GC to read a weak root |
Hiroshi Yamauchi | 76f55b0 | 2015-08-21 16:10:39 -0700 | [diff] [blame] | 54 | kWaitingForGcThreadFlip, // WAITING TS_WAIT waiting on the GC thread flip (CC collector) to finish |
Koji Fukui | 34857b5 | 2019-03-20 19:13:00 +0900 | [diff] [blame] | 55 | kNativeForAbort, // WAITING TS_WAIT checking other threads are not run on abort. |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 56 | kStarting, // NEW TS_WAIT native thread started, not yet ready to run managed code |
| 57 | kNative, // RUNNABLE TS_RUNNING running in a JNI native method |
| 58 | kSuspended, // RUNNABLE TS_RUNNING suspended by GC or debugger |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 59 | }; |
Vladimir Marko | 9974e3c | 2020-06-10 16:27:06 +0100 | [diff] [blame] | 60 | std::ostream& operator<<(std::ostream& os, ThreadState rhs); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 61 | |
| 62 | } // namespace art |
| 63 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 64 | #endif // ART_RUNTIME_THREAD_STATE_H_ |