No locking in kernel code

- No locking in RTS_(UN)SET macros

- No lock_notify()

- Removed unused lock_send()

- No lock/unlock macros anymore
This commit is contained in:
Tomas Hruby
2010-02-09 15:26:58 +00:00
parent 064cb7583a
commit c6fec6866f
24 changed files with 38 additions and 161 deletions

View File

@@ -33,7 +33,7 @@ PUBLIC int do_endksig(struct proc * caller, message * m_ptr)
/* PM has finished one kernel signal. Perhaps process is ready now? */
if (!RTS_ISSET(rp, RTS_SIGNALED)) /* new signal arrived */
RTS_LOCK_UNSET(rp, RTS_SIG_PENDING); /* remove pending flag */
RTS_UNSET(rp, RTS_SIG_PENDING); /* remove pending flag */
return(OK);
}

View File

@@ -41,7 +41,7 @@ PUBLIC int do_exec(struct proc * caller, message * m_ptr)
arch_pre_exec(rp, (u32_t) m_ptr->PR_IP_PTR, (u32_t) m_ptr->PR_STACK_PTR);
/* No reply to EXEC call */
RTS_LOCK_UNSET(rp, RTS_RECEIVING);
RTS_UNSET(rp, RTS_RECEIVING);
/* Mark fpu_regs contents as not significant, so fpu
* will be initialized, when it's used next time. */

View File

@@ -70,7 +70,7 @@ register struct proc *rc; /* slot of process to clean up */
/* Make sure that the exiting process is no longer scheduled,
* and mark slot as FREE. Also mark saved fpu contents as not significant.
*/
RTS_LOCK_SETFLAGS(rc, RTS_SLOT_FREE);
RTS_SETFLAGS(rc, RTS_SLOT_FREE);
rc->p_misc_flags &= ~MF_FPU_INITIALIZED;
/* Release the process table slot. If this is a system process, also

View File

@@ -105,13 +105,13 @@ PUBLIC int do_fork(struct proc * caller, message * m_ptr)
/* Don't schedule process in VM mode until it has a new pagetable. */
if(m_ptr->PR_FORK_FLAGS & PFF_VMINHIBIT) {
RTS_LOCK_SET(rpc, RTS_VMINHIBIT);
RTS_SET(rpc, RTS_VMINHIBIT);
}
/*
* Only one in group should have RTS_SIGNALED, child doesn't inherit tracing.
*/
RTS_LOCK_UNSET(rpc, (RTS_SIGNALED | RTS_SIG_PENDING | RTS_P_STOP));
RTS_UNSET(rpc, (RTS_SIGNALED | RTS_SIG_PENDING | RTS_P_STOP));
sigemptyset(&rpc->p_pending);
return r;

View File

@@ -32,7 +32,7 @@ PUBLIC int do_getksig(struct proc * caller, message * m_ptr)
m_ptr->SIG_ENDPT = rp->p_endpoint;
m_ptr->SIG_MAP = rp->p_pending; /* pending signals map */
sigemptyset(&rp->p_pending); /* ball is in PM's court */
RTS_LOCK_UNSET(rp, RTS_SIGNALED); /* blocked by SIG_PENDING */
RTS_UNSET(rp, RTS_SIGNALED); /* blocked by SIG_PENDING */
return(OK);
}
}

View File

@@ -37,12 +37,10 @@ PUBLIC int do_nice(struct proc * caller, message * m_ptr)
if (new_q < MAX_USER_Q) new_q = MAX_USER_Q; /* shouldn't happen */
if (new_q > MIN_USER_Q) new_q = MIN_USER_Q; /* shouldn't happen */
/* Make sure the process is not running while changing its priority.
* Put the process back in its new queue if it is runnable.
*/
RTS_LOCK_SET(rp, RTS_SYS_LOCK);
/* Dequeue the process and put it in its new queue if it is runnable. */
RTS_SET(rp, RTS_SYS_LOCK);
rp->p_max_priority = rp->p_priority = new_q;
RTS_LOCK_UNSET(rp, RTS_SYS_LOCK);
RTS_UNSET(rp, RTS_SYS_LOCK);
return(OK);
}

View File

@@ -52,13 +52,13 @@ PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
if (!RTS_ISSET(rp, RTS_NO_PRIV) || priv(rp)->s_proc_nr == NONE) {
return(EPERM);
}
RTS_LOCK_UNSET(rp, RTS_NO_PRIV);
RTS_UNSET(rp, RTS_NO_PRIV);
return(OK);
case SYS_PRIV_DISALLOW:
/* Disallow process from running. */
if (RTS_ISSET(rp, RTS_NO_PRIV)) return(EPERM);
RTS_LOCK_SET(rp, RTS_NO_PRIV);
RTS_SET(rp, RTS_NO_PRIV);
return(OK);
case SYS_PRIV_SET_SYS:

View File

@@ -40,14 +40,14 @@ PUBLIC int do_runctl(struct proc * caller, message * m_ptr)
* should not also install signal handlers *and* expect POSIX compliance.
*/
if (action == RC_STOP && (flags & RC_DELAY)) {
RTS_LOCK_SET(rp, RTS_SYS_LOCK);
RTS_SET(rp, RTS_SYS_LOCK);
if (RTS_ISSET(rp, RTS_SENDING) || (rp->p_misc_flags & MF_SC_DEFER))
rp->p_misc_flags |= MF_SIG_DELAY;
delayed = (rp->p_misc_flags & MF_SIG_DELAY);
RTS_LOCK_UNSET(rp, RTS_SYS_LOCK);
RTS_UNSET(rp, RTS_SYS_LOCK);
if (delayed) return(EBUSY);
}
@@ -55,10 +55,10 @@ PUBLIC int do_runctl(struct proc * caller, message * m_ptr)
/* Either set or clear the stop flag. */
switch (action) {
case RC_STOP:
RTS_LOCK_SET(rp, RTS_PROC_STOP);
RTS_SET(rp, RTS_PROC_STOP);
break;
case RC_RESUME:
RTS_LOCK_UNSET(rp, RTS_PROC_STOP);
RTS_UNSET(rp, RTS_PROC_STOP);
break;
default:
return(EINVAL);

View File

@@ -145,8 +145,8 @@ PUBLIC int map_invoke_vm(struct proc * caller,
vmassert(!RTS_ISSET(caller, RTS_VMREQTARGET));
vmassert(!RTS_ISSET(dst, RTS_VMREQUEST));
vmassert(!RTS_ISSET(dst, RTS_VMREQTARGET));
RTS_LOCK_SET(caller, RTS_VMREQUEST);
RTS_LOCK_SET(dst, RTS_VMREQTARGET);
RTS_SET(caller, RTS_VMREQUEST);
RTS_SET(dst, RTS_VMREQTARGET);
/* Map to the destination. */
caller->p_vmrequest.req_type = req_type;
@@ -161,7 +161,7 @@ PUBLIC int map_invoke_vm(struct proc * caller,
/* Connect caller on vmrequest wait queue. */
if(!(caller->p_vmrequest.nextrequestor = vmrequest))
lock_notify(SYSTEM, VM_PROC_NR);
mini_notify(proc_addr(SYSTEM), VM_PROC_NR);
vmrequest = caller;
return OK;

View File

@@ -65,7 +65,7 @@ timer_t *tp;
* process with a notification message from CLOCK.
*/
int proc_nr_e = tmr_arg(tp)->ta_int; /* get process number */
lock_notify(CLOCK, proc_nr_e); /* notify process */
mini_notify(proc_addr(CLOCK), proc_nr_e); /* notify process */
}
#endif /* USE_SETALARM */

View File

@@ -90,7 +90,7 @@ PUBLIC int do_trace(struct proc * caller, message * m_ptr)
if (isemptyp(rp)) return(EINVAL);
switch (tr_request) {
case T_STOP: /* stop process */
RTS_LOCK_SET(rp, RTS_P_STOP);
RTS_SET(rp, RTS_P_STOP);
rp->p_reg.psw &= ~TRACEBIT; /* clear trace bit */
rp->p_misc_flags &= ~MF_SC_TRACE; /* clear syscall trace flag */
return(OK);
@@ -167,19 +167,19 @@ PUBLIC int do_trace(struct proc * caller, message * m_ptr)
/* fall through */
case T_RESUME: /* resume execution */
RTS_LOCK_UNSET(rp, RTS_P_STOP);
RTS_UNSET(rp, RTS_P_STOP);
m_ptr->CTL_DATA = 0;
break;
case T_STEP: /* set trace bit */
rp->p_reg.psw |= TRACEBIT;
RTS_LOCK_UNSET(rp, RTS_P_STOP);
RTS_UNSET(rp, RTS_P_STOP);
m_ptr->CTL_DATA = 0;
break;
case T_SYSCALL: /* trace system call */
rp->p_misc_flags |= MF_SC_TRACE;
RTS_LOCK_UNSET(rp, RTS_P_STOP);
RTS_UNSET(rp, RTS_P_STOP);
m_ptr->CTL_DATA = 0;
break;

View File

@@ -100,11 +100,7 @@ PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
}
}
/* Perform actual device I/O for byte, word, and long values. Note that
* the entire switch is wrapped in lock() and unlock() to prevent the I/O
* batch from being interrupted.
*/
lock;
/* Perform actual device I/O for byte, word, and long values */
switch (io_type) {
case _DIO_BYTE: /* byte values */
if (io_in) for (i=0; i<vec_size; i++)
@@ -152,7 +148,6 @@ PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
}
}
}
unlock;
/* Almost done, copy back results for input requests. */
if (io_in)

View File

@@ -33,7 +33,7 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
switch(m_ptr->SVMCTL_PARAM) {
case VMCTL_CLEAR_PAGEFAULT:
RTS_LOCK_UNSET(p, RTS_PAGEFAULT);
RTS_UNSET(p, RTS_PAGEFAULT);
return OK;
case VMCTL_MEMREQ_GET:
/* Send VM the information about the memory request. */
@@ -125,7 +125,7 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
#endif
vmassert(RTS_ISSET(target, RTS_VMREQTARGET));
RTS_LOCK_UNSET(target, RTS_VMREQTARGET);
RTS_UNSET(target, RTS_VMREQTARGET);
switch(p->p_vmrequest.type) {
case VMSTYPE_KERNELCALL:
@@ -152,15 +152,10 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
p->p_vmrequest.type);
}
RTS_LOCK_UNSET(p, RTS_VMREQUEST);
RTS_UNSET(p, RTS_VMREQUEST);
return OK;
case VMCTL_ENABLE_PAGING:
/*
* system task must not get preempted while switching to paging,
* interrupt handling is not safe
*/
lock;
if(vm_running)
minix_panic("do_vmctl: paging already enabled", NO_NUM);
vm_init(p);
@@ -169,14 +164,12 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
vmassert(p->p_delivermsg_lin ==
umap_local(p, D, p->p_delivermsg_vir, sizeof(message)));
if ((err = arch_enable_paging()) != OK) {
unlock;
return err;
}
if(newmap(caller, p, (struct mem_map *) m_ptr->SVMCTL_VALUE) != OK)
minix_panic("do_vmctl: newmap failed", NO_NUM);
FIXLINMSG(p);
vmassert(p->p_delivermsg_lin);
unlock;
return OK;
case VMCTL_KERN_PHYSMAP:
{