Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 1999 19:39:28 -0700
From:      "Russell L. Carter" <rcarter@pinyon.org>
To:        freebsd-current@FreeBSD.ORG
Subject:   Re: Using LinuxThreads
Message-ID:  <199901220239.TAA06788@psf.Pinyon.ORG>

next in thread | raw e-mail | index | archive | help
dick@tar.com said:
%For kernel threading you just use libc.  Whether or not libc generates
% thread safe (re-entrant) calls depends on whether its also linked
%with a library that 1) sets __isthreaded to a non-zero value, 2) has a
%_spinlock() implementationm, and 3) implements the functions
%flockfile, funlockfile, etc. There are also a few macros in header
%files that require _THREAD_SAFE to be defined to be thread safe.

%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:

uthread_wait4.c:

#include <errno.h>
#include <sys/wait.h>
#ifdef _THREAD_SAFE
#include <pthread.h>
#include "pthread_private.h"

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


Russell



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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901220239.TAA06788>