diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-01-05 13:51:22 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-01-05 13:51:22 +0000 |
commit | d6c88c0f27b6e6c0006896e7fb3e47f0f7e992d8 (patch) | |
tree | 7cdbbed3366ccd9eec189ba14d2d48ff355912e4 /lib/libthr/thread/thr_private.h | |
parent | e065d5a1853d5ac2323fc116b1b2462841c0160e (diff) | |
download | FreeBSD-src-d6c88c0f27b6e6c0006896e7fb3e47f0f7e992d8.zip FreeBSD-src-d6c88c0f27b6e6c0006896e7fb3e47f0f7e992d8.tar.gz |
Refine thread suspension code, now thread suspension is a blockable
operation, the caller is blocked util target threads are really
suspended, also avoid suspending a thread when it is holding a
critical lock.
Fix a bug in _thr_ref_delete which tests a never set flag.
Diffstat (limited to 'lib/libthr/thread/thr_private.h')
-rw-r--r-- | lib/libthr/thread/thr_private.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index ddd75dc..6725a43 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -349,6 +349,12 @@ struct pthread { /* How many low level locks the thread held. */ int locklevel; + /* + * Set to non-zero when this thread has entered a critical + * region. We allow for recursive entries into critical regions. + */ + int critical_count; + /* Signal blocked counter. */ int sigblock; @@ -494,6 +500,10 @@ struct pthread { td_event_msg_t event_buf; }; +#define THR_IN_CRITICAL(thrd) \ + (((thrd)->locklevel > 0) || \ + ((thrd)->critical_count > 0)) + #define THR_UMTX_TRYLOCK(thrd, lck) \ _thr_umtx_trylock((lck), (thrd)->tid) @@ -517,6 +527,7 @@ do { \ if ((thrd)->locklevel > 0) { \ _thr_umtx_unlock((lck), (thrd)->tid); \ (thrd)->locklevel--; \ + _thr_ast(thrd); \ } else { \ _thr_assert_lock_level(); \ } \ @@ -673,6 +684,7 @@ void _thread_exit(char *, int, char *) __hidden __dead2; void _thr_exit_cleanup(void) __hidden; int _thr_ref_add(struct pthread *, struct pthread *, int) __hidden; void _thr_ref_delete(struct pthread *, struct pthread *) __hidden; +void _thr_ref_delete_unlocked(struct pthread *, struct pthread *) __hidden; int _thr_find_thread(struct pthread *, struct pthread *, int) __hidden; void _thr_rtld_init(void) __hidden; void _thr_rtld_fini(void) __hidden; @@ -695,10 +707,11 @@ void _thr_list_init(void) __hidden; void _thr_hash_add(struct pthread *) __hidden; void _thr_hash_remove(struct pthread *) __hidden; struct pthread *_thr_hash_find(struct pthread *) __hidden; -void _thr_link(struct pthread *curthread, struct pthread *thread) __hidden; -void _thr_unlink(struct pthread *curthread, struct pthread *thread) __hidden; -void _thr_suspend_check(struct pthread *curthread) __hidden; +void _thr_link(struct pthread *, struct pthread *) __hidden; +void _thr_unlink(struct pthread *, struct pthread *) __hidden; +void _thr_suspend_check(struct pthread *) __hidden; void _thr_assert_lock_level(void) __hidden __dead2; +void _thr_ast(struct pthread *) __hidden; void _thr_timer_init(void) __hidden; void _thr_report_creation(struct pthread *curthread, struct pthread *newthread) __hidden; |