summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-10-23 12:19:08 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-10-23 12:19:08 +0000
commit7086514f41a8629e4d5de82e04da61a0d8984c7a (patch)
tree102c102a88cf109e39d6ce10f15ba455e6d2fb0d /sys
parent34d1b4d779aad03872c69239800bb0c43f930720 (diff)
downloadFreeBSD-src-7086514f41a8629e4d5de82e04da61a0d8984c7a.zip
FreeBSD-src-7086514f41a8629e4d5de82e04da61a0d8984c7a.tar.gz
Make p_itimers as a pointer, so file sys/proc.h does not need to include
sys/timers.h.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_exec.c1
-rw-r--r--sys/kern/kern_exit.c1
-rw-r--r--sys/kern/kern_thread.c1
-rw-r--r--sys/kern/kern_time.c53
-rw-r--r--sys/sys/proc.h3
-rw-r--r--sys/sys/timers.h4
6 files changed, 30 insertions, 33 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 18df172..78b4a04 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysent.h>
#include <sys/shm.h>
#include <sys/sysctl.h>
+#include <sys/timers.h>
#include <sys/vnode.h>
#ifdef KTRACE
#include <sys/ktrace.h>
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 399d369..347a484 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mac.h>
#include <sys/shm.h>
#include <sys/sem.h>
+#include <sys/timers.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index da7ab55..e315baf 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -278,7 +278,6 @@ proc_linkup(struct proc *p, struct ksegrp *kg, struct thread *td)
TAILQ_INIT(&p->p_threads); /* all threads in proc */
TAILQ_INIT(&p->p_suspended); /* Threads suspended */
sigqueue_init(&p->p_sigqueue, p);
- itimers_init(&p->p_itimers);
p->p_numksegrps = 0;
p->p_numthreads = 0;
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 5da4e00..d5427c4 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -964,7 +964,7 @@ kern_timer_create(struct thread *td, clockid_t clock_id,
return (EINVAL);
}
- if (p->p_itimers.its_timers == NULL)
+ if (p->p_itimers == NULL)
itimers_alloc(p);
it = uma_zalloc(itimer_zone, M_WAITOK);
@@ -988,7 +988,7 @@ kern_timer_create(struct thread *td, clockid_t clock_id,
if (preset_id != -1) {
KASSERT(preset_id >= 0 && preset_id < 3, ("invalid preset_id"));
id = preset_id;
- if (p->p_itimers.its_timers[id] != NULL) {
+ if (p->p_itimers->its_timers[id] != NULL) {
PROC_UNLOCK(p);
error = 0;
goto out;
@@ -999,7 +999,7 @@ kern_timer_create(struct thread *td, clockid_t clock_id,
* for setitimer().
*/
for (id = 3; id < TIMER_MAX; id++)
- if (p->p_itimers.its_timers[id] == NULL)
+ if (p->p_itimers->its_timers[id] == NULL)
break;
if (id == TIMER_MAX) {
PROC_UNLOCK(p);
@@ -1008,7 +1008,7 @@ kern_timer_create(struct thread *td, clockid_t clock_id,
}
}
it->it_timerid = id;
- p->p_itimers.its_timers[id] = it;
+ p->p_itimers->its_timers[id] = it;
if (evp != NULL)
it->it_sigev = *evp;
else {
@@ -1064,8 +1064,8 @@ itimer_find(struct proc *p, timer_t timerid, int include_deleting)
struct itimer *it;
PROC_LOCK_ASSERT(p, MA_OWNED);
- if ((p->p_itimers.its_timers == NULL) || (timerid >= TIMER_MAX) ||
- (it = p->p_itimers.its_timers[timerid]) == NULL) {
+ if ((p->p_itimers == NULL) || (timerid >= TIMER_MAX) ||
+ (it = p->p_itimers->its_timers[timerid]) == NULL) {
return (NULL);
}
ITIMER_LOCK(it);
@@ -1102,7 +1102,7 @@ kern_timer_delete(struct thread *td, timer_t timerid)
PROC_LOCK(p);
if (KSI_ONQ(&it->it_ksi))
sigqueue_take(&it->it_ksi);
- p->p_itimers.its_timers[timerid] = NULL;
+ p->p_itimers->its_timers[timerid] = NULL;
PROC_UNLOCK(p);
uma_zfree(itimer_zone, it);
return (0);
@@ -1324,7 +1324,7 @@ realtimer_event_hook(struct proc *p, clockid_t clock_id, int event)
i = 1;
else
i = 0;
- its = &p->p_itimers;
+ its = p->p_itimers;
for (; i < TIMER_MAX; i++) {
if ((it = its->its_timers[i]) != NULL &&
it->it_clockid == clock_id) {
@@ -1404,29 +1404,26 @@ itimer_fire(struct itimer *it)
static void
itimers_alloc(struct proc *p)
{
- struct itimer **itp;
+ struct itimers *its;
+ int i;
- itp = malloc(sizeof(struct itimer *) * TIMER_MAX, M_SUBPROC,
- M_WAITOK | M_ZERO);
+ its = malloc(sizeof (struct itimers), M_SUBPROC, M_WAITOK | M_ZERO);
+ LIST_INIT(&its->its_virtual);
+ LIST_INIT(&its->its_prof);
+ TAILQ_INIT(&its->its_worklist);
+ for (i = 0; i < TIMER_MAX; i++)
+ its->its_timers[i] = NULL;
PROC_LOCK(p);
- if (p->p_itimers.its_timers == NULL) {
- p->p_itimers.its_timers = itp;
+ if (p->p_itimers == NULL) {
+ p->p_itimers = its;
PROC_UNLOCK(p);
- } else {
+ }
+ else {
PROC_UNLOCK(p);
- free(itp, M_SUBPROC);
+ free(its, M_SUBPROC);
}
}
-void
-itimers_init(struct itimers *its)
-{
- LIST_INIT(&its->its_virtual);
- LIST_INIT(&its->its_prof);
- TAILQ_INIT(&its->its_worklist);
- its->its_timers = NULL;
-}
-
/* Clean up timers when some process events are being triggered. */
void
itimers_event_hook(struct proc *p, int event)
@@ -1435,8 +1432,8 @@ itimers_event_hook(struct proc *p, int event)
struct itimer *it;
int i;
- if (p->p_itimers.its_timers != NULL) {
- its = &p->p_itimers;
+ if (p->p_itimers != NULL) {
+ its = p->p_itimers;
for (i = 0; i < MAX_CLOCKS; ++i) {
if (posix_clocks[i].event_hook != NULL)
CLOCK_CALL(i, event_hook, (p, i, event));
@@ -1464,8 +1461,8 @@ itimers_event_hook(struct proc *p, int event)
if (its->its_timers[0] == NULL &&
its->its_timers[1] == NULL &&
its->its_timers[2] == NULL) {
- free(its->its_timers, M_SUBPROC);
- p->p_itimers.its_timers = NULL;
+ free(its, M_SUBPROC);
+ p->p_itimers = NULL;
}
}
}
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 7f0997f..6591e82 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -57,7 +57,6 @@
#else
#include <sys/pcpu.h>
#endif
-#include <sys/timers.h>
#include <sys/ucontext.h>
#include <sys/ucred.h>
#include <machine/proc.h> /* Machine-dependent proc substruct. */
@@ -547,7 +546,6 @@ struct proc {
LIST_ENTRY(proc) p_sibling; /* (e) List of sibling processes. */
LIST_HEAD(, proc) p_children; /* (e) Pointer to list of children. */
struct mtx p_mtx; /* (n) Lock for this struct. */
- struct itimers p_itimers; /* (c) POSIX interval timers. */
sigqueue_t p_sigqueue; /* (c) Sigs not delivered to a td. */
#define p_siglist p_sigqueue.sq_signals
@@ -582,6 +580,7 @@ struct proc {
int p_boundary_count;/* (c) Num threads at user boundary */
struct ksegrp *p_procscopegrp;
int p_pendingcnt; /* how many signals are pending */
+ struct itimers *p_itimers; /* (c) POSIX interval timers. */
/* End area that is zeroed on creation. */
#define p_endzero p_magic
diff --git a/sys/sys/timers.h b/sys/sys/timers.h
index 9c41e94..18434fa5 100644
--- a/sys/sys/timers.h
+++ b/sys/sys/timers.h
@@ -94,7 +94,7 @@ struct itimers {
struct itimerlist its_virtual;
struct itimerlist its_prof;
TAILQ_HEAD(, itimer) its_worklist;
- struct itimer **its_timers;
+ struct itimer *its_timers[TIMER_MAX];
};
struct kclock {
@@ -112,7 +112,7 @@ struct kclock {
#define ITIMER_EV_EXEC 0
#define ITIMER_EV_EXIT 1
-void itimers_init(struct itimers *its);
void itimers_event_hook(struct proc *p, int event);
+
#endif
#endif /* !_SYS_TIMERS_H_ */
OpenPOWER on IntegriCloud