Deleted Added
sdiff udiff text old ( 113658 ) new ( 113661 )
full compact
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/libkse/thread/thr_private.h 113661 2003-04-18 07:09:43Z deischen $
35 */
36
37#ifndef _THR_PRIVATE_H
38#define _THR_PRIVATE_H
39
40/*
41 * Include files.
42 */

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

148/*
149 * Each KSEG has a scheduling queue. For now, threads that exist in their
150 * own KSEG (system scope) will get a full priority queue. In the future
151 * this can be optimized for the single thread per KSEG case.
152 */
153struct sched_queue {
154 pq_queue_t sq_runq;
155 TAILQ_HEAD(, pthread) sq_waitq; /* waiting in userland */
156};
157
158/* Used to maintain pending and active signals: */
159struct sigstatus {
160 siginfo_t *info; /* arg 2 to signal handler */
161 int pending; /* Is this a pending signal? */
162 int blocked; /*
163 * This signal has occured and hasn't

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

174#define MAX_KSE_LOCKLEVEL 3
175struct kse {
176 struct kse_mailbox k_mbx; /* kernel kse mailbox */
177 /* -- location and order specific items for gdb -- */
178 struct pthread *k_curthread; /* current thread */
179 struct kse_group *k_kseg; /* parent KSEG */
180 struct sched_queue *k_schedq; /* scheduling queue */
181 /* -- end of location and order specific items -- */
182 TAILQ_ENTRY(kse) k_qe; /* KSE list link entry */
183 TAILQ_ENTRY(kse) k_kgqe; /* KSEG's KSE list entry */
184 struct ksd k_ksd; /* KSE specific data */
185 /*
186 * Items that are only modified by the kse, or that otherwise
187 * don't need to be locked when accessed
188 */
189 struct lock k_lock;
190 struct lockuser k_lockusers[MAX_KSE_LOCKLEVEL];
191 int k_locklevel;

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

216 int kg_threadcount; /* # of assigned threads */
217 int kg_idle_kses;
218 int kg_flags;
219#define KGF_SINGLE_THREAD 0x0001 /* scope system kse group */
220#define KGF_SCHEDQ_INITED 0x0002 /* has an initialized schedq */
221};
222
223/*
224 * Add/remove threads from a KSE's scheduling queue.
225 * For now the scheduling queue is hung off the KSEG.
226 */
227#define KSEG_THRQ_ADD(kseg, thr) \
228do { \
229 TAILQ_INSERT_TAIL(&(kseg)->kg_threadq, thr, kle);\
230 (kseg)->kg_threadcount++; \
231} while (0)
232
233#define KSEG_THRQ_REMOVE(kseg, thr) \
234do { \
235 TAILQ_REMOVE(&(kseg)->kg_threadq, thr, kle); \
236 (kseg)->kg_threadcount--; \
237} while (0)
238
239
240/*
241 * Lock acquire and release for KSEs.
242 */
243#define KSE_LOCK_ACQUIRE(kse, lck) \
244do { \
245 if ((kse)->k_locklevel >= MAX_KSE_LOCKLEVEL) \
246 PANIC("Exceeded maximum lock level"); \
247 else { \
248 (kse)->k_locklevel++; \

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

872#define THR_LIST_REMOVE(thrd) do { \
873 if (((thrd)->flags & THR_FLAGS_IN_TDLIST) != 0) { \
874 TAILQ_REMOVE(&_thread_list, thrd, tle); \
875 (thrd)->flags &= ~THR_FLAGS_IN_TDLIST; \
876 } \
877} while (0)
878#define THR_GCLIST_ADD(thrd) do { \
879 if (((thrd)->flags & THR_FLAGS_IN_GCLIST) == 0) { \
880 TAILQ_INSERT_HEAD(&_thread_gc_list, thrd, gcle);\
881 (thrd)->flags |= THR_FLAGS_IN_GCLIST; \
882 _gc_count++; \
883 } \
884} while (0)
885#define THR_GCLIST_REMOVE(thrd) do { \
886 if (((thrd)->flags & THR_FLAGS_IN_GCLIST) != 0) { \
887 TAILQ_REMOVE(&_thread_gc_list, thrd, gcle); \
888 (thrd)->flags &= ~THR_FLAGS_IN_GCLIST; \
889 _gc_count--; \
890 } \
891} while (0)
892
893#define GC_NEEDED() (atomic_load_acq_int(&_gc_count) >= 5)
894
895/*
896 * Locking the scheduling queue for another thread uses that thread's
897 * KSEG lock.
898 */
899#define THR_SCHED_LOCK(curthr, thr) do { \
900 (curthr)->critical[(curthr)->locklevel] = _kse_critical_enter(); \
901 (curthr)->locklevel++; \
902 KSE_SCHED_LOCK((curthr)->kse, (thr)->kseg); \

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

