Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

@@ -22,10 +22,14 @@
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright 2018 Joyent, Inc.
+ */
+
 #ifndef _SYS_THREAD_H
 #define _SYS_THREAD_H
 
 
 #include <sys/types.h>

@@ -343,10 +347,12 @@
 #endif
         hrtime_t        t_hrtime;       /* high-res last time on cpu */
         kmutex_t        t_ctx_lock;     /* protects t_ctx in removectx() */
         struct waitq    *t_waitq;       /* wait queue */
         kmutex_t        t_wait_mutex;   /* used in CV wait functions */
+
+        char            *t_name;        /* thread name */
 } kthread_t;
 
 /*
  * Thread flag (t_flag) definitions.
  *      These flags must be changed only for the current thread,

@@ -587,14 +593,19 @@
 extern disp_lock_t transition_lock;     /* lock protecting transiting threads */
 extern disp_lock_t stop_lock;           /* lock protecting stopped threads */
 
 caddr_t thread_stk_init(caddr_t);       /* init thread stack */
 
+int thread_setname(kthread_t *, const char *);
+int thread_vsetname(kthread_t *, const char *, ...);
+
 extern int default_binding_mode;
 
 #endif  /* _KERNEL */
 
+#define THREAD_NAME_MAX 32      /* includes terminating NUL */
+
 /*
  * Macros to indicate that the thread holds resources that could be critical
  * to other kernel threads, so this thread needs to have kernel priority
  * if it blocks or is preempted.  Note that this is not necessary if the
  * resource is a mutex or a writer lock because of priority inheritance.