From 73e4f7b939e100687a39d95bf490e9a15c0d8780 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 30 Jun 2003 23:54:04 +0000 Subject: [PATCH] Add threads to the process-retrieval sysctls so they show up in top, ps, etc. Reorder the boot sequence a little to add a TAILQ for all threads. Add a td_refs field to prevent a thread from disappearing on us. --- sys/i386/i386/machdep.c | 28 +++++---- sys/kern/init_main.c | 4 +- sys/kern/kern_exit.c | 3 +- sys/kern/kern_proc.c | 99 +++++++++++++++++++++++++------- sys/kern/lwkt_thread.c | 64 ++++++++++++++++----- sys/platform/pc32/i386/machdep.c | 28 +++++---- sys/sys/globaldata.h | 3 +- sys/sys/proc.h | 5 +- sys/sys/rtprio.h | 3 +- sys/sys/thread.h | 9 ++- sys/sys/user.h | 3 +- 11 files changed, 183 insertions(+), 66 deletions(-) diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 5d7d92fd5f..8c291337ea 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.18 2003/06/30 19:50:30 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.19 2003/06/30 23:54:00 dillon Exp $ */ #include "apm.h" @@ -1830,15 +1830,7 @@ init386(int first) */ gd = &CPU_prvspace[0].mdglobaldata; - lwkt_init_thread(&thread0, proc0paddr, 0, &gd->mi); gd->mi.gd_curthread = &thread0; - safepri = thread0.td_cpl = SWI_MASK | HWI_MASK; - thread0.td_switch = cpu_heavy_switch; /* YYY eventually LWKT */ - proc0.p_addr = (void *)thread0.td_kstack; - proc0.p_thread = &thread0; - proc0.p_flag |= P_CURPROC; - gd->mi.gd_uprocscheduled = 1; - thread0.td_proc = &proc0; atdevbase = ISA_HOLE_START + KERNBASE; @@ -1880,9 +1872,6 @@ init386(int first) * early in the boot sequence because the system assumes * that 'curthread' is never NULL. */ - /* YYY use prvspace for UP too and set here rather then later */ - mi_gdinit(&gd->mi, 0); - cpu_gdinit(gd, 0); for (x = 0; x < NGDT; x++) { #ifdef BDE_DEBUGGER @@ -1897,6 +1886,18 @@ init386(int first) r_gdt.rd_base = (int) gdt; lgdt(&r_gdt); + mi_gdinit(&gd->mi, 0); + cpu_gdinit(gd, 0); + lwkt_init_thread(&thread0, proc0paddr, 0, &gd->mi); + lwkt_set_comm(&thread0, "thread0"); + proc0.p_addr = (void *)thread0.td_kstack; + proc0.p_thread = &thread0; + proc0.p_flag |= P_CURPROC; + gd->mi.gd_uprocscheduled = 1; + thread0.td_proc = &proc0; + thread0.td_switch = cpu_heavy_switch; /* YYY eventually LWKT */ + safepri = thread0.td_cpl = SWI_MASK | HWI_MASK; + /* make ldt memory segments */ /* * XXX - VM_MAXUSER_ADDRESS is an end address, not a max. And it @@ -2045,6 +2046,8 @@ init386(int first) * data space were allocated in locore. * * Note: the idlethread's cpl is 0 + * + * WARNING! Called from early boot, 'mycpu' may not work yet. */ void cpu_gdinit(struct mdglobaldata *gd, int cpu) @@ -2057,6 +2060,7 @@ cpu_gdinit(struct mdglobaldata *gd, int cpu) gd->mi.gd_idletd = &gd->gd_idlethread; sp = gd->mi.gd_prvspace->idlestack; lwkt_init_thread(&gd->gd_idlethread, sp, 0, &gd->mi); + lwkt_set_comm(&gd->gd_idlethread, "idle_%d", cpu); gd->gd_idlethread.td_switch = cpu_lwkt_switch; gd->gd_idlethread.td_sp -= sizeof(void *); *(void **)gd->gd_idlethread.td_sp = cpu_idle_restore; diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index dd86cbdb08..9806e84dc3 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.16 2003/06/30 19:50:31 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.17 2003/06/30 23:54:02 dillon Exp $ */ #include "opt_init_path.h" @@ -574,6 +574,8 @@ SYSINIT(kickinit,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kick_init, NULL) /* * Machine independant globaldata initialization + * + * WARNING! Called from early boot, 'mycpu' may not work yet. */ void mi_gdinit(struct globaldata *gd, int cpuid) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index d29141f42e..edfa8a2cba 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,7 +37,7 @@ * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 * $FreeBSD: src/sys/kern/kern_exit.c,v 1.92.2.11 2003/01/13 22:51:16 dillon Exp $ - * $DragonFly: src/sys/kern/kern_exit.c,v 1.13 2003/06/30 22:19:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.14 2003/06/30 23:54:02 dillon Exp $ */ #include "opt_compat.h" @@ -464,6 +464,7 @@ loop: while (p->p_lock) tsleep(p, PWAIT, "reap2", hz); } + lwkt_wait_free(p->p_thread); /* charge childs scheduling cpu usage to parent */ if (curproc->p_pid != 1) { diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index eb03eea959..1307721fb1 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -32,7 +32,7 @@ * * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95 * $FreeBSD: src/sys/kern/kern_proc.c,v 1.63.2.9 2003/05/08 07:47:16 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_proc.c,v 1.8 2003/06/30 22:19:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_proc.c,v 1.9 2003/06/30 23:54:02 dillon Exp $ */ #include @@ -57,8 +57,11 @@ static MALLOC_DEFINE(M_PROC, "proc", "Proc structures"); MALLOC_DEFINE(M_SUBPROC, "subproc", "Proc sub-structures"); static int ps_showallprocs = 1; +static int ps_showallthreads = 1; SYSCTL_INT(_kern, OID_AUTO, ps_showallprocs, CTLFLAG_RW, &ps_showallprocs, 0, ""); +SYSCTL_INT(_kern, OID_AUTO, ps_showallthreads, CTLFLAG_RW, + &ps_showallthreads, 0, ""); static void pgdelete __P((struct pgrp *)); @@ -349,22 +352,48 @@ DB_SHOW_COMMAND(pgrpdump, pgrpdump) } #endif /* DDB */ +/* + * Fill in an eproc structure for the specified thread. + */ +void +fill_eproc_td(thread_t td, struct eproc *ep, struct proc *xp) +{ + bzero(ep, sizeof(*ep)); + + ep->e_uticks = td->td_uticks; + ep->e_sticks = td->td_sticks; + ep->e_iticks = td->td_iticks; + ep->e_tdev = NOUDEV; + if (td->td_wmesg) { + strncpy(ep->e_wmesg, td->td_wmesg, WMESGLEN); + ep->e_wmesg[WMESGLEN] = 0; + } + + /* + * Fake up portions of the proc structure copied out by the sysctl + * to return useful information. Note that using td_pri directly + * is messy because it includes critial section data so we fake + * up an rtprio.prio for threads. + */ + if (xp) { + *xp = *initproc; + xp->p_rtprio.type = RTP_PRIO_THREAD; + xp->p_rtprio.prio = td->td_pri & TDPRI_MASK; + xp->p_pid = -1; + } +} + /* * Fill in an eproc structure for the specified process. */ void -fill_eproc(p, ep) - register struct proc *p; - register struct eproc *ep; +fill_eproc(struct proc *p, struct eproc *ep) { - register struct tty *tp; + struct tty *tp; - bzero(ep, sizeof(*ep)); + fill_eproc_td(p->p_thread, ep, NULL); ep->e_paddr = p; - ep->e_uticks = p->p_thread->td_uticks; - ep->e_sticks = p->p_thread->td_sticks; - ep->e_iticks = p->p_thread->td_iticks; if (p->p_ucred) { ep->e_ucred = *p->p_ucred; } @@ -399,11 +428,8 @@ fill_eproc(p, ep) ep->e_tdev = dev2udev(tp->t_dev); ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; ep->e_tsess = tp->t_session; - } else + } else { ep->e_tdev = NOUDEV; - if (p->p_wmesg) { - strncpy(ep->e_wmesg, p->p_wmesg, WMESGLEN); - ep->e_wmesg[WMESGLEN] = 0; } } @@ -419,26 +445,37 @@ zpfind(pid_t pid) } static int -sysctl_out_proc(struct proc *p, struct sysctl_req *req, int doingzomb) +sysctl_out_proc(struct proc *p, struct thread *td, struct sysctl_req *req, int doingzomb) { struct eproc eproc; + struct proc xproc; int error; +#if 0 pid_t pid = p->p_pid; - - fill_eproc(p, &eproc); - error = SYSCTL_OUT(req,(caddr_t)p, sizeof(struct proc)); +#endif + + if (p) { + td = p->p_thread; + fill_eproc(p, &eproc); + xproc = *p; + } else if (td) { + fill_eproc_td(td, &eproc, &xproc); + } + error = SYSCTL_OUT(req,(caddr_t)&xproc, sizeof(struct proc)); if (error) return (error); error = SYSCTL_OUT(req,(caddr_t)&eproc, sizeof(eproc)); if (error) return (error); - error = SYSCTL_OUT(req,(caddr_t)&p->p_thread, sizeof(struct thread)); + error = SYSCTL_OUT(req,(caddr_t)td, sizeof(struct thread)); if (error) return (error); +#if 0 if (!doingzomb && pid && (pfind(pid) != p)) return EAGAIN; if (doingzomb && zpfind(pid) != p) return EAGAIN; +#endif return (0); } @@ -448,6 +485,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) int *name = (int*) arg1; u_int namelen = arg2; struct proc *p; + struct thread *td; int doingzomb; int error = 0; struct ucred *cr1 = curproc->p_ucred; @@ -460,7 +498,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) return (0); if (!PRISON_CHECK(cr1, p->p_ucred)) return (0); - error = sysctl_out_proc(p, req, 0); + error = sysctl_out_proc(p, NULL, req, 0); return (error); } if (oidp->oid_number == KERN_PROC_ALL && !namelen) @@ -497,7 +535,6 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) * do by session. */ switch (oidp->oid_number) { - case KERN_PROC_PGRP: /* could do this by traversing pgrp */ if (p->p_pgrp == NULL || @@ -530,12 +567,32 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) if (!PRISON_CHECK(cr1, p->p_ucred)) continue; PHOLD(p); - error = sysctl_out_proc(p, req, doingzomb); + error = sysctl_out_proc(p, NULL, req, doingzomb); PRELE(p); if (error) return (error); } } + if (ps_showallthreads) { + TAILQ_FOREACH(td, &mycpu->gd_tdallq, td_allq) { + if (td->td_proc) + continue; + switch (oidp->oid_number) { + case KERN_PROC_PGRP: + case KERN_PROC_TTY: + case KERN_PROC_UID: + case KERN_PROC_RUID: + continue; + default: + break; + } + lwkt_hold(td); + error = sysctl_out_proc(NULL, td, req, doingzomb); + lwkt_rele(td); + if (error) + return (error); + } + } return (0); } diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c index 88f12ec35c..3889887720 100644 --- a/sys/kern/lwkt_thread.c +++ b/sys/kern/lwkt_thread.c @@ -27,7 +27,7 @@ * thread scheduler, which means that generally speaking we only need * to use a critical section to prevent hicups. * - * $DragonFly: src/sys/kern/lwkt_thread.c,v 1.12 2003/06/30 19:50:31 dillon Exp $ + * $DragonFly: src/sys/kern/lwkt_thread.c,v 1.13 2003/06/30 23:54:02 dillon Exp $ */ #include @@ -108,7 +108,7 @@ _lwkt_enqueue(thread_t td) /* * LWKTs operate on a per-cpu basis * - * YYY implement strict priorities & round-robin at the same priority + * WARNING! Called from early boot, 'mycpu' may not work yet. */ void lwkt_gdinit(struct globaldata *gd) @@ -118,6 +118,7 @@ lwkt_gdinit(struct globaldata *gd) for (i = 0; i < sizeof(gd->gd_tdrunq)/sizeof(gd->gd_tdrunq[0]); ++i) TAILQ_INIT(&gd->gd_tdrunq[i]); gd->gd_runqmask = 0; + TAILQ_INIT(&gd->gd_tdallq); } /* @@ -185,26 +186,63 @@ lwkt_init_thread(thread_t td, void *stack, int flags, struct globaldata *gd) td->td_gd = gd; td->td_pri = TDPRI_CRIT; pmap_init_thread(td); + crit_enter(); + TAILQ_INSERT_TAIL(&mycpu->gd_tdallq, td, td_allq); + crit_exit(); +} + +void +lwkt_set_comm(thread_t td, const char *ctl, ...) +{ + va_list va; + + va_start(va, ctl); + vsnprintf(td->td_comm, sizeof(td->td_comm), ctl, va); + va_end(va); } void -lwkt_free_thread(struct thread *td) +lwkt_hold(thread_t td) { + ++td->td_refs; +} + +void +lwkt_rele(thread_t td) +{ + KKASSERT(td->td_refs > 0); + --td->td_refs; +} + +void +lwkt_wait_free(thread_t td) +{ + while (td->td_refs) + tsleep(td, PWAIT, "tdreap", hz); +} + +void +lwkt_free_thread(thread_t td) +{ + struct globaldata *gd = mycpu; + KASSERT(td->td_flags & TDF_EXITED, ("lwkt_free_thread: did not exit! %p", td)); crit_enter(); - if (mycpu->gd_tdfreecount < CACHE_NTHREADS && + TAILQ_REMOVE(&gd->gd_tdallq, td, td_allq); + if (gd->gd_tdfreecount < CACHE_NTHREADS && (td->td_flags & TDF_ALLOCATED_THREAD) ) { - ++mycpu->gd_tdfreecount; - TAILQ_INSERT_HEAD(&mycpu->gd_tdfreeq, td, td_threadq); + ++gd->gd_tdfreecount; + TAILQ_INSERT_HEAD(&gd->gd_tdfreeq, td, td_threadq); crit_exit(); } else { crit_exit(); if (td->td_kstack && (td->td_flags & TDF_ALLOCATED_STACK)) { kmem_free(kernel_map, (vm_offset_t)td->td_kstack, UPAGES * PAGE_SIZE); + /* gd invalid */ td->td_kstack = NULL; } if (td->td_flags & TDF_ALLOCATED_THREAD) @@ -308,9 +346,9 @@ again: * switch. */ void -lwkt_preempt(struct thread *ntd, int id) +lwkt_preempt(thread_t ntd, int id) { - struct thread *td = curthread; + thread_t td = curthread; /* * The caller has put us in a critical section, and in order to have @@ -602,7 +640,7 @@ lwkt_setpri_self(int pri) struct proc * lwkt_preempted_proc(void) { - struct thread *td = curthread; + thread_t td = curthread; while (td->td_preempted) td = td->td_preempted; return(td->td_proc); @@ -761,10 +799,10 @@ lwkt_regettoken(lwkt_token_t tok) */ int lwkt_create(void (*func)(void *), void *arg, - struct thread **tdp, struct thread *template, int tdflags, + struct thread **tdp, thread_t template, int tdflags, const char *fmt, ...) { - struct thread *td; + thread_t td; va_list ap; td = *tdp = lwkt_alloc_thread(template); @@ -815,7 +853,7 @@ int kthread_create(void (*func)(void *), void *arg, struct thread **tdp, const char *fmt, ...) { - struct thread *td; + thread_t td; va_list ap; td = *tdp = lwkt_alloc_thread(NULL); @@ -839,7 +877,7 @@ kthread_create(void (*func)(void *), void *arg, void crit_panic(void) { - struct thread *td = curthread; + thread_t td = curthread; int lpri = td->td_pri; td->td_pri = 0; diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index dea7d87848..a93192850e 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.18 2003/06/30 19:50:30 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.19 2003/06/30 23:54:00 dillon Exp $ */ #include "apm.h" @@ -1830,15 +1830,7 @@ init386(int first) */ gd = &CPU_prvspace[0].mdglobaldata; - lwkt_init_thread(&thread0, proc0paddr, 0, &gd->mi); gd->mi.gd_curthread = &thread0; - safepri = thread0.td_cpl = SWI_MASK | HWI_MASK; - thread0.td_switch = cpu_heavy_switch; /* YYY eventually LWKT */ - proc0.p_addr = (void *)thread0.td_kstack; - proc0.p_thread = &thread0; - proc0.p_flag |= P_CURPROC; - gd->mi.gd_uprocscheduled = 1; - thread0.td_proc = &proc0; atdevbase = ISA_HOLE_START + KERNBASE; @@ -1880,9 +1872,6 @@ init386(int first) * early in the boot sequence because the system assumes * that 'curthread' is never NULL. */ - /* YYY use prvspace for UP too and set here rather then later */ - mi_gdinit(&gd->mi, 0); - cpu_gdinit(gd, 0); for (x = 0; x < NGDT; x++) { #ifdef BDE_DEBUGGER @@ -1897,6 +1886,18 @@ init386(int first) r_gdt.rd_base = (int) gdt; lgdt(&r_gdt); + mi_gdinit(&gd->mi, 0); + cpu_gdinit(gd, 0); + lwkt_init_thread(&thread0, proc0paddr, 0, &gd->mi); + lwkt_set_comm(&thread0, "thread0"); + proc0.p_addr = (void *)thread0.td_kstack; + proc0.p_thread = &thread0; + proc0.p_flag |= P_CURPROC; + gd->mi.gd_uprocscheduled = 1; + thread0.td_proc = &proc0; + thread0.td_switch = cpu_heavy_switch; /* YYY eventually LWKT */ + safepri = thread0.td_cpl = SWI_MASK | HWI_MASK; + /* make ldt memory segments */ /* * XXX - VM_MAXUSER_ADDRESS is an end address, not a max. And it @@ -2045,6 +2046,8 @@ init386(int first) * data space were allocated in locore. * * Note: the idlethread's cpl is 0 + * + * WARNING! Called from early boot, 'mycpu' may not work yet. */ void cpu_gdinit(struct mdglobaldata *gd, int cpu) @@ -2057,6 +2060,7 @@ cpu_gdinit(struct mdglobaldata *gd, int cpu) gd->mi.gd_idletd = &gd->gd_idlethread; sp = gd->mi.gd_prvspace->idlestack; lwkt_init_thread(&gd->gd_idlethread, sp, 0, &gd->mi); + lwkt_set_comm(&gd->gd_idlethread, "idle_%d", cpu); gd->gd_idlethread.td_switch = cpu_lwkt_switch; gd->gd_idlethread.td_sp -= sizeof(void *); *(void **)gd->gd_idlethread.td_sp = cpu_idle_restore; diff --git a/sys/sys/globaldata.h b/sys/sys/globaldata.h index 1724032574..18be29159d 100644 --- a/sys/sys/globaldata.h +++ b/sys/sys/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/sys/globaldata.h,v 1.4 2003/06/30 19:50:32 dillon Exp $ + * $DragonFly: src/sys/sys/globaldata.h,v 1.5 2003/06/30 23:54:04 dillon Exp $ */ #ifndef _SYS_GLOBALDATA_H_ @@ -68,6 +68,7 @@ struct globaldata { struct thread *gd_idletd; /* a bit messy but it works */ int gd_tdfreecount; /* new thread cache */ int gd_reqpri; /* (see note above) */ + TAILQ_HEAD(,thread) gd_tdallq; /* all threads */ TAILQ_HEAD(,thread) gd_tdfreeq; /* new thread cache */ TAILQ_HEAD(,thread) gd_tdrunq[32]; /* runnable threads */ u_int32_t gd_runqmask; /* which queues? */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 7a461f8be1..e227f8eeeb 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.19 2003/06/30 19:50:32 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.20 2003/06/30 23:54:04 dillon Exp $ */ #ifndef _SYS_PROC_H_ @@ -205,7 +205,6 @@ struct proc { stack_t p_sigstk; /* sp & on stack state variable */ u_char p_priority; /* Tracks user sched queue */ char p_nice; /* Process "nice" value. */ - char p_comm[MAXCOMLEN+1]; struct pgrp *p_pgrp; /* Pointer to process group. */ @@ -234,6 +233,7 @@ struct proc { #if defined(_KERNEL) #define p_wchan p_thread->td_wchan #define p_wmesg p_thread->td_wmesg +#define p_comm p_thread->td_comm #define p_session p_pgrp->pg_session #define p_pgid p_pgrp->pg_id #endif @@ -244,6 +244,7 @@ struct proc { #define SSLEEP 3 /* Sleeping on an address. */ #define SSTOP 4 /* Process debugging or suspension. */ #define SZOMB 5 /* Awaiting collection by parent. */ +#define STHREAD 6 /* Synthesized for eproc only */ /* These flags are kept in p_flags. */ #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */ diff --git a/sys/sys/rtprio.h b/sys/sys/rtprio.h index 5cf4716c98..fd1d3de954 100644 --- a/sys/sys/rtprio.h +++ b/sys/sys/rtprio.h @@ -29,7 +29,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/rtprio.h,v 1.9 1999/12/29 04:24:46 peter Exp $ - * $DragonFly: src/sys/sys/rtprio.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/rtprio.h,v 1.3 2003/06/30 23:54:04 dillon Exp $ */ #ifndef _SYS_RTPRIO_H_ @@ -44,6 +44,7 @@ #define RTP_PRIO_REALTIME 0 #define RTP_PRIO_NORMAL 1 #define RTP_PRIO_IDLE 2 +#define RTP_PRIO_THREAD 3 /* RTP_PRIO_FIFO is POSIX.1B SCHED_FIFO. */ diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 2f3c533808..2f9d412053 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -4,7 +4,7 @@ * Implements the architecture independant portion of the LWKT * subsystem. * - * $DragonFly: src/sys/sys/thread.h,v 1.16 2003/06/30 19:50:32 dillon Exp $ + * $DragonFly: src/sys/sys/thread.h,v 1.17 2003/06/30 23:54:04 dillon Exp $ */ #ifndef _SYS_THREAD_H_ @@ -125,6 +125,7 @@ typedef struct lwkt_rwlock { */ struct thread { TAILQ_ENTRY(thread) td_threadq; + TAILQ_ENTRY(thread) td_allq; struct proc *td_proc; /* (optional) associated process */ struct pcb *td_pcb; /* points to pcb and top of kstack */ struct globaldata *td_gd; /* associated with this cpu */ @@ -142,6 +143,7 @@ struct thread { u_int64_t td_sticks; /* Statclock hits in system mode (uS) */ u_int64_t td_iticks; /* Statclock hits processing intr (uS) */ int td_locks; /* lockmgr lock debugging YYY */ + int td_refs; /* hold position in gd_tdallq / hold free */ char td_comm[MAXCOMLEN+1]; /* typ 16+1 bytes */ struct thread *td_preempted; /* we preempted this thread */ struct md_thread td_mach; @@ -157,6 +159,7 @@ struct thread { #define TDF_PREEMPT_LOCK 0x0004 /* I have been preempted */ #define TDF_PREEMPT_DONE 0x0008 /* acknowledge preemption complete */ +#define TDF_ONALLQ 0x0100 /* on gd_tdallq */ #define TDF_ALLOCATED_THREAD 0x0200 /* zalloc allocated thread */ #define TDF_ALLOCATED_STACK 0x0400 /* zalloc allocated stack */ #define TDF_VERBOSE 0x0800 /* verbose on exit */ @@ -202,6 +205,8 @@ extern struct vm_zone *thread_zone; extern struct thread *lwkt_alloc_thread(struct thread *template); extern void lwkt_init_thread(struct thread *td, void *stack, int flags, struct globaldata *gd); +extern void lwkt_set_comm(thread_t td, const char *ctl, ...); +extern void lwkt_wait_free(struct thread *td); extern void lwkt_free_thread(struct thread *td); extern void lwkt_init_wait(struct lwkt_wait *w); extern void lwkt_gdinit(struct globaldata *gd); @@ -213,6 +218,8 @@ extern void lwkt_deschedule(thread_t td); extern void lwkt_deschedule_self(void); extern void lwkt_yield(void); extern void lwkt_yield_quick(void); +extern void lwkt_hold(thread_t td); +extern void lwkt_rele(thread_t td); extern void lwkt_block(lwkt_wait_t w, const char *wmesg, int *gen); extern void lwkt_signal(lwkt_wait_t w); diff --git a/sys/sys/user.h b/sys/sys/user.h index 7bd0a5ef2c..8862fa5c94 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -32,7 +32,7 @@ * * @(#)user.h 8.2 (Berkeley) 9/23/93 * $FreeBSD: src/sys/sys/user.h,v 1.24.2.1 2001/10/11 08:20:18 peter Exp $ - * $DragonFly: src/sys/sys/user.h,v 1.7 2003/06/28 04:16:05 dillon Exp $ + * $DragonFly: src/sys/sys/user.h,v 1.8 2003/06/30 23:54:04 dillon Exp $ */ #ifndef _SYS_USER_H_ @@ -97,6 +97,7 @@ struct kinfo_proc { } kp_eproc; struct thread kp_thread; /* thread structure */ }; +void fill_eproc_td __P((struct thread *, struct eproc *, struct proc *)); void fill_eproc __P((struct proc *, struct eproc *)); -- 2.41.0