<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc_r/uthread/uthread_file.c, branch release/4.2.0_cvs</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>This commit was manufactured by cvs2svn to create tag</title>
<updated>2000-11-20T04:41:45+00:00</updated>
<author>
<name>cvs2svn</name>
<email>cvs2svn@FreeBSD.org</email>
</author>
<published>2000-11-20T04:41:45+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=0d497cf6e989f7498cf5036a29fe7003a89abf83'/>
<id>0d497cf6e989f7498cf5036a29fe7003a89abf83</id>
<content type='text'>
'RELENG_4_2_0_RELEASE'.

This commit was manufactured to restore the state of the 4.2-RELEASE image.
Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'RELENG_4_2_0_RELEASE'.

This commit was manufactured to restore the state of the 4.2-RELEASE image.
Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
</pre>
</div>
</content>
</entry>
<entry>
<title>MFC: bring in signal handling changes, bug fixes, performance</title>
<updated>2000-11-09T23:46:05+00:00</updated>
<author>
<name>Daniel Eischen</name>
<email>deischen@FreeBSD.org</email>
</author>
<published>2000-11-09T23:46:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ffdee96937558a4a9203283f6c8d86b6c60a5946'/>
<id>ffdee96937558a4a9203283f6c8d86b6c60a5946</id>
<content type='text'>
     enhancements, and other good stuff.  gdb thread changes to
     follow later tonight.

Approved by:	jkh
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
     enhancements, and other good stuff.  gdb thread changes to
     follow later tonight.

Approved by:	jkh
</pre>
</div>
</content>
</entry>
<entry>
<title>Implement continuations to correctly handle [sig|_]longjmp() inside of a</title>
<updated>2000-01-19T07:04:50+00:00</updated>
<author>
<name>Jason Evans</name>
<email>jasone@FreeBSD.org</email>
</author>
<published>2000-01-19T07:04:50+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=0a3fa43c7e06dfbd6ddde4767d9c8a0c6a2ad51f'/>
<id>0a3fa43c7e06dfbd6ddde4767d9c8a0c6a2ad51f</id>
<content type='text'>
signal handler.  Explicitly check for jumps to anywhere other than the
current stack, since such jumps are undefined according to POSIX.

While we're at it, convert thread cancellation to use continuations, since
it's cleaner than the original cancellation code.

Avoid delivering a signal to a thread twice.  This was a pre-existing bug,
but was likely unexposed until these other changes were made.

Defer signals generated by pthread_kill() so that they can be delivered on
the appropriate stack.  deischen claims that this is unnecessary, which is
likely true, but without this change, pthread_kill() can cause undefined
priority queue states and/or PANICs in [sig|_]longjmp(), so I'm leaving
this in for now.  To compile this code out and exercise the bug, define
the _NO_UNDISPATCH cpp macro.  Defining _PTHREADS_INVARIANTS as well will
cause earlier crashes.

PR:			kern/14685
Collaboration with:	deischen
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
signal handler.  Explicitly check for jumps to anywhere other than the
current stack, since such jumps are undefined according to POSIX.

While we're at it, convert thread cancellation to use continuations, since
it's cleaner than the original cancellation code.

Avoid delivering a signal to a thread twice.  This was a pre-existing bug,
but was likely unexposed until these other changes were made.

Defer signals generated by pthread_kill() so that they can be delivered on
the appropriate stack.  deischen claims that this is unnecessary, which is
likely true, but without this change, pthread_kill() can cause undefined
priority queue states and/or PANICs in [sig|_]longjmp(), so I'm leaving
this in for now.  To compile this code out and exercise the bug, define
the _NO_UNDISPATCH cpp macro.  Defining _PTHREADS_INVARIANTS as well will
cause earlier crashes.

PR:			kern/14685
Collaboration with:	deischen
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix problems with cancellation while in critical regions.</title>
<updated>1999-12-17T00:57:54+00:00</updated>
<author>
<name>Daniel Eischen</name>
<email>deischen@FreeBSD.org</email>
</author>
<published>1999-12-17T00:57:54+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=fc8f3f5bfe691a89cc23a521c08e0128fbf8c2ae'/>
<id>fc8f3f5bfe691a89cc23a521c08e0128fbf8c2ae</id>
<content type='text'>
  o Cancellation flags were not getting properly set/cleared.
  o Loops waiting for internal locks were not being exited
    correctly by a cancelled thread.
  o Minor spelling (cancelation -&gt; cancellation) and formatting
    corrections (missing tab).

