mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-25 15:00:45 -08:00
205 lines
7.1 KiB
HTML
205 lines
7.1 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
|
|
<head>
|
|
|
|
<title>The design of the MPS thread manager</title>
|
|
|
|
</head>
|
|
|
|
<body bgcolor="#FFFFFF" text="#000000" link="#000099" vlink="#660066" alink="#FF0000">
|
|
|
|
<div align="center">
|
|
|
|
<p>
|
|
<a href="/">Ravenbrook</a> /
|
|
<a href="/project/">Projects</a> /
|
|
<a href="/project/mps/">Memory Pool System</a> /
|
|
<a href="/project/mps/master/">Master Product Sources</a> /
|
|
<a href="/project/mps/master/design/">Design Documents</a>
|
|
</p>
|
|
|
|
<p><i><a href="/project/mps/">Memory Pool System Project</a></i></p>
|
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
<pre>
|
|
THE DESIGN OF THE MPS THREAD MANAGER
|
|
design.mps.thread-manager
|
|
incomplete design
|
|
richard 1995-11-20
|
|
|
|
PURPOSE
|
|
|
|
The Thread Manager handles various thread-related functions required by the
|
|
MPS. These are:
|
|
|
|
- stack scanning
|
|
|
|
- suspension and resumption of the mutator threads
|
|
|
|
CONTEXT
|
|
|
|
The barrier requires suspension and resumption of threads in order to ensure
|
|
that the collector has exclusive access to part of memory.
|
|
[design.mps.barrier.@@@]
|
|
|
|
Stack scanning is provided as a service to the client. [Link?@@@]
|
|
|
|
OVERVIEW
|
|
|
|
Each thread is represented by an object of type "Thread". The Thread type is
|
|
implemented as an ADT. A deque of Thread objects is maintained in the Space.
|
|
The Thread object contains OS dependent information about the thread --
|
|
information necessary for manipulating the thread and for scanning the thread
|
|
context. Thread "registration" adds or removes the current thread to the
|
|
Thread deque in the Space.
|
|
|
|
DETAILED DESIGN
|
|
|
|
Stack Scan
|
|
This is a module providing a stack scanning function. The scanning is arch/os
|
|
dependent. Typically the function will push the save registers (those
|
|
preserved across function calls) which plausibly contain pointers (not FP/debug
|
|
registers) and call TraceScanStack on the appropriate range.
|
|
|
|
Thread Interface
|
|
|
|
- Register/Deregister
|
|
register returns "Thread"
|
|
|
|
- Suspend/Resume
|
|
suspends registered threads which are not the current thread
|
|
|
|
- ThreadDequeScan
|
|
ambiguously scans the stacks and root registers of all threads. The exact
|
|
definition is os/arch dependent
|
|
|
|
Single-Threaded Generic Implementation
|
|
|
|
- single thread
|
|
- Suspend/Resume do nothing because there are no other threads.
|
|
- registration records stack base only.
|
|
- ThreadDequeScan calls StackScan
|
|
|
|
Win32 Implementation
|
|
- supports multiple threads
|
|
- structured exception style faults are expected
|
|
- suspend/resume loop over threads and call Win32 suspend/resume
|
|
- registration records information for current thread
|
|
- stack base for current thread
|
|
- Win32 "handle" with SUSPEND/RESUME and GET CONTEXT access to the thread.
|
|
This handle is needed as parameter to
|
|
- Suspend/ResumeThread
|
|
- ThreadGetContext
|
|
- Win32 ThreadId this is so that the current thread may be identified.
|
|
- stack scanning is Win32 specific
|
|
- ThreadDequeScan uses GetThreadContext for other threads, giving root
|
|
registers and the stack pointer
|
|
- The thread's registers are dumped into the CONTEXT structure and fixed in
|
|
memory.
|
|
- scan the stack (getting sp from CONTEXT)
|
|
- ThreadDequeScan calls StackScan to do the current thread. The current
|
|
thread is different because GetContext doesn't work on it. (The context would
|
|
not necessarily have the values which were in the saved registers on entry to
|
|
the MM).
|
|
|
|
ISSUES
|
|
|
|
Scanning after Exceptions
|
|
StackScan relies on the non-preserved registers having been pushed on the
|
|
stack. If we want to scan after a fault we must make sure that these registers
|
|
are either already stored on the stack, or, have an extra function to do this
|
|
explicitly.
|
|
|
|
Multiple Registration
|
|
It is not clear whether a thread should be allowed to be registered multiple
|
|
times. We do not provide a mechanism for knowing whether a thread is already
|
|
registered with a space.
|
|
</pre>
|
|
|
|
|
|
<h2><a id="section-A" name="section-A">A. References</a></h2>
|
|
|
|
<!-- Template Entry
|
|
|
|
<table>
|
|
|
|
<tr valign="top">
|
|
|
|
<td>[<a id="ref-#REF#" name="ref-#REF#" href="#REF_URL#">#REF_NAME#</a>]</td>
|
|
|
|
<td>
|
|
"#REF_TITLE#";
|
|
#REF_AUTHOR#;
|
|
<URL: <a href="#REF_URL#">#REF_URL#</a>>;
|
|
#REF_DATE#.
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
-->
|
|
|
|
|
|
<h2><a id="section-B" name="section-B">B. Document History</a></h2>
|
|
|
|
<table>
|
|
|
|
<tr valign="top">
|
|
|
|
<td>2002-06-21</td>
|
|
|
|
<td><a href="mailto:rb@ravenbrook.com">RB</a></td>
|
|
|
|
<td>Converted from MMInfo database design document.</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
<h2><a id="section-C" name="section-C">C. Copyright and License</a></h2>
|
|
|
|
<p> This document is copyright © 1995-2002 <a href="http://www.ravenbrook.com/">Ravenbrook Limited</a>. All rights reserved. This is an open source license. Contact Ravenbrook for commercial licensing options. </p>
|
|
|
|
<p> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: </p>
|
|
|
|
<ol>
|
|
|
|
<li> Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. </li>
|
|
|
|
<li> Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. </li>
|
|
|
|
<li> Redistributions in any form must be accompanied by information on how to obtain complete source code for the this software and any accompanying software that uses this software. The source code must either be included in the distribution or be available for no more than the cost of distribution plus a nominal fee, and must be freely redistributable under reasonable conditions. For an executable file, complete source code means the source code for all modules it contains. It does not include source code for modules or files that typically accompany the major components of the operating system on which the executable file runs. </li>
|
|
|
|
</ol>
|
|
|
|
<p> <strong> This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement, are disclaimed. In no event shall the copyright holders and contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. </strong> </p>
|
|
|
|
|
|
<hr />
|
|
|
|
<div align="center">
|
|
|
|
<p><code>$Id$</code></p>
|
|
|
|
<p>
|
|
<a href="/">Ravenbrook</a> /
|
|
<a href="/project/">Projects</a> /
|
|
<a href="/project/mps/">Memory Pool System</a> /
|
|
<a href="/project/mps/master/">Master Product Sources</a> /
|
|
<a href="/project/mps/master/design/">Design Documents</a>
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|