On Thu, Jan 21, 1999 at 07:39:28PM -0700, Russell L. Carter wrote:
> d...@tar.com said:
> %libc_r could be modified so that is doesn't replace libc, but rather
> %is an addon, comparable to the kernel threaded libc case.  But, it
> %would involve a bit of work. 
> 
> I thought so at first, but then I had to look at wait4 today and
> now I'm not so sure.  At least some of libc_r is very closely
> tied to the uthread scheduler:

Sure it is.  But, I don't see why that prevents the possibility of leaving
libc in place and having libc_r just be an add on (not that I'm advocating
this).  Taking your example, in libc the syscall is implemented as _wait4,
and wait4 is a weak alias to _wait4.  If you replaced _thread_sys_wait4
below with _wait4 instead, and put the resulting code in a library separate
from libc (eg. in a "new" libc_r) along with the uthread scheduling code
and the rest of the uthread pthread code, you could leave libc alone.
Then, when you linked with libc and libc_r together, the wait4 in libc_r
would override the weak aliased wait4 in libc.  If you didn't link with
libc_r, you'd have your plain old wait4.

The bigger problem is that the uthread code needs "two layer" aliasing
in order to implement pthread cancellation.


> pid_t
> wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
> {
>         pid_t           ret;
> 
>         /* Perform a non-blocking wait4 syscall: */
>         while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, 
> rusage)) == 0 && (options & WNOHANG) == 0) {
>                 /* Reset the interrupted operation flag: */
>                 _thread_run->interrupted = 0;
> 
>                 /* Schedule the next thread while this one waits: */
>                 _thread_kern_sched_state(PS_WAIT_WAIT, __FILE__, __LINE__);
> 
>                 /* Check if this call was interrupted by a signal: */
>                 if (_thread_run->interrupted) {
>                         errno = EINTR;
>                         ret = -1;
>                         break;
>                 }
>         }
>         return (ret);
> }
> #endif

-- 
Richard Seamman, Jr.          email: d...@tar.com
5182 N. Maple Lane            phone: 414-367-5450
Chenequa WI 53058             fax:   414-367-5852

To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message

Reply via email to