Changeset View
Standalone View
sys/sys/proc.h
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||||||||||
#include <sys/rtprio.h> /* XXX. */ | #include <sys/rtprio.h> /* XXX. */ | ||||||||||||
#include <sys/runq.h> | #include <sys/runq.h> | ||||||||||||
#include <sys/resource.h> | #include <sys/resource.h> | ||||||||||||
#include <sys/sigio.h> | #include <sys/sigio.h> | ||||||||||||
#include <sys/signal.h> | #include <sys/signal.h> | ||||||||||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||||||||||
#ifndef _KERNEL | #ifndef _KERNEL | ||||||||||||
#include <sys/time.h> /* For structs itimerval, timeval. */ | #include <sys/time.h> /* For structs itimerval, timeval. */ | ||||||||||||
#include <machine/atomic.h> /* atomic_load_int/atomic_store_int */ | |||||||||||||
mjg: comments like this notoriously get stale | |||||||||||||
#else | #else | ||||||||||||
#include <sys/pcpu.h> | #include <sys/pcpu.h> | ||||||||||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||||||||||
#endif | #endif | ||||||||||||
#include <sys/ucontext.h> | #include <sys/ucontext.h> | ||||||||||||
#include <sys/ucred.h> | #include <sys/ucred.h> | ||||||||||||
#include <sys/types.h> | #include <sys/types.h> | ||||||||||||
#include <sys/_domainset.h> | #include <sys/_domainset.h> | ||||||||||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | enum td_states { | ||||||||||||
TDS_RUNQ, | TDS_RUNQ, | ||||||||||||
TDS_RUNNING | TDS_RUNNING | ||||||||||||
} td_state; /* (t) thread state */ | } td_state; /* (t) thread state */ | ||||||||||||
union { | union { | ||||||||||||
register_t tdu_retval[2]; | register_t tdu_retval[2]; | ||||||||||||
off_t tdu_off; | off_t tdu_off; | ||||||||||||
} td_uretoff; /* (k) Syscall aux returns. */ | } td_uretoff; /* (k) Syscall aux returns. */ | ||||||||||||
#define td_retval td_uretoff.tdu_retval | #define td_retval td_uretoff.tdu_retval | ||||||||||||
u_int td_cowgen; /* (k) Generation of COW pointers. */ | u_int td_cowgen; /* (k) Generation of COW pointers. */ | ||||||||||||
Done Inline ActionsIf this was added to induce compilation failures for plain td_state access it needs a comment. I don't have an opinion one way or the other if this should be done here. mjg: If this was added to induce compilation failures for plain td_state access it needs a comment. | |||||||||||||
Done Inline ActionsI would guess it'll also break some number of ports. Probably not many, but to me it's an argument against the name change. markj: I would guess it'll also break some number of ports. Probably not many, but to me it's an… | |||||||||||||
Done Inline ActionsGood point, I guess the wrapper struct could either be only for _KERNEL, or I just drop it entirely now that I've found all uses. arichardson: Good point, I guess the wrapper struct could either be only for _KERNEL, or I just drop it… | |||||||||||||
Done Inline ActionsIt will break devel/mdb as mdb uses some weird hacks where it create mirror structures with a subset of members and depends on the CTF data for its own version and the CTF data in the kernel for the kernel's version to copy the right fields of the kernel structure into its mirrored structure. However, this depends on 1:1 correspondence of structures and is a PITA to deal with. (kgdb wouldn't care either way) jhb: It will break devel/mdb as mdb uses some weird hacks where it create mirror structures with a… | |||||||||||||
/* LP64 hole */ | /* LP64 hole */ | ||||||||||||
struct callout td_slpcallout; /* (h) Callout for sleep. */ | struct callout td_slpcallout; /* (h) Callout for sleep. */ | ||||||||||||
struct trapframe *td_frame; /* (k) */ | struct trapframe *td_frame; /* (k) */ | ||||||||||||
vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */ | vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */ | ||||||||||||
int td_kstack_pages; /* (a) Size of the kstack. */ | int td_kstack_pages; /* (a) Size of the kstack. */ | ||||||||||||
volatile u_int td_critnest; /* (k*) Critical section nest level. */ | volatile u_int td_critnest; /* (k*) Critical section nest level. */ | ||||||||||||
struct mdthread td_md; /* (k) Any machine-dependent fields. */ | struct mdthread td_md; /* (k) Any machine-dependent fields. */ | ||||||||||||
struct kaudit_record *td_ar; /* (k) Active audit record, if any. */ | struct kaudit_record *td_ar; /* (k) Active audit record, if any. */ | ||||||||||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | |||||||||||||
#define TDI_IWAIT 0x0010 /* Awaiting interrupt. */ | #define TDI_IWAIT 0x0010 /* Awaiting interrupt. */ | ||||||||||||
#define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING) | #define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING) | ||||||||||||
#define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL) | #define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL) | ||||||||||||
#define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED) | #define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED) | ||||||||||||
#define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED) | #define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED) | ||||||||||||
#define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK) | #define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK) | ||||||||||||
#define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT) | #define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT) | ||||||||||||
#define TD_IS_RUNNING(td) ((td)->td_state == TDS_RUNNING) | #define TD_IS_RUNNING(td) (atomic_load_int(&(td)->td_state) == TDS_RUNNING) | ||||||||||||
#define TD_ON_RUNQ(td) ((td)->td_state == TDS_RUNQ) | #define TD_ON_RUNQ(td) ((td)->td_state == TDS_RUNQ) | ||||||||||||
#define TD_CAN_RUN(td) ((td)->td_state == TDS_CAN_RUN) | #define TD_CAN_RUN(td) ((td)->td_state == TDS_CAN_RUN) | ||||||||||||
#define TD_IS_INHIBITED(td) ((td)->td_state == TDS_INHIBITED) | #define TD_IS_INHIBITED(td) ((td)->td_state == TDS_INHIBITED) | ||||||||||||
Done Inline ActionsI would define separate implementations for _KERNEL and !_KERNEL rather than pulling in atomic.h. markj: I would define separate implementations for `_KERNEL` and `!_KERNEL` rather than pulling in… | |||||||||||||
Done Inline ActionsSounds good, will do so later this week. arichardson: Sounds good, will do so later this week. | |||||||||||||
#define TD_ON_UPILOCK(td) ((td)->td_flags & TDF_UPIBLOCKED) | #define TD_ON_UPILOCK(td) ((td)->td_flags & TDF_UPIBLOCKED) | ||||||||||||
#define TD_IS_IDLETHREAD(td) ((td)->td_flags & TDF_IDLETD) | #define TD_IS_IDLETHREAD(td) ((td)->td_flags & TDF_IDLETD) | ||||||||||||
#define TD_CAN_ABORT(td) (TD_ON_SLEEPQ((td)) && \ | #define TD_CAN_ABORT(td) (TD_ON_SLEEPQ((td)) && \ | ||||||||||||
((td)->td_flags & TDF_SINTR) != 0) | ((td)->td_flags & TDF_SINTR) != 0) | ||||||||||||
#define KTDSTATE(td) \ | #define KTDSTATE(td) \ | ||||||||||||
(((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \ | (((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \ | ||||||||||||
((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \ | ((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \ | ||||||||||||
((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \ | ((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \ | ||||||||||||
((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \ | ((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \ | ||||||||||||
((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding") | ((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding") | ||||||||||||
#define TD_SET_INHIB(td, inhib) do { \ | #define TD_SET_INHIB(td, inhib) do { \ | ||||||||||||
(td)->td_state = TDS_INHIBITED; \ | atomic_store_int(&(td)->td_state, TDS_INHIBITED); \ | ||||||||||||
(td)->td_inhibitors |= (inhib); \ | (td)->td_inhibitors |= (inhib); \ | ||||||||||||
} while (0) | } while (0) | ||||||||||||
#define TD_CLR_INHIB(td, inhib) do { \ | #define TD_CLR_INHIB(td, inhib) do { \ | ||||||||||||
if (((td)->td_inhibitors & (inhib)) && \ | if (((td)->td_inhibitors & (inhib)) && \ | ||||||||||||
(((td)->td_inhibitors &= ~(inhib)) == 0)) \ | (((td)->td_inhibitors &= ~(inhib)) == 0)) \ | ||||||||||||
(td)->td_state = TDS_CAN_RUN; \ | atomic_store_int(&(td)->td_state, TDS_CAN_RUN); \ | ||||||||||||
} while (0) | } while (0) | ||||||||||||
#define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING) | #define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING) | ||||||||||||
#define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED) | #define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED) | ||||||||||||
#define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK) | #define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK) | ||||||||||||
#define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED) | #define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED) | ||||||||||||
#define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT) | #define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT) | ||||||||||||
#define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING) | #define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING) | ||||||||||||
#define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING) | #define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING) | ||||||||||||
#define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED) | #define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED) | ||||||||||||
#define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK) | #define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK) | ||||||||||||
#define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED) | #define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED) | ||||||||||||
#define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT) | #define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT) | ||||||||||||
#define TD_SET_RUNNING(td) (td)->td_state = TDS_RUNNING | #define TD_SET_RUNNING(td) atomic_store_int(&(td)->td_state, TDS_RUNNING) | ||||||||||||
#define TD_SET_RUNQ(td) (td)->td_state = TDS_RUNQ | #define TD_SET_RUNQ(td) atomic_store_int(&(td)->td_state, TDS_RUNQ) | ||||||||||||
#define TD_SET_CAN_RUN(td) (td)->td_state = TDS_CAN_RUN | #define TD_SET_CAN_RUN(td) atomic_store_int(&(td)->td_state, TDS_CAN_RUN) | ||||||||||||
mjgUnsubmitted Done Inline ActionsI think this should be TD_SET_STATE(td, state) and used by all of these and other places. mjg: I think this should be TD_SET_STATE(td, state) and used by all of these and other places. | |||||||||||||
arichardsonAuthorUnsubmitted Done Inline ActionsYes, much better. Thanks for the suggestion. arichardson: Yes, much better. Thanks for the suggestion. | |||||||||||||
Done Inline Actions
jhb: | |||||||||||||
#define TD_SBDRY_INTR(td) \ | #define TD_SBDRY_INTR(td) \ | ||||||||||||
(((td)->td_flags & (TDF_SEINTR | TDF_SERESTART)) != 0) | (((td)->td_flags & (TDF_SEINTR | TDF_SERESTART)) != 0) | ||||||||||||
#define TD_SBDRY_ERRNO(td) \ | #define TD_SBDRY_ERRNO(td) \ | ||||||||||||
(((td)->td_flags & TDF_SEINTR) != 0 ? EINTR : ERESTART) | (((td)->td_flags & TDF_SEINTR) != 0 ? EINTR : ERESTART) | ||||||||||||
/* | /* | ||||||||||||
* Process structure. | * Process structure. | ||||||||||||
*/ | */ | ||||||||||||
▲ Show 20 Lines • Show All 675 Lines • Show Last 20 Lines |
comments like this notoriously get stale