Found by:	tg
Reviewed by:	jasone
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
  o Cancellation flags were not getting properly set/cleared.
  o Loops waiting for internal locks were not being exited
    correctly by a cancelled thread.
  o Minor spelling (cancelation -&gt; cancellation) and formatting
    corrections (missing tab).

Found by:	tg
Reviewed by:	jasone
</pre>
</div>
</content>
</entry>
<entry>
<title>add pthread_cancel, obtained from OpenBSD.</title>
<updated>1999-11-28T05:38:13+00:00</updated>
<author>
<name>Alfred Perlstein</name>
<email>alfred@FreeBSD.org</email>
</author>
<published>1999-11-28T05:38:13+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=7285bccf1a9224fadd3b7b81be034cd04f35a820'/>
<id>7285bccf1a9224fadd3b7b81be034cd04f35a820</id>
<content type='text'>
eischen (Daniel Eischen) added wrappers to protect against cancled
threads orphaning internal resources.

the cancelability code is still a bit fuzzy but works for test
programs of my own, OpenBSD's and some examples from ORA's books.

add readdir_r to both libc and libc_r

add some 'const' attributes to function parameters

Reviewed by: eischen, jasone
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
eischen (Daniel Eischen) added wrappers to protect against cancled
threads orphaning internal resources.

the cancelability code is still a bit fuzzy but works for test
programs of my own, OpenBSD's and some examples from ORA's books.

add readdir_r to both libc and libc_r

add some 'const' attributes to function parameters

Reviewed by: eischen, jasone
</pre>
</div>
</content>
</entry>
<entry>
<title>$Id$ -&gt; $FreeBSD$</title>
<updated>1999-08-28T00:22:10+00:00</updated>
<author>
<name>Peter Wemm</name>
<email>peter@FreeBSD.org</email>
</author>
<published>1999-08-28T00:22:10+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=7f3dea244c40159a41ab22da77a434d7c5b5e85a'/>
<id>7f3dea244c40159a41ab22da77a434d7c5b5e85a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add RCS IDs to those files without them.</title>
<updated>1999-08-05T12:15:30+00:00</updated>
<author>
<name>Daniel Eischen</name>
<email>deischen@FreeBSD.org</email>
</author>
<published>1999-08-05T12:15:30+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=fa7c4d557556a90c64eaf10038c0d2a685801357'/>
<id>fa7c4d557556a90c64eaf10038c0d2a685801357</id>
<content type='text'>
Fix copyrights (s/REGENTS/AUTHOR).

Suggested by:	tg
Approved by:	jb
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix copyrights (s/REGENTS/AUTHOR).

Suggested by:	tg
Approved by:	jb
</pre>
</div>
</content>
</entry>
<entry>
<title>In the words of the author:</title>
<updated>1999-06-20T08:28:48+00:00</updated>
<author>
<name>John Birrell</name>
<email>jb@FreeBSD.org</email>
</author>
<published>1999-06-20T08:28:48+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=02292f131acd0fc6c16b950f1e6b05e75de2cdcb'/>
<id>02292f131acd0fc6c16b950f1e6b05e75de2cdcb</id>
<content type='text'>
  o The polling mechanism for I/O readiness was changed from
    select() to poll().  In additon, a wrapped version of poll()
    is now provided.

  o The wrapped select routine now converts each fd_set to a
    poll array so that the thread scheduler doesn't have to
    perform a bitwise search for selected fds each time file
    descriptors are polled for I/O readiness.

  o The thread scheduler was modified to use a new queue (_workq)
    for threads that need work.  Threads waiting for I/O readiness
    and spinblocks are added to the work queue in addition to the
    waiting queue.  This reduces the time spent forming/searching
    the array of file descriptors being polled.

  o The waiting queue (_waitingq) is now maintained in order of
    thread wakeup time.  This allows the thread scheduler to
    find the nearest wakeup time by looking at the first thread
    in the queue instead of searching the entire queue.

  o Removed file descriptor locking for select/poll routines.  An
    application should not rely on the threads library for providing
    this locking; if necessary, the application should use mutexes
    to protect selecting/polling of file descriptors.

  o Retrieve and use the kernel clock rate/resolution at startup
    instead of hardcoding the clock resolution to 10 msec (tested
    with kernel running at 1000 HZ).

  o All queues have been changed to use queue.h macros.  These
    include the queues of all threads, dead threads, and threads
    waiting for file descriptor locks.

  o Added reinitialization of the GC mutex and condition variable
    after a fork.  Also prevented reallocation of the ready queue
    after a fork.

  o Prevented the wrapped close routine from closing the thread
    kernel pipes.

  o Initialized file descriptor table for stdio entries at thread
    init.

  o Provided additional flags to indicate to what queues threads
    belong.

  o Moved TAILQ initialization for statically allocated mutex and
    condition variables to after the spinlock.

  o Added dispatching of signals to pthread_kill.  Removing the
    dispatching of signals from thread activation broke sigsuspend
    when pthread_kill was used to send a signal to a thread.

  o Temporarily set the state of a thread to PS_SUSPENDED when it
    is first created and placed in the list of threads so that it
    will not be accidentally scheduled before becoming a member
    of one of the scheduling queues.

  o Change the signal handler to queue signals to the thread kernel
    pipe if the scheduling queues are protected.  When scheduling
    queues are unprotected, signals are then dequeued and handled.

  o Ensured that all installed signal handlers block the scheduling
    signal and that the scheduling signal handler blocks all
    other signals.  This ensures that the signal handler is only
    interruptible for and by non-scheduling signals.  An atomic
    lock is used to decide which instance of the signal handler
    will handle pending signals.

  o Removed _lock_thread_list and _unlock_thread_list as they are
    no longer used to protect the thread list.

  o Added missing RCS IDs to modified files.

  o Added checks for appropriate queue membership and activity when
    adding, removing, and searching the scheduling queues.  These
    checks add very little overhead and are enabled when compiled
    with _PTHREADS_INVARIANTS defined.  Suggested and implemented
    by Tor Egge with some modification by me.

  o Close a race condition in uthread_close.  (Tor Egge)

  o Protect the scheduling queues while modifying them in
    pthread_cond_signal and _thread_fd_unlock.  (Tor Egge)

  o Ensure that when a thread gets a mutex, the mutex is on that
    threads list of owned mutexes.  (Tor Egge)

  o Set the kernel-in-scheduler flag in _thread_kern_sched_state
    and _thread_kern_sched_state_unlock to prevent a scheduling
    signal from calling the scheduler again.  (Tor Egge)

  o Don't use TAILQ_FOREACH macro while searching the waiting
    queue for threads in a sigwait state, because a change of
    state destroys the TAILQ link.  It is actually safe to do
    so, though, because once a sigwaiting thread is found, the
    loop ends and the function returns.  (Tor Egge)

  o When dispatching signals to threads, make the thread inherit
    the signal deferral flag of the currently running thread.
    (Tor Egge)

Submitted by: Daniel Eischen &lt;eischen@vigrid.com&gt; and
              Tor Egge &lt;Tor.Egge@fast.no&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
  o The polling mechanism for I/O readiness was changed from
    select() to poll().  In additon, a wrapped version of poll()
    is now provided.

  o The wrapped select routine now converts each fd_set to a
    poll array so that the thread scheduler doesn't have to
    perform a bitwise search for selected fds each time file
    descriptors are polled for I/O readiness.

  o The thread scheduler was modified to use a new queue (_workq)
    for threads that need work.  Threads waiting for I/O readiness
    and spinblocks are added to the work queue in addition to the
    waiting queue.  This reduces the time spent forming/searching
    the array of file descriptors being polled.

  o The waiting queue (_waitingq) is now maintained in order of
    thread wakeup time.  This allows the thread scheduler to
    find the nearest wakeup time by looking at the first thread
    in the queue instead of searching the entire queue.

  o Removed file descriptor locking for select/poll routines.  An
    application should not rely on the threads library for providing
    this locking; if necessary, the application should use mutexes
    to protect selecting/polling of file descriptors.

  o Retrieve and use the kernel clock rate/resolution at startup
    instead of hardcoding the clock resolution to 10 msec (tested
    with kernel running at 1000 HZ).

  o All queues have been changed to use queue.h macros.  These
    include the queues of all threads, dead threads, and threads
    waiting for file descriptor locks.

  o Added reinitialization of the GC mutex and condition variable
    after a fork.  Also prevented reallocation of the ready queue
    after a fork.

  o Prevented the wrapped close routine from closing the thread
    kernel pipes.

  o Initialized file descriptor table for stdio entries at thread
    init.

  o Provided additional flags to indicate to what queues threads
    belong.

  o Moved TAILQ initialization for statically allocated mutex and
    condition variables to after the spinlock.

  o Added dispatching of signals to pthread_kill.  Removing the
    dispatching of signals from thread activation broke sigsuspend
    when pthread_kill was used to send a signal to a thread.

  o Temporarily set the state of a thread to PS_SUSPENDED when it
    is first created and placed in the list of threads so that it
    will not be accidentally scheduled before becoming a member
    of one of the scheduling queues.

  o Change the signal handler to queue signals to the thread kernel
    pipe if the scheduling queues are protected.  When scheduling
    queues are unprotected, signals are then dequeued and handled.

  o Ensured that all installed signal handlers block the scheduling
    signal and that the scheduling signal handler blocks all
    other signals.  This ensures that the signal handler is only
    interruptible for and by non-scheduling signals.  An atomic
    lock is used to decide which instance of the signal handler
    will handle pending signals.

  o Removed _lock_thread_list and _unlock_thread_list as they are
    no longer used to protect the thread list.

  o Added missing RCS IDs to modified files.

  o Added checks for appropriate queue membership and activity when
    adding, removing, and searching the scheduling queues.  These
    checks add very little overhead and are enabled when compiled
    with _PTHREADS_INVARIANTS defined.  Suggested and implemented
    by Tor Egge with some modification by me.

  o Close a race condition in uthread_close.  (Tor Egge)

  o Protect the scheduling queues while modifying them in
    pthread_cond_signal and _thread_fd_unlock.  (Tor Egge)

  o Ensure that when a thread gets a mutex, the mutex is on that
    threads list of owned mutexes.  (Tor Egge)

  o Set the kernel-in-scheduler flag in _thread_kern_sched_state
    and _thread_kern_sched_state_unlock to prevent a scheduling
    signal from calling the scheduler again.  (Tor Egge)

  o Don't use TAILQ_FOREACH macro while searching the waiting
    queue for threads in a sigwait state, because a change of
    state destroys the TAILQ link.  It is actually safe to do
    so, though, because once a sigwaiting thread is found, the
    loop ends and the function returns.  (Tor Egge)

  o When dispatching signals to threads, make the thread inherit
    the signal deferral flag of the currently running thread.
    (Tor Egge)

Submitted by: Daniel Eischen &lt;eischen@vigrid.com&gt; and
              Tor Egge &lt;Tor.Egge@fast.no&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixed bug, caused threads to wait for locks which nobody hold.</title>
<updated>1998-09-09T16:50:33+00:00</updated>
<author>
<name>Dmitrij Tejblum</name>
<email>dt@FreeBSD.org</email>
</author>
<published>1998-09-09T16:50:33+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f0f066ec83de46a834851fa99cdf4edf399122c4'/>
<id>f0f066ec83de46a834851fa99cdf4edf399122c4</id>
<content type='text'>
Fixed sign extension bug, caused undefined behavior if FILE live in stack.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixed sign extension bug, caused undefined behavior if FILE live in stack.
</pre>
</div>
</content>
</entry>
<entry>
<title>Removed unused variables.</title>
<updated>1998-09-07T21:55:01+00:00</updated>
<author>
<name>Alexander Langer</name>
<email>alex@FreeBSD.org</email>
</author>
<published>1998-09-07T21:55:01+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=cecc7b0974187640c58fbd23711ff7a1874eae46'/>
<id>cecc7b0974187640c58fbd23711ff7a1874eae46</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
