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


  40 #include <ucontext.h>
  41 #include <thread.h>
  42 #include <pthread.h>
  43 #include <atomic.h>
  44 #include <link.h>
  45 #include <sys/resource.h>
  46 #include <sys/lwp.h>
  47 #include <errno.h>
  48 #include <sys/asm_linkage.h>
  49 #include <sys/regset.h>
  50 #include <sys/fcntl.h>
  51 #include <sys/mman.h>
  52 #include <synch.h>
  53 #include <door.h>
  54 #include <limits.h>
  55 #include <sys/synch32.h>
  56 #include <schedctl.h>
  57 #include <sys/priocntl.h>
  58 #include <thread_db.h>
  59 #include <setjmp.h>

  60 #include "libc_int.h"
  61 #include "tdb_agent.h"
  62 #include "thr_debug.h"
  63 
  64 /*
  65  * This is an implementation-specific include file for threading support.
  66  * It is not to be seen by the clients of the library.
  67  *
  68  * This file also describes uberdata in libc.
  69  *
  70  * The term "uberdata" refers to data that is unique and visible across
  71  * all link maps.  The name is meant to imply that such data is truly
  72  * global, not just locally global to a particular link map.
  73  *
  74  * See the Linker and Libraries Guide for a full description of alternate
  75  * link maps and how they are set up and used.
  76  *
  77  * Alternate link maps implement multiple global namespaces within a single
  78  * process.  There may be multiple instances of identical dynamic libraries
  79  * loaded in a process's address space at the same time, each on a different


1216 } cvattr_t;
1217 
1218 typedef struct  _mattr {
1219         int     pshared;
1220         int     protocol;
1221         int     prioceiling;
1222         int     type;
1223         int     robustness;
1224 } mattr_t;
1225 
1226 typedef struct  _thrattr {
1227         size_t  stksize;
1228         void    *stkaddr;
1229         int     detachstate;
1230         int     daemonstate;
1231         int     scope;
1232         int     prio;
1233         int     policy;
1234         int     inherit;
1235         size_t  guardsize;

1236 } thrattr_t;
1237 
1238 typedef struct  _rwlattr {
1239         int     pshared;
1240 } rwlattr_t;
1241 
1242 /* _curthread() is inline for speed */
1243 extern  ulwp_t          *_curthread(void);
1244 #define curthread       (_curthread())
1245 
1246 /* this version (also inline) can be tested for NULL */
1247 extern  ulwp_t          *__curthread(void);
1248 
1249 /* get the current stack pointer (also inline) */
1250 extern  greg_t          stkptr(void);
1251 
1252 /*
1253  * Suppress __attribute__((...)) if we are not compiling with gcc
1254  */
1255 #if !defined(__GNUC__)


