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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/thread.h
          +++ new/usr/src/uts/common/sys/thread.h
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright 2018 Joyent, Inc.
       29 + */
       30 +
  27   31  #ifndef _SYS_THREAD_H
  28   32  #define _SYS_THREAD_H
  29   33  
  30   34  
  31   35  #include <sys/types.h>
  32   36  #include <sys/t_lock.h>
  33   37  #include <sys/klwp.h>
  34   38  #include <sys/time.h>
  35   39  #include <sys/signal.h>
  36   40  #include <sys/kcpc.h>
↓ open down ↓ 301 lines elided ↑ open up ↑
 338  342          uintptr_t       t_dtrace_scrpc; /* DTrace per-thread scratch location */
 339  343          uintptr_t       t_dtrace_astpc; /* DTrace return sequence location */
 340  344  #ifdef __amd64
 341  345          uint64_t        t_dtrace_regv;  /* DTrace saved reg from fasttrap */
 342  346          uint64_t        t_useracc;      /* SMAP state saved across swtch() */
 343  347  #endif
 344  348          hrtime_t        t_hrtime;       /* high-res last time on cpu */
 345  349          kmutex_t        t_ctx_lock;     /* protects t_ctx in removectx() */
 346  350          struct waitq    *t_waitq;       /* wait queue */
 347  351          kmutex_t        t_wait_mutex;   /* used in CV wait functions */
      352 +
      353 +        char            *t_name;        /* thread name */
 348  354  } kthread_t;
 349  355  
 350  356  /*
 351  357   * Thread flag (t_flag) definitions.
 352  358   *      These flags must be changed only for the current thread,
 353  359   *      and not during preemption code, since the code being
 354  360   *      preempted could be modifying the flags.
 355  361   *
 356  362   *      For the most part these flags do not need locking.
 357  363   *      The following flags will only be changed while the thread_lock is held,
↓ open down ↓ 224 lines elided ↑ open up ↑
 582  588  #define thread_unlock_high(t)           disp_lock_exit_high((t)->t_lockp)
 583  589  #define thread_unlock_nopreempt(t)      disp_lock_exit_nopreempt((t)->t_lockp)
 584  590  
 585  591  #define THREAD_LOCK_HELD(t)     (DISP_LOCK_HELD((t)->t_lockp))
 586  592  
 587  593  extern disp_lock_t transition_lock;     /* lock protecting transiting threads */
 588  594  extern disp_lock_t stop_lock;           /* lock protecting stopped threads */
 589  595  
 590  596  caddr_t thread_stk_init(caddr_t);       /* init thread stack */
 591  597  
      598 +int thread_setname(kthread_t *, const char *);
      599 +int thread_vsetname(kthread_t *, const char *, ...);
      600 +
 592  601  extern int default_binding_mode;
 593  602  
 594  603  #endif  /* _KERNEL */
 595  604  
      605 +#define THREAD_NAME_MAX 32      /* includes terminating NUL */
      606 +
 596  607  /*
 597  608   * Macros to indicate that the thread holds resources that could be critical
 598  609   * to other kernel threads, so this thread needs to have kernel priority
 599  610   * if it blocks or is preempted.  Note that this is not necessary if the
 600  611   * resource is a mutex or a writer lock because of priority inheritance.
 601  612   *
 602  613   * The only way one thread may legally manipulate another thread's t_kpri_req
 603  614   * is to hold the target thread's thread lock while that thread is asleep.
 604  615   * (The rwlock code does this to implement direct handoff to waiting readers.)
 605  616   */
↓ open down ↓ 118 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX