diff options
author | davidxu <davidxu@FreeBSD.org> | 2003-12-09 02:20:56 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2003-12-09 02:20:56 +0000 |
commit | 22c52834eb703c132b4e7c6bd591610f1129d32d (patch) | |
tree | 336614966b1df2677098ac89ea3a03fc82f7141b /lib/libpthread/thread/thr_private.h | |
parent | 84e2c4c55b82cc4f62ab90c4141beffce4e30412 (diff) | |
download | FreeBSD-src-22c52834eb703c132b4e7c6bd591610f1129d32d.zip FreeBSD-src-22c52834eb703c132b4e7c6bd591610f1129d32d.tar.gz |
Rename _thr_enter_cancellation_point to _thr_cancel_enter, rename
_thr_leave_cancellation_point to _thr_cancel_leave, add a parameter
to _thr_cancel_leave to indicate whether cancellation point should be
checked, this gives us an option to not check cancallation point if
a syscall successfully returns to avoid any leaks, current I have
creat(), open() and fcntl(F_DUPFD) to not check cancellation point
after they sucessfully returned.
Replace some members in structure kse with bit flags to same some
memory.
Conditionally compile THR_ASSERT to nothing if _PTHREAD_INVARIANTS is
not defined.
Inline some small functions in thr_cancel.c.
Use __predict_false in thr_kern.c for some executed only once code.
Reviewd by: deischen
Diffstat (limited to 'lib/libpthread/thread/thr_private.h')
-rw-r--r-- | lib/libpthread/thread/thr_private.h | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index fc5f97e..8c344ec 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -81,12 +81,14 @@ #define DBG_MUTEX 0x0001 #define DBG_SIG 0x0002 - +#ifdef _PTHREADS_INVARIANTS #define THR_ASSERT(cond, msg) do { \ if (!(cond)) \ PANIC(msg); \ } while (0) - +#else +#define THR_ASSERT(cond, msg) +#endif /* * State change macro without scheduling queue change: @@ -192,15 +194,21 @@ struct kse { int k_flags; #define KF_STARTED 0x0001 /* kernel kse created */ #define KF_INITIALIZED 0x0002 /* initialized on 1st upcall */ -#define KF_TERMINATED 0x0004 - int k_idle; /* kse is idle */ +#define KF_TERMINATED 0x0004 /* kse is terminated */ +#define KF_IDLE 0x0008 /* kse is idle */ +#define KF_SWITCH 0x0010 /* thread switch in UTS */ int k_error; /* syscall errno in critical */ int k_cpu; /* CPU ID when bound */ - int k_done; /* this KSE is done */ - int k_switch; /* thread switch in UTS */ int k_sigseqno; /* signal buffered count */ }; +#define KSE_SET_IDLE(kse) ((kse)->k_flags |= KF_IDLE) +#define KSE_CLEAR_IDLE(kse) ((kse)->k_flags &= ~KF_IDLE) +#define KSE_IS_IDLE(kse) (((kse)->k_flags & KF_IDLE) != 0) +#define KSE_SET_SWITCH(kse) ((kse)->k_flags |= KF_SWITCH) +#define KSE_CLEAR_SWITCH(kse) ((kse)->k_flags &= ~KF_SWITCH) +#define KSE_IS_SWITCH(kse) (((kse)->k_flags & KF_SWITCH) != 0) + /* * Each KSE group contains one or more KSEs in which threads can run. * At least for now, there is one scheduling queue per KSE group; KSEs @@ -293,10 +301,6 @@ do { \ #define KSE_WAKEUP(kse) kse_wakeup(&(kse)->k_kcb->kcb_kmbx) -#define KSE_SET_IDLE(kse) ((kse)->k_idle = 1) -#define KSE_CLEAR_IDLE(kse) ((kse)->k_idle = 0) -#define KSE_IS_IDLE(kse) ((kse)->k_idle != 0) - /* * TailQ initialization values. */ @@ -659,7 +663,6 @@ struct pthread { int active; /* thread running */ int blocked; /* thread blocked in kernel */ int need_switchout; - int need_wakeup; /* * Used for tracking delivery of signal handlers. @@ -984,7 +987,15 @@ do { \ (((thrd)->state == PS_SUSPENDED) || \ (((thrd)->flags & THR_FLAGS_SUSPENDED) != 0)) #define THR_IS_EXITING(thrd) (((thrd)->flags & THR_FLAGS_EXITING) != 0) - + +extern int __isthreaded; + +static inline int +_kse_isthreaded(void) +{ + return (__isthreaded != 0); +} + /* * Global variables for the pthread kernel. */ @@ -1149,8 +1160,8 @@ void _thr_sig_rundown(struct pthread *, ucontext_t *, void _thr_sig_send(struct pthread *pthread, int sig); void _thr_sigframe_restore(struct pthread *thread, struct pthread_sigframe *psf); void _thr_spinlock_init(void); -void _thr_enter_cancellation_point(struct pthread *); -void _thr_leave_cancellation_point(struct pthread *); +void _thr_cancel_enter(struct pthread *); +void _thr_cancel_leave(struct pthread *, int); int _thr_setconcurrency(int new_level); int _thr_setmaxconcurrency(void); void _thr_critical_enter(struct pthread *); |