summaryrefslogtreecommitdiff
path: root/mit-pthreads/include/pthread/state.def
diff options
context:
space:
mode:
Diffstat (limited to 'mit-pthreads/include/pthread/state.def')
-rwxr-xr-xmit-pthreads/include/pthread/state.def64
1 files changed, 64 insertions, 0 deletions
diff --git a/mit-pthreads/include/pthread/state.def b/mit-pthreads/include/pthread/state.def
new file mode 100755
index 00000000000..c62d102a9f0
--- /dev/null
+++ b/mit-pthreads/include/pthread/state.def
@@ -0,0 +1,64 @@
+/* This file defines the states that a given thread can be in.
+
+ The funky macro use here is so that this one header file can also
+ define the corresponding state names, so that the two lists can't
+ get inconsistent within a given source tree. */
+
+/* The thread is runnable. */
+__pthread_defstate (PS_RUNNING, "running")
+
+/*
+ * The rest of the states are where the thread is waiting on some event.
+ * Someday maybe the "data" field will point to the object being waited for.
+ */
+
+/* Waiting for a mutex (pthread_mutex_lock()). */
+__pthread_defstate (PS_MUTEX_WAIT, "mutex")
+
+/* Waiting on a condition variable
+ (pthread_cond_wait(), or pthread_cond_timedwait()). */
+__pthread_defstate (PS_COND_WAIT, "cond")
+
+/*
+ * File descriptor stuff.
+ *
+ * File descriptors have a special lock. If it is a FULL_DUPLEX fd such as
+ * a socket or fifo then it has two mutexes, one for reads and one for writes.
+ * Some routines will even try to get both. It will always try to get the
+ * read lock first before tring to get the write. All other fds only have
+ * one mutex which all calls will get. It is displayed as if it is a read lock.
+ */
+/* Waiting on a fd read lock (fd_lock()) */
+__pthread_defstate (PS_FDLR_WAIT, "fdlr")
+
+/* Waiting on a fd write lock (fd_lock()) */
+__pthread_defstate (PS_FDLW_WAIT, "fdlw")
+
+/* Waiting for the kernel fd to have data to read,
+ (read(), readv(), recv(), recvfrom(), and recvmsg()). */
+__pthread_defstate (PS_FDR_WAIT, "fdr") /* Waiting on a kernel read */
+
+/* Waiting for the kernel fd to allow a write
+ (write(), writev(), send(), sendto(), sendmsg()) */
+__pthread_defstate (PS_FDW_WAIT, "fdw")
+
+/* Waiting for several fds in a select() */
+__pthread_defstate (PS_SELECT_WAIT, "select")
+
+/* Waiting on a sleep (sleep(), usleep() or nanosleep()). */
+__pthread_defstate (PS_SLEEP_WAIT, "sleep")
+
+/* Waiting for a child to die (wait(), waitpid(), wait3(), or wait4()). */
+__pthread_defstate (PS_WAIT_WAIT, "wait")
+
+/* Waiting on some set of signals (sigwait()) */
+__pthread_defstate (PS_SIGWAIT, "sig")
+
+/* Waiting for a thread to die (pthread_join()) */
+__pthread_defstate (PS_JOIN, "join")
+
+/* Waiting for some thread to join with me or detach me */
+__pthread_defstate (PS_DEAD, "dead")
+
+/* Waiting for some thread to create me */
+__pthread_defstate (PS_UNALLOCED, "unallocated")