source: trunk/gc6.8/doc/README.win32@ 360

Last change on this file since 360 was 132, checked in by cinc, 19 years ago

Boehm-Demers-Weiser garbage collector. Single-threaded for OS/2.

File size: 9.6 KB
Line 
1The collector has at various times been compiled under Windows 95 & later, NT,
2and XP, with the original Microsoft SDK, with Visual C++ 2.0, 4.0, and 6, with
3the GNU win32 tools, with Borland 4.5, with Watcom C, and recently
4with the Digital Mars compiler. It is likely that some of these have been
5broken in the meantime. Patches are appreciated.
6
7For historical reasons,
8the collector test program "gctest" is linked as a GUI application,
9but does not open any windows. Its output appears in the file
10"gc.log". It may be started from the file manager. The hour glass
11cursor may appear as long as it's running. If it is started from the
12command line, it will usually run in the background. Wait a few
13minutes (a few seconds on a modern machine) before you check the output.
14You should see either a failure indication or a "Collector appears to
15work" message.
16
17The cord test program has not been ported (but should port
18easily). A toy editor (cord/de.exe) based on cords (heavyweight
19strings represented as trees) has been ported and is included.
20It runs fine under either win32 or win32S. It serves as an example
21of a true Windows application, except that it was written by a
22nonexpert Windows programmer. (There are some peculiarities
23in the way files are displayed. The <cr> is displayed explicitly
24for standard DOS text files. As in the UNIX version, control
25characters are displayed explicitly, but in this case as red text.
26This may be suboptimal for some tastes and/or sets of default
27window colors.)
28
29In general -DREDIRECT_MALLOC is unlikely to work unless the
30application is completely statically linked.
31
32The collector normally allocates memory from the OS with VirtualAlloc.
33This appears to cause problems under Windows NT and Windows 2000 (but
34not Windows 95/98) if the memory is later passed to CreateDIBitmap.
35To work around this problem, build the collector with -DUSE_GLOBAL_ALLOC.
36This is currently incompatible with -DUSE_MUNMAP. (Thanks to Jonathan
37Clark for tracking this down. There's some chance this may be fixed
38in 6.1alpha4, since we now separate heap sections with an unused page.)
39
40Microsoft Tools
41---------------
42For Microsoft development tools, rename NT_MAKEFILE as
43MAKEFILE. (Make sure that the CPU environment variable is defined
44to be i386.) In order to use the gc_cpp.h C++ interface, all
45client code should include gc_cpp.h.
46
47For historical reasons,
48the collector test program "gctest" is linked as a GUI application,
49but does not open any windows. Its output appears in the file
50"gc.log". It may be started from the file manager. The hour glass
51cursor may appear as long as it's running. If it is started from the
52command line, it will usually run in the background. Wait a few
53minutes (a few seconds on a modern machine) before you check the output.
54You should see either a failure indication or a "Collector appears to
55work" message.
56
57If you would prefer a VC++.NET project file, ask boehm@acm.org. One has
58been contributed, but it seems to contain some absolute paths etc., so
59it can presumably only be a starting point, and is not in the standard
60distribution. It is unclear (to me, Hans Boehm) whether it is feasible to
61change that.
62
63Clients may need to define GC_NOT_DLL before including gc.h, if the
64collector was built as a static library (as it normally is in the
65absence of thread support).
66
67GNU Tools
68---------
69For GNU-win32, use the regular makefile, possibly after uncommenting
70the line "include Makefile.DLLs". The latter should be necessary only
71if you want to package the collector as a DLL.
72[Is the following sentence obsolete? -HB] The GNU-win32 port is
73believed to work only for b18, not b19, probably due to linker changes
74in b19. This is probably fixable with a different definition of
75DATASTART and DATAEND in gcconfig.h.
76
77The collector should also be buildable under Cygwin with either the
78old standard Makefile, or with the "configure;make" machinery.
79
80Borland Tools
81-------------
82[Rarely tested.]
83For Borland tools, use BCC_MAKEFILE. Note that
84Borland's compiler defaults to 1 byte alignment in structures (-a1),
85whereas Visual C++ appears to default to 8 byte alignment (/Zp8).
86The garbage collector in its default configuration EXPECTS AT
87LEAST 4 BYTE ALIGNMENT. Thus the BORLAND DEFAULT MUST
88BE OVERRIDDEN. (In my opinion, it should usually be anyway.
89I expect that -a1 introduces major performance penalties on a
90486 or Pentium.) Note that this changes structure layouts. (As a last
91resort, gcconfig.h can be changed to allow 1 byte alignment. But
92this has significant negative performance implications.)
93The Makefile is set up to assume Borland 4.5. If you have another
94version, change the line near the top. By default, it does not
95require the assembler. If you do have the assembler, I recommend
96removing the -DUSE_GENERIC.
97
98Incremental Collection
99----------------------
100There is some support for incremental collection. This is
101currently pretty simple-minded. Pages are protected. Protection
102faults are caught by a handler installed at the bottom of the handler
103stack. This is both slow and interacts poorly with a debugger.
104Whenever possible, I recommend adding a call to
105GC_enable_incremental at the last possible moment, after most
106debugging is complete. Unlike the UNIX versions, no system
107calls are wrapped by the collector itself. It may be necessary
108to wrap ReadFile calls that use a buffer in the heap, so that the
109call does not encounter a protection fault while it's running.
110(As usual, none of this is an issue unless GC_enable_incremental
111is called.)
112
113Note that incremental collection is disabled with -DSMALL_CONFIG.
114
115Threads
116-------
117
118James Clark has contributed the necessary code to support win32 threads
119with the collector in a DLL.
120Use NT_THREADS_MAKEFILE (a.k.a gc.mak) instead of NT_MAKEFILE
121to build this version. Note that this requires some files whose names
122are more than 8 + 3 characters long. Thus you should unpack the tar file
123so that long file names are preserved. To build the garbage collector
124test with VC++ from the command line, use
125
126nmake /F ".\gc.mak" CFG="gctest - Win32 Release"
127
128This requires that the subdirectory gctest\Release exist.
129The test program and DLL will reside in the Release directory.
130
131This version relies on the collector residing in a dll.
132
133This version currently supports incremental collection only if it is
134enabled before any additional threads are created.
135
136Since 6.3alpha2, threads are also better supported in static library builds
137with Microsoft tools (use NT_STATIC_THREADS_MAKEFILE) and with the GNU
138tools. In all cases,the collector must be built with GC_WIN32_THREADS
139defined, even if the Cygwin pthreads interface is used.
140(NT_STATIC_THREADS_MAKEFILE does this implicitly. Under Cygwin,
141./configure --enable-threads=posix defines GC_WIN32_THREADS.) Threads must be
142created with GC_CreateThread. This can be accomplished by
143including gc.h and then calling CreateThread, which is redefined
144by gc.h.
145
146For the statically linked versions, it is required that GC_init()
147be called before other GC calls, since there seems to be no implicit way
148to initialize the allocation lock. The easiest way to ensure this in
149portable code is to call GC_INIT() from the main executable (not
150a dynamic library) before calling any other GC_ routines.
151
152We strongly advise against using the TerminateThread() win32 API call,
153especially with the garbage collector. Any use is likely to provoke a
154crash in the GC, since it makes it impossible for the collector to
155correctly track threads.
156
157
158Watcom compiler
159---------------
160
161Ivan V. Demakov's README for the Watcom port:
162
163The collector has been compiled with Watcom C 10.6 and 11.0.
164It runs under win32, win32s, and even under msdos with dos4gw
165dos-extender. It should also run under OS/2, though this isn't
166tested. Under win32 the collector can be built either as dll
167or as static library.
168
169Note that all compilations were done under Windows 95 or NT.
170For unknown reason compiling under Windows 3.11 for NT (one
171attempt has been made) leads to broken executables.
172
173Incremental collection is not supported.
174
175cord is not ported.
176
177Before compiling you may need to edit WCC_MAKEFILE to set target
178platform, library type (dynamic or static), calling conventions, and
179optimization options.
180
181To compile the collector and testing programs use the command:
182 wmake -f WCC_MAKEFILE
183
184All programs using gc should be compiled with 4-byte alignment.
185For further explanations on this see comments about Borland.
186
187If the gc is compiled as dll, the macro ``GC_DLL'' should be defined before
188including "gc.h" (for example, with -DGC_DLL compiler option). It's
189important, otherwise resulting programs will not run.
190
191Ivan Demakov (email: ivan@tgrad.nsk.su)
192
193Win32S
194------
195
196[The following is probably obsolete. The win32s support is still in the
197collector, but I doubt anyone cares, or has tested it recently.]
198
199The collector runs under both win32s and win32, but with different semantics.
200Under win32, all writable pages outside of the heaps and stack are
201scanned for roots. Thus the collector sees pointers in DLL data
202segments. Under win32s, only the main data segment is scanned.
203(The main data segment should always be scanned. Under some
204versions of win32s, other regions may also be scanned.)
205Thus all accessible objects should be accessible from local variables
206or variables in the main data segment. Alternatively, other data
207segments (e.g. in DLLs) may be registered with the collector by
208calling GC_init() and then GC_register_root_section(a), where
209a is the address of some variable inside the data segment. (Duplicate
210registrations are ignored, but not terribly quickly.)
211
212(There are two reasons for this. We didn't want to see many 16:16
213pointers. And the VirtualQuery call has different semantics under
214the two systems, and under different versions of win32s.)
215
Note: See TracBrowser for help on using the repository browser.