diff options
author | julian <julian@FreeBSD.org> | 1996-08-20 08:22:01 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1996-08-20 08:22:01 +0000 |
commit | 7350d1d3b2ec940c89a2b20f9d09985d9fd9e9d7 (patch) | |
tree | b14348030d1048f8628b798374a8a061a990aae3 /lib/libpthread/thread/thr_private.h | |
parent | 60125bd1a9e42a8b02f15396ba886b417c95bbc1 (diff) | |
download | FreeBSD-src-7350d1d3b2ec940c89a2b20f9d09985d9fd9e9d7.zip FreeBSD-src-7350d1d3b2ec940c89a2b20f9d09985d9fd9e9d7.tar.gz |
Submitted by: John Birrell <cimaxp1!jb@werple.net.au>
Here are the diffs for libc_r to get it one step closer to P1003.1c
These make most of the thread/mutex/condvar structures opaque to the
user. There are three functions which have been renamed with _np
suffixes because they are extensions to P1003.1c (I did them for JAVA,
which needs to suspend/resume threads and also start threads suspended).
I've created a new header (pthread_np.h) for the non-POSIX stuff.
The egrep tags stuff in /usr/src/lib/libc_r/Makefile that I uncommented
doesn't work. I think its best to delete it. I don't think libc_r needs
tags anyway, 'cause most of the source is in libc which does have tags.
also:
Here's the first batch of man pages for the thread functions.
The diff to /usr/src/lib/libc_r/Makefile removes some stuff that was
inherited from /usr/src/lib/libc/Makefile that should only be done with
libc.
also:
I should have sent this diff with the pthread(3) man page.
It allows people to type
make -DWANT_LIBC_R world
to get libc_r built with the rest of the world. I put this in the
pthread(3) man page. The default is still not to build libc_r.
also:
The diff attached adds a pthread(3) man page to /usr/src/share/man/man3.
The idea is that without libc_r installed, this man page will give people
enough info to know that they have to build libc_r.
Diffstat (limited to 'lib/libpthread/thread/thr_private.h')
-rw-r--r-- | lib/libpthread/thread/thr_private.h | 148 |
1 files changed, 140 insertions, 8 deletions
diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index fc8ba27..48e70ce 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -59,6 +59,129 @@ #define PANIC(string) _thread_exit(__FILE__,__LINE__,string) /* + * Queue definitions. + */ +struct pthread_queue { + struct pthread *q_next; + struct pthread *q_last; + void *q_data; +}; + +/* + * Static queue initialization values. + */ +#define PTHREAD_QUEUE_INITIALIZER { NULL, NULL, NULL } + +/* + * Mutex definitions. + */ +enum pthread_mutextype { + MUTEX_TYPE_FAST = 1, + MUTEX_TYPE_COUNTING_FAST = 2, /* Recursive */ + MUTEX_TYPE_MAX +}; + +union pthread_mutex_data { + void *m_ptr; + int m_count; +}; + +struct pthread_mutex { + enum pthread_mutextype m_type; + struct pthread_queue m_queue; + struct pthread *m_owner; + union pthread_mutex_data m_data; + long m_flags; +}; + +/* + * Flags for mutexes. + */ +#define MUTEX_FLAGS_PRIVATE 0x01 +#define MUTEX_FLAGS_INITED 0x02 +#define MUTEX_FLAGS_BUSY 0x04 + +/* + * Static mutex initialization values. + */ +#define PTHREAD_MUTEX_INITIALIZER \ + { MUTEX_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, \ + NULL, { NULL }, MUTEX_FLAGS_INITED } + +struct pthread_mutex_attr { + enum pthread_mutextype m_type; + long m_flags; +}; + +/* + * Condition variable definitions. + */ +enum pthread_cond_type { + COND_TYPE_FAST, + COND_TYPE_MAX +}; + +struct pthread_cond { + enum pthread_cond_type c_type; + struct pthread_queue c_queue; + void *c_data; + long c_flags; +}; + +struct pthread_cond_attr { + enum pthread_cond_type c_type; + long c_flags; +}; + +/* + * Flags for condition variables. + */ +#define COND_FLAGS_PRIVATE 0x01 +#define COND_FLAGS_INITED 0x02 +#define COND_FLAGS_BUSY 0x04 + +/* + * Static cond initialization values. + */ +#define PTHREAD_COND_INITIALIZER \ + { COND_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, NULL, COND_FLAGS_INITED } + +/* + * Cleanup definitions. + */ +struct pthread_cleanup { + struct pthread_cleanup *next; + void (*routine) (); + void *routine_arg; +}; + +/* + * Scheduling definitions. + */ +enum schedparam_policy { + SCHED_RR, + SCHED_IO, + SCHED_FIFO, + SCHED_OTHER +}; + +struct pthread_attr { + enum schedparam_policy schedparam_policy; + int prio; + int suspend; + int flags; + void *arg_attr; + void (*cleanup_attr) (); + void *stackaddr_attr; + size_t stacksize_attr; +}; + +struct sched_param { + int prio; + void *no_data; +}; + +/* * Thread creation state attributes. */ #define PTHREAD_CREATE_RUNNING 0 @@ -67,14 +190,11 @@ /* * Miscellaneous definitions. */ -#define PTHREAD_STACK_MIN 1024 #define PTHREAD_STACK_DEFAULT 65536 -#define PTHREAD_DATAKEYS_MAX 256 #define PTHREAD_DEFAULT_PRIORITY 64 #define PTHREAD_MAX_PRIORITY 126 #define PTHREAD_MIN_PRIORITY 0 #define _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_DESTRUTOR_ITERATIONS 4 /* * Clock resolution in nanoseconds. @@ -190,10 +310,10 @@ struct pthread { * Thread start routine, argument, stack pointer and thread * attributes. */ - void *(*start_routine)(void *); - void *arg; - void *stack; - pthread_attr_t attr; + void *(*start_routine)(void *); + void *arg; + void *stack; + struct pthread_attr attr; /* * Thread-specific signal handler interface: @@ -319,6 +439,17 @@ SCLASS struct pthread *_thread_run ; #endif +/* + * Ptr to the thread running in single-threaded mode or NULL if + * running multi-threaded (default POSIX behaviour). + */ +SCLASS struct pthread *_thread_single +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL; +#else +; +#endif + /* Ptr to the first thread in the thread linked list: */ SCLASS struct pthread *_thread_link_list #ifdef GLOBAL_PTHREAD_PRIVATE @@ -372,7 +503,7 @@ SCLASS struct pthread *_thread_initial #endif /* Default thread attributes: */ -SCLASS pthread_attr_t pthread_attr_default +SCLASS struct pthread_attr pthread_attr_default #ifdef GLOBAL_PTHREAD_PRIVATE = { SCHED_RR, PTHREAD_DEFAULT_PRIORITY, PTHREAD_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, PTHREAD_STACK_DEFAULT }; @@ -570,6 +701,7 @@ pid_t _thread_sys_fork(void); pid_t _thread_sys_tcgetpgrp(int); ssize_t _thread_sys_read(int, void *, size_t); ssize_t _thread_sys_write(int, const void *, size_t); +void _thread_sys__exit(int); #endif /* #include <fcntl.h> */ |