Deleted Added
full compact
thr_private.h (127556) thr_private.h (129484)
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * Private thread definitions for the uthread kernel.
33 *
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * Private thread definitions for the uthread kernel.
33 *
34 * $FreeBSD: head/lib/libthr/thread/thr_private.h 127556 2004-03-29 05:45:01Z mtm $
34 * $FreeBSD: head/lib/libthr/thread/thr_private.h 129484 2004-05-20 12:06:16Z mtm $
35 */
36
37#ifndef _THR_PRIVATE_H
38#define _THR_PRIVATE_H
39
40/*
41 * Evaluate the storage class specifier.
42 */

--- 80 unchanged lines hidden (view full) ---

123 } while (0)
124
125#define UMTX_UNLOCK(m) \
126 do { \
127 if (umtx_unlock((m), curthread->thr_id) != 0) \
128 abort(); \
129 } while (0)
130
35 */
36
37#ifndef _THR_PRIVATE_H
38#define _THR_PRIVATE_H
39
40/*
41 * Evaluate the storage class specifier.
42 */

--- 80 unchanged lines hidden (view full) ---

123 } while (0)
124
125#define UMTX_UNLOCK(m) \
126 do { \
127 if (umtx_unlock((m), curthread->thr_id) != 0) \
128 abort(); \
129 } while (0)
130
131#define PTHREAD_LOCK(p) UMTX_LOCK(&(p)->lock)
132#define PTHREAD_UNLOCK(p) UMTX_UNLOCK(&(p)->lock)
131
133
132/*
133 * State change macro:
134 */
135#define PTHREAD_SET_STATE(thrd, newstate) do { \
136 (thrd)->state = newstate; \
137 (thrd)->fname = __FILE__; \
138 (thrd)->lineno = __LINE__; \
139} while (0)
134#define PTHREAD_WAKE(ptd) thr_wake((ptd)->thr_id)
140
135
141#define PTHREAD_NEW_STATE(thrd, newstate) do { \
142 if (newstate == PS_RUNNING) \
143 thr_wake(thrd->thr_id); \
144 PTHREAD_SET_STATE(thrd, newstate); \
145} while (0)
146
147/*
148 * TailQ initialization values.
149 */
150#define TAILQ_INITIALIZER { NULL, NULL }
151
152#define UMTX_INITIALIZER { NULL }
153
154struct pthread_mutex_attr {

--- 292 unchanged lines hidden (view full) ---

447 struct pthread_rwlock *rh_rwlock;
448 int rh_rdcount;
449 int rh_wrcount;
450};
451
452LIST_HEAD(rwlock_listhead, rwlock_held);
453
454/*
136/*
137 * TailQ initialization values.
138 */
139#define TAILQ_INITIALIZER { NULL, NULL }
140
141#define UMTX_INITIALIZER { NULL }
142
143struct pthread_mutex_attr {

--- 292 unchanged lines hidden (view full) ---

436 struct pthread_rwlock *rh_rwlock;
437 int rh_rdcount;
438 int rh_wrcount;
439};
440
441LIST_HEAD(rwlock_listhead, rwlock_held);
442
443/*
444 * The cancel mode a thread is in is determined by the
445 * the cancel type and state it is set in. The two values
446 * are combined into one mode:
447 * Mode State Type
448 * ---- ----- ----
449 * off disabled deferred
450 * off disabled async
451 * deferred enabled deferred
452 * async enabled async
453 */
454enum cancel_mode { M_OFF, M_DEFERRED, M_ASYNC };
455
456/*
457 * A thread's cancellation is pending until the cancel
458 * mode has been tested to determine if the thread can be
459 * cancelled immediately.
460 */
461enum cancellation_state { CS_NULL, CS_PENDING, CS_SET };
462
463/*
455 * Thread structure.
456 */
457struct pthread {
458 /*
459 * Magic value to help recognize a valid thread structure
460 * from an invalid one:
461 */
462#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
463 u_int32_t magic;
464 char *name;
465 u_int64_t uniqueid; /* for gdb */
466 thr_id_t thr_id;
467 sigset_t savedsig;
468 int signest; /* blocked signal netsting level */
464 * Thread structure.
465 */
466struct pthread {
467 /*
468 * Magic value to help recognize a valid thread structure
469 * from an invalid one:
470 */
471#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
472 u_int32_t magic;
473 char *name;
474 u_int64_t uniqueid; /* for gdb */
475 thr_id_t thr_id;
476 sigset_t savedsig;
477 int signest; /* blocked signal netsting level */
478 int ptdflags; /* used by other other threads
479 to signal this thread */
480 int isdead;
481 int isdeadlocked;
482 int exiting;
483 int cancellationpoint;
469
470 /*
471 * Lock for accesses to this thread structure.
472 */
473 struct umtx lock;
474
475 /* Queue entry for list of all threads: */
476 TAILQ_ENTRY(pthread) tle;

--- 11 unchanged lines hidden (view full) ---

488 struct pthread_attr attr;
489
490 /*
491 * Machine context, including signal state.
492 */
493 ucontext_t ctx;
494
495 /*
484
485 /*
486 * Lock for accesses to this thread structure.
487 */
488 struct umtx lock;
489
490 /* Queue entry for list of all threads: */
491 TAILQ_ENTRY(pthread) tle;

--- 11 unchanged lines hidden (view full) ---

503 struct pthread_attr attr;
504
505 /*
506 * Machine context, including signal state.
507 */
508 ucontext_t ctx;
509
510 /*
496 * Cancelability flags - the lower 2 bits are used by cancel
497 * definitions in pthread.h
511 * The primary method of obtaining a thread's cancel state
512 * and type is through cancelmode. The cancelstate field is
513 * only so we don't loose the cancel state when the mode is
514 * turned off.
498 */
515 */
499#define PTHREAD_AT_CANCEL_POINT 0x0004
500#define PTHREAD_CANCELLING 0x0008
516 enum cancel_mode cancelmode;
517 enum cancel_mode cancelstate;
501
518
502 /*
503 * Protected by Giant.
504 */
505 int cancelflags;
519 /* Specifies if cancellation is pending, acted upon, or neither. */
520 enum cancellation_state cancellation;
506
521
507 /* Thread state: */
508 enum pthread_state state;
509
510 /*
511 * Error variable used instead of errno. The function __error()
512 * returns a pointer to this.
513 */
514 int error;
515
516 /*
517 * The joiner is the thread that is joining to this thread. The

--- 5 unchanged lines hidden (view full) ---

523 /*
524 * A thread can belong to:
525 *
526 * o A queue of threads waiting for a mutex
527 * o A queue of threads waiting for a condition variable
528 *
529 * A thread can also be joining a thread (the joiner field above).
530 *
522 /*
523 * Error variable used instead of errno. The function __error()
524 * returns a pointer to this.
525 */
526 int error;
527
528 /*
529 * The joiner is the thread that is joining to this thread. The

--- 5 unchanged lines hidden (view full) ---

535 /*
536 * A thread can belong to:
537 *
538 * o A queue of threads waiting for a mutex
539 * o A queue of threads waiting for a condition variable
540 *
541 * A thread can also be joining a thread (the joiner field above).
542 *
531 * It must not be possible for a thread to belong to any of the
532 * above queues while it is handling a signal. Signal handlers
533 * may longjmp back to previous stack frames circumventing normal
534 * control flow. This could corrupt queue integrity if the thread
535 * retains membership in the queue. Therefore, if a thread is a
536 * member of one of these queues when a signal handler is invoked,
537 * it must remove itself from the queue before calling the signal
538 * handler and reinsert itself after normal return of the handler.
539 *
540 * Use sqe for synchronization (mutex and condition variable) queue
541 * links.
542 */
543 TAILQ_ENTRY(pthread) sqe; /* synchronization queue link */
544
545 /* Wait data. */
546 union pthread_wait_data data;
547
548 /* Miscellaneous flags; only set with signals deferred. */
549 int flags;
550#define PTHREAD_FLAGS_PRIVATE 0x0001
543 * Use sqe for synchronization (mutex and condition variable) queue
544 * links.
545 */
546 TAILQ_ENTRY(pthread) sqe; /* synchronization queue link */
547
548 /* Wait data. */
549 union pthread_wait_data data;
550
551 /* Miscellaneous flags; only set with signals deferred. */
552 int flags;
553#define PTHREAD_FLAGS_PRIVATE 0x0001
551#define PTHREAD_EXITING 0x0002
552#define PTHREAD_FLAGS_BARR_REL 0x0004 /* has been released from barrier */
554#define PTHREAD_FLAGS_BARR_REL 0x0004 /* has been released from barrier */
555#define PTHREAD_FLAGS_IN_BARRQ 0x0008 /* in barrier queue using sqe link */
553#define PTHREAD_FLAGS_IN_CONDQ 0x0080 /* in condition queue using sqe link*/
554#define PTHREAD_FLAGS_IN_MUTEXQ 0x0100 /* in mutex queue using sqe link */
555#define PTHREAD_FLAGS_SUSPENDED 0x0200 /* thread is suspended */
556#define PTHREAD_FLAGS_TRACE 0x0400 /* for debugging purposes */
557#define PTHREAD_FLAGS_IN_SYNCQ \
556#define PTHREAD_FLAGS_IN_CONDQ 0x0080 /* in condition queue using sqe link*/
557#define PTHREAD_FLAGS_IN_MUTEXQ 0x0100 /* in mutex queue using sqe link */
558#define PTHREAD_FLAGS_SUSPENDED 0x0200 /* thread is suspended */
559#define PTHREAD_FLAGS_TRACE 0x0400 /* for debugging purposes */
560#define PTHREAD_FLAGS_IN_SYNCQ \
558 (PTHREAD_FLAGS_IN_CONDQ | PTHREAD_FLAGS_IN_MUTEXQ)
561 (PTHREAD_FLAGS_IN_CONDQ | PTHREAD_FLAGS_IN_MUTEXQ | PTHREAD_FLAGS_IN_BARRQ)
562#define PTHREAD_FLAGS_NOT_RUNNING \
563 (PTHREAD_FLAGS_IN_SYNCQ | PTHREAD_FLAGS_SUSPENDED)
559
560 /*
561 * Base priority is the user setable and retrievable priority
562 * of the thread. It is only affected by explicit calls to
563 * set thread priority and upon thread creation via a thread
564 * attribute or default priority.
565 */
566 char base_priority;

--- 201 unchanged lines hidden (view full) ---

768int _pthread_setspecific(pthread_key_t, const void *);
769int _spintrylock(spinlock_t *);
770void _thread_exit(char *, int, char *);
771void _thread_exit_cleanup(void);
772void *_thread_cleanup(pthread_t);
773void _thread_cleanupspecific(void);
774void _thread_dump_info(void);
775void _thread_init(void);
564
565 /*
566 * Base priority is the user setable and retrievable priority
567 * of the thread. It is only affected by explicit calls to
568 * set thread priority and upon thread creation via a thread
569 * attribute or default priority.
570 */
571 char base_priority;

--- 201 unchanged lines hidden (view full) ---

773int _pthread_setspecific(pthread_key_t, const void *);
774int _spintrylock(spinlock_t *);
775void _thread_exit(char *, int, char *);
776void _thread_exit_cleanup(void);
777void *_thread_cleanup(pthread_t);
778void _thread_cleanupspecific(void);
779void _thread_dump_info(void);
780void _thread_init(void);
776void _thread_sig_wrapper(int sig, siginfo_t *info, void *context);
777void _thread_printf(int fd, const char *, ...);
778void _thread_start(void);
779void _thread_seterrno(pthread_t, int);
780void _thread_enter_cancellation_point(void);
781void _thread_leave_cancellation_point(void);
782void _thread_cancellation_point(void);
783int _thread_suspend(pthread_t thread, const struct timespec *abstime);
784void _thread_critical_enter(pthread_t);

--- 121 unchanged lines hidden ---
781void _thread_printf(int fd, const char *, ...);
782void _thread_start(void);
783void _thread_seterrno(pthread_t, int);
784void _thread_enter_cancellation_point(void);
785void _thread_leave_cancellation_point(void);
786void _thread_cancellation_point(void);
787int _thread_suspend(pthread_t thread, const struct timespec *abstime);
788void _thread_critical_enter(pthread_t);

--- 121 unchanged lines hidden ---