Use local struct proc variables to reduce repeated td->td_proc dereferences
and improve readability.
This commit is contained in:
parent
ac139f5914
commit
e7a906488e
@ -164,6 +164,7 @@ linux_alarm(struct thread *td, struct linux_alarm_args *args)
|
||||
{
|
||||
struct itimerval it, old_it;
|
||||
struct timeval tv;
|
||||
struct proc *p;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(alarm))
|
||||
@ -177,18 +178,19 @@ linux_alarm(struct thread *td, struct linux_alarm_args *args)
|
||||
it.it_value.tv_usec = 0;
|
||||
it.it_interval.tv_sec = 0;
|
||||
it.it_interval.tv_usec = 0;
|
||||
PROC_LOCK(td->td_proc);
|
||||
old_it = td->td_proc->p_realtimer;
|
||||
p = td->td_proc;
|
||||
PROC_LOCK(p);
|
||||
old_it = p->p_realtimer;
|
||||
getmicrouptime(&tv);
|
||||
if (timevalisset(&old_it.it_value))
|
||||
callout_stop(&td->td_proc->p_itcallout);
|
||||
callout_stop(&p->p_itcallout);
|
||||
if (it.it_value.tv_sec != 0) {
|
||||
callout_reset(&td->td_proc->p_itcallout, tvtohz(&it.it_value),
|
||||
realitexpire, td->td_proc);
|
||||
callout_reset(&p->p_itcallout, tvtohz(&it.it_value),
|
||||
realitexpire, p);
|
||||
timevaladd(&it.it_value, &tv);
|
||||
}
|
||||
td->td_proc->p_realtimer = it;
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
p->p_realtimer = it;
|
||||
PROC_UNLOCK(p);
|
||||
if (timevalcmp(&old_it.it_value, &tv, >)) {
|
||||
timevalsub(&old_it.it_value, &tv);
|
||||
if (old_it.it_value.tv_usec != 0)
|
||||
@ -809,6 +811,7 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args)
|
||||
struct rusage *rusage;
|
||||
} */ tmp;
|
||||
int error, tmpstat;
|
||||
struct proc *p;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(wait4))
|
||||
@ -828,9 +831,10 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args)
|
||||
if ((error = wait4(td, &tmp)) != 0)
|
||||
return error;
|
||||
|
||||
PROC_LOCK(td->td_proc);
|
||||
SIGDELSET(td->td_proc->p_siglist, SIGCHLD);
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
p = td->td_proc;
|
||||
PROC_LOCK(p);
|
||||
SIGDELSET(p->p_siglist, SIGCHLD);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
if (args->status) {
|
||||
if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0)
|
||||
|
@ -554,21 +554,21 @@ svr4_sys_sigpending(td, uap)
|
||||
struct thread *td;
|
||||
struct svr4_sys_sigpending_args *uap;
|
||||
{
|
||||
struct proc *p;
|
||||
sigset_t bss;
|
||||
int *retval;
|
||||
svr4_sigset_t sss;
|
||||
|
||||
DPRINTF(("@@@ svr4_sys_sigpending(%d)\n", td->td_proc->p_pid));
|
||||
retval = td->td_retval;
|
||||
p = td->td_proc;
|
||||
DPRINTF(("@@@ svr4_sys_sigpending(%d)\n", p->p_pid));
|
||||
switch (uap->what) {
|
||||
case 1: /* sigpending */
|
||||
if (uap->mask == NULL)
|
||||
return 0;
|
||||
PROC_LOCK(td->td_proc);
|
||||
bss = td->td_proc->p_siglist;
|
||||
PROC_LOCK(p);
|
||||
bss = p->p_siglist;
|
||||
SIGSETOR(bss, td->td_siglist);
|
||||
SIGSETAND(bss, td->td_sigmask);
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
PROC_UNLOCK(p);
|
||||
bsd_to_svr4_sigset(&bss, &sss);
|
||||
break;
|
||||
|
||||
|
@ -198,7 +198,7 @@ char emulating = 0;
|
||||
static int
|
||||
math_emulate(struct trapframe * tframe)
|
||||
{
|
||||
|
||||
struct proc *p;
|
||||
unsigned char FPU_modrm;
|
||||
unsigned short code;
|
||||
#ifdef LOOKAHEAD_LIMIT
|
||||
@ -232,10 +232,11 @@ math_emulate(struct trapframe * tframe)
|
||||
#endif
|
||||
|
||||
FPU_lookahead = FPU_LOOKAHEAD;
|
||||
PROC_LOCK(curthread->td_proc);
|
||||
if (curproc->p_flag & P_TRACED)
|
||||
p = curthread->td_proc;
|
||||
PROC_LOCK(p);
|
||||
if (p->p_flag & P_TRACED)
|
||||
FPU_lookahead = 0;
|
||||
PROC_UNLOCK(curthread->td_proc);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
do_another_FPU_instruction:
|
||||
|
||||
|
@ -569,15 +569,17 @@ ithread_loop(void *arg)
|
||||
static void
|
||||
start_softintr(void *dummy)
|
||||
{
|
||||
struct proc *p;
|
||||
|
||||
if (swi_add(&clk_ithd, "clock", softclock, NULL, SWI_CLOCK,
|
||||
INTR_MPSAFE, &softclock_ih) ||
|
||||
swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, 0, &vm_ih))
|
||||
panic("died while creating standard software ithreads");
|
||||
|
||||
PROC_LOCK(clk_ithd->it_td->td_proc);
|
||||
clk_ithd->it_td->td_proc->p_flag |= P_NOLOAD;
|
||||
PROC_UNLOCK(clk_ithd->it_td->td_proc);
|
||||
p = clk_ithd->it_td->td_proc;
|
||||
PROC_LOCK(p);
|
||||
p->p_flag |= P_NOLOAD;
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user