981SCLASS sigset_t _thr_proc_sigmask SCLASS_PRESET({{0, 0, 0, 0}});
982SCLASS siginfo_t _thr_proc_siginfo[NSIG];
983
984SCLASS pid_t _thr_pid SCLASS_PRESET(0);
985
986/* Garbage collector lock. */
987SCLASS struct lock _gc_lock;
988SCLASS int _gc_check SCLASS_PRESET(0);
989SCLASS int _gc_count SCLASS_PRESET(0);
990
991SCLASS struct lock _mutex_static_lock;
992SCLASS struct lock _rwlock_static_lock;
993SCLASS struct lock _keytable_lock;
994SCLASS struct lock _thread_list_lock;
995SCLASS int _thr_guard_default;
996SCLASS int _thr_page_size;
997

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

1006 * Function prototype definitions.
1007 */
1008__BEGIN_DECLS
1009int _cond_reinit(pthread_cond_t *);
1010void _cond_wait_backout(struct pthread *);
1011struct pthread *_get_curthread(void);
1012struct kse *_get_curkse(void);
1013void _set_curkse(struct kse *);
1014struct kse *_kse_alloc(struct pthread *);
1015kse_critical_t _kse_critical_enter(void);
1016void _kse_critical_leave(kse_critical_t);
1017void _kse_free(struct pthread *, struct kse *);
1018void _kse_init();
1019struct kse_group *_kseg_alloc(struct pthread *);
1020void _kse_lock_wait(struct lock *, struct lockuser *lu);
1021void _kse_lock_wakeup(struct lock *, struct lockuser *lu);
1022void _kse_sig_check_pending(struct kse *);
1023void _kse_single_thread(struct pthread *);
1024void _kse_start(struct kse *);
1025void _kse_setthreaded(int);
1026int _kse_isthreaded(void);
1027int _mutex_cv_lock(pthread_mutex_t *);
1028int _mutex_cv_unlock(pthread_mutex_t *);
1029void _mutex_lock_backout(struct pthread *);
1030void _mutex_notify_priochange(struct pthread *, struct pthread *, int);
1031int _mutex_reinit(struct pthread_mutex *);
1032void _mutex_unlock_private(struct pthread *);
1033void _libpthread_init(struct pthread *);
1034int _pq_alloc(struct pq_queue *, int, int);
1035void _pq_free(struct pq_queue *);
1036int _pq_init(struct pq_queue *);
1037void _pq_remove(struct pq_queue *pq, struct pthread *);
1038void _pq_insert_head(struct pq_queue *pq, struct pthread *);
1039void _pq_insert_tail(struct pq_queue *pq, struct pthread *);
1040struct pthread *_pq_first(struct pq_queue *pq);
1041void *_pthread_getspecific(pthread_key_t);
1042int _pthread_key_create(pthread_key_t *, void (*) (void *));
1043int _pthread_key_delete(pthread_key_t);
1044int _pthread_mutex_destroy(pthread_mutex_t *);
1045int _pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);
1046int _pthread_mutex_lock(pthread_mutex_t *);
1047int _pthread_mutex_trylock(pthread_mutex_t *);
1048int _pthread_mutex_unlock(pthread_mutex_t *);
1049int _pthread_mutexattr_init(pthread_mutexattr_t *);
1050int _pthread_mutexattr_destroy(pthread_mutexattr_t *);
1051int _pthread_mutexattr_settype(pthread_mutexattr_t *, int);
1052int _pthread_once(pthread_once_t *, void (*) (void));
1053struct pthread *_pthread_self(void);
1054int _pthread_setspecific(pthread_key_t, const void *);
1055struct pthread *_thr_alloc(struct pthread *);
1056int _thread_enter_uts(struct kse_thr_mailbox *, struct kse_mailbox *);
1057int _thread_switch(struct kse_thr_mailbox *, struct kse_thr_mailbox **);
1058void _thr_exit(char *, int, char *);
1059void _thr_exit_cleanup(void);
1060void _thr_lock_wait(struct lock *lock, struct lockuser *lu);
1061void _thr_lock_wakeup(struct lock *lock, struct lockuser *lu);
1062int _thr_ref_add(struct pthread *, struct pthread *, int);
1063void _thr_ref_delete(struct pthread *, struct pthread *);
1064void _thr_schedule_add(struct pthread *, struct pthread *);
1065void _thr_schedule_remove(struct pthread *, struct pthread *);
1066void _thr_setrunnable(struct pthread *curthread, struct pthread *thread);
1067void _thr_setrunnable_unlocked(struct pthread *thread);
1068void _thr_sig_add(struct pthread *, int, siginfo_t *, ucontext_t *);
1069void _thr_sig_dispatch(struct kse *, int, siginfo_t *);
1070int _thr_stack_alloc(struct pthread_attr *);
1071void _thr_stack_free(struct pthread_attr *);
1072void _thr_exit_cleanup(void);
1073void _thr_free(struct pthread *, struct pthread *);
1074void _thr_gc(struct pthread *);
1075void _thr_panic_exit(char *, int, char *);
1076void _thread_cleanupspecific(void);
1077void _thread_dump_info(void);
1078void _thread_printf(int, const char *, ...);
1079void _thr_sched_frame(struct pthread_sigframe *);
1080void _thr_sched_switch(struct pthread *);
1081void _thr_set_timeout(const struct timespec *);
1082void _thr_sig_handler(int, siginfo_t *, ucontext_t *);

--- 92 unchanged lines hidden ---