1475 
1476 /* belongs in <pthread.h> */
1477 #define PTHREAD_CREATE_DAEMON_NP        0x100   /* = THR_DAEMON */
1478 #define PTHREAD_CREATE_NONDAEMON_NP     0
1479 extern  int     pthread_attr_setdaemonstate_np(pthread_attr_t *, int);
1480 extern  int     pthread_attr_getdaemonstate_np(const pthread_attr_t *, int *);
1481 
1482 extern  int     mutex_held(mutex_t *);
1483 extern  int     mutex_lock_internal(mutex_t *, timespec_t *, int);
1484 extern  int     mutex_unlock_internal(mutex_t *, int);
1485 
1486 /* not cancellation points: */
1487 extern  int     __cond_wait(cond_t *, mutex_t *);
1488 extern  int     __cond_timedwait(cond_t *, mutex_t *, const timespec_t *);
1489 extern  int     __cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
1490 
1491 extern  int     rw_read_held(rwlock_t *);
1492 extern  int     rw_write_held(rwlock_t *);
1493 
1494 extern  int     _thrp_create(void *, size_t, void *(*)(void *), void *, long,
1495                         thread_t *, size_t);
1496 extern  int     _thrp_suspend(thread_t, uchar_t);
1497 extern  int     _thrp_continue(thread_t, uchar_t);
1498 
1499 extern  void    _thrp_terminate(void *);
1500 extern  void    _thrp_exit(void);
1501 
1502 extern  const pcclass_t *get_info_by_class(id_t);
1503 extern  const pcclass_t *get_info_by_policy(int);
1504 extern  const thrattr_t *def_thrattr(void);
1505 extern  id_t    setparam(idtype_t, id_t, int, int);
1506 extern  id_t    setprio(idtype_t, id_t, int, int *);
1507 extern  id_t    getparam(idtype_t, id_t, int *, struct sched_param *);
1508 
1509 /*
1510  * System call wrappers (direct interfaces to the kernel)
1511  */
1512 extern  int     ___lwp_mutex_register(mutex_t *, mutex_t **);
1513 extern  int     ___lwp_mutex_trylock(mutex_t *, ulwp_t *);
1514 extern  int     ___lwp_mutex_timedlock(mutex_t *, timespec_t *, ulwp_t *);
1515 extern  int     ___lwp_mutex_unlock(mutex_t *);




  40 #include <ucontext.h>
  41 #include <thread.h>
  42 #include <pthread.h>
  43 #include <atomic.h>
  44 #include <link.h>
  45 #include <sys/resource.h>
  46 #include <sys/lwp.h>
  47 #include <errno.h>
  48 #include <sys/asm_linkage.h>
  49 #include <sys/regset.h>
  50 #include <sys/fcntl.h>
  51 #include <sys/mman.h>
  52 #include <synch.h>
  53 #include <door.h>
  54 #include <limits.h>
  55 #include <sys/synch32.h>
  56 #include <schedctl.h>
  57 #include <sys/priocntl.h>
  58 #include <thread_db.h>
  59 #include <setjmp.h>
  60 #include <sys/thread.h>
  61 #include "libc_int.h"
  62 #include "tdb_agent.h"
  63 #include "thr_debug.h"
  64 
  65 /*
  66  * This is an implementation-specific include file for threading support.
  67  * It is not to be seen by the clients of the library.
  68  *
  69  * This file also describes uberdata in libc.
  70  *
  71  * The term "uberdata" refers to data that is unique and visible across
  72  * all link maps.  The name is meant to imply that such data is truly
  73  * global, not just locally global to a particular link map.
  74  *
  75  * See the Linker and Libraries Guide for a full description of alternate
  76  * link maps and how they are set up and used.
  77  *
  78  * Alternate link maps implement multiple global namespaces within a single
  79  * process.  There may be multiple instances of identical dynamic libraries
  80  * loaded in a process's address space at the same time, each on a different


1217 } cvattr_t;
1218 
1219 typedef struct  _mattr {
1220         int     pshared;
1221         int     protocol;
1222         int     prioceiling;
1223         int     type;
1224         int     robustness;
1225 } mattr_t;
1226 
1227 typedef struct  _thrattr {
1228         size_t  stksize;
1229         void    *stkaddr;
1230         int     detachstate;
1231         int     daemonstate;
1232         int     scope;
1233         int     prio;
1234         int     policy;
1235         int     inherit;
1236         size_t  guardsize;
1237         char    name[THREAD_NAME_MAX];
1238 } thrattr_t;
1239 
1240 typedef struct  _rwlattr {
1241         int     pshared;
1242 } rwlattr_t;
1243 
1244 /* _curthread() is inline for speed */
1245 extern  ulwp_t          *_curthread(void);
1246 #define curthread       (_curthread())
1247 
1248 /* this version (also inline) can be tested for NULL */
1249 extern  ulwp_t          *__curthread(void);
1250 
1251 /* get the current stack pointer (also inline) */
1252 extern  greg_t          stkptr(void);
1253 
1254 /*
1255  * Suppress __attribute__((...)) if we are not compiling with gcc
1256  */
1257 #if !defined(__GNUC__)


1477 
1478 /* belongs in <pthread.h> */
1479 #define PTHREAD_CREATE_DAEMON_NP        0x100   /* = THR_DAEMON */
1480 #define PTHREAD_CREATE_NONDAEMON_NP     0
1481 extern  int     pthread_attr_setdaemonstate_np(pthread_attr_t *, int);
1482 extern  int     pthread_attr_getdaemonstate_np(const pthread_attr_t *, int *);
1483 
1484 extern  int     mutex_held(mutex_t *);
1485 extern  int     mutex_lock_internal(mutex_t *, timespec_t *, int);
1486 extern  int     mutex_unlock_internal(mutex_t *, int);
1487 
1488 /* not cancellation points: */
1489 extern  int     __cond_wait(cond_t *, mutex_t *);
1490 extern  int     __cond_timedwait(cond_t *, mutex_t *, const timespec_t *);
1491 extern  int     __cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
1492 
1493 extern  int     rw_read_held(rwlock_t *);
1494 extern  int     rw_write_held(rwlock_t *);
1495 
1496 extern  int     _thrp_create(void *, size_t, void *(*)(void *), void *, long,
1497                         thread_t *, size_t, const char *);
1498 extern  int     _thrp_suspend(thread_t, uchar_t);
1499 extern  int     _thrp_continue(thread_t, uchar_t);
1500 
1501 extern  void    _thrp_terminate(void *);
1502 extern  void    _thrp_exit(void);
1503 
1504 extern  const pcclass_t *get_info_by_class(id_t);
1505 extern  const pcclass_t *get_info_by_policy(int);
1506 extern  const thrattr_t *def_thrattr(void);
1507 extern  id_t    setparam(idtype_t, id_t, int, int);
1508 extern  id_t    setprio(idtype_t, id_t, int, int *);
1509 extern  id_t    getparam(idtype_t, id_t, int *, struct sched_param *);
1510 
1511 /*
1512  * System call wrappers (direct interfaces to the kernel)
1513  */
1514 extern  int     ___lwp_mutex_register(mutex_t *, mutex_t **);
1515 extern  int     ___lwp_mutex_trylock(mutex_t *, ulwp_t *);
1516 extern  int     ___lwp_mutex_timedlock(mutex_t *, timespec_t *, ulwp_t *);
1517 extern  int     ___lwp_mutex_unlock(mutex_t *);