kern_threads.c.. upcall question..

Julian Elischer julian at elischer.org
Tue May 6 00:10:34 PDT 2003



On Tue, 6 May 2003, David Xu wrote:

> I think the following patch is enough:

I agree that this seems enough from what I was reading.
(I like patches that have most lines starting with '-' :-)


> 
> Index: kern_thread.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/kern/kern_thread.c,v
> retrieving revision 1.129
> diff -u -r1.129 kern_thread.c
> --- kern_thread.c 1 May 2003 12:16:06 -0000 1.129
> +++ kern_thread.c 6 May 2003 06:32:10 -0000
> @@ -721,41 +721,6 @@
[...]
>  void
> @@ -962,27 +927,25 @@
>   uintptr_t mbx;
>   void *addr;
>   int error,temp;
> - ucontext_t uc;
> + mcontext_t mc;
>  
>   p = td->td_proc;
>   kg = td->td_ksegrp;
>  
>   /* Export the user/machine context. */
> - addr = (void *)(&td->td_mailbox->tm_context);
> - error = copyin(addr, &uc, sizeof(ucontext_t));
> - if (error) 
> -  goto bad;
> -
> - thread_getcontext(td, &uc);
> - error = copyout(&uc, addr, sizeof(ucontext_t));
> - if (error) 
> + get_mcontext(td, &mc, 0);

I think this could be optimised even more.
(why copy the FP regs if they are not valid) (etc).
but it is an improvement..

> + addr = (void *)(&td->td_mailbox->tm_context.uc_mcontext);
> + error = copyout(&mc, addr, sizeof(mcontext_t));
> + if (error)
>    goto bad;
>  
>   /* Exports clock ticks in kernel mode */
>   addr = (caddr_t)(&td->td_mailbox->tm_sticks);
>   temp = fuword(addr) + td->td_usticks;
> - if (suword(addr, temp))
> + if (suword(addr, temp)) {
> +  error = EFAULT;
>    goto bad;
> + }
>  
>   /* Get address in latest mbox of list pointer */
>   addr = (void *)(&td->td_mailbox->tm_next);
> 
> 
> And should we disable single threading testing or do
> double checking in thread_user_enter()? I think per-syscall
> PROC_LOCK is too expensive for us.

I am not sure which one you refer too.. Which single_threading
test?

BTW, I am a little unsure about the calling of thread_user_enter()
from thread_userret().



> 
> David Xu
> 
> 
> 



More information about the freebsd-threads mailing list