1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
|
WELCOME!
The State Threads Library is a small application library which provides
a foundation for writing fast and highly scalable Internet applications
(such as web servers, proxy servers, mail transfer agents, and so on,
really any network-data-driven application) on UNIX-like platforms. It
combines the simplicity of the multithreaded programming paradigm, in
which one thread supports each simultaneous connection, with the
performance and scalability of an event-driven state machine
architecture. In other words, this library offers a threading API for
structuring an Internet application as a state machine. For more
details, please see the library documentation in the "docs" directory or
on-line at
http://state-threads.sourceforge.net/docs/
The State Threads Project is an open source project for maintaining and
enhancing the State Threads Library. For more information about this
project, please see
http://state-threads.sourceforge.net/
BUILDING
To build the library by hand, use the GNU make utility. Run the make
command (e.g., `gmake') with no arguments to display all supported
targets.
To build more or less automatically, first set the CONFIG_GUESS_PATH
variable in either osguess.sh or your environment then run "make
default" which guesses your OS and builds. Requires the "config.guess"
utility from GNU autoconf (not included with ST). You can use one from
a larger "main" software project or just use any config.guess available
on your system. You can also get it directly from GNU:
ftp://ftp.gnu.org/gnu/autoconf/
To build rpms (RedHat Linux 6.2 or later, Linux/Mandrake, Solaris with
gnome, etc.):
download the latest st-x.y.tar.gz
# rpm -ta st-x.y.tar.gz
The .rpms will land in /usr/src/RPMS/<arch>. Install them with:
# rpm -i libst*.rpm
Requires GNU automake and rpm 3.0.3 or later.
Debian users:
If you run potato, please upgrade to woody.
If you run woody, "apt-get install libst-dev" will get you v1.3.
If you run testing/unstable, you will get the newest available version.
If you *must* have the newest libst in woody, you may follow these
not-recommended instructions:
1. Add "deb-src <your-favourite-debian-mirror> unstable main" to your
/etc/apt/sources.list
2. apt-get update
3. apt-get source st
4. cd st-1.4 (or whatever version you got)
5. debuild
6. dpkg -i ../*.deb
If your application uses autoconf to search for dependencies and you
want to search for a given version of libst, you can simply add
PKG_CHECK_MODULES(MYAPP, st >= 1.3 mumble >= 0.2.23)
to your configure.ac/in. This will define @MYAPP_LIBS@ and
@MYAPP_CFLAGS@ which you may then use in your Makefile.am/in files to
link against mumble and st.
LICENSE
The State Threads library is a derivative of the Netscape Portable
Runtime library (NSPR). All source code in this directory is
distributed under the terms of the Mozilla Public License (MPL) version
1.1 or the GNU General Public License (GPL) version 2 or later. For
more information about these licenses please see
http://www.mozilla.org/MPL/ and http://www.gnu.org/copyleft/.
All source code in the "examples" directory is distributed under the BSD
style license.
PLATFORMS
Please see the "docs/notes.html" file for the list of currently
supported platforms.
DEBUGGER SUPPORT
It's almost impossible to print SP and PC in a portable way. The only
way to see thread's stack platform-independently is to actually jump to
the saved context. That's what the _st_iterate_threads() function does.
Do the following to iterate over all threads:
- set the _st_iterate_threads_flag to 1 in debugger
- set breakpoint at the _st_show_thread_stack() function
(which does nothing)
- call the _st_iterate_threads() function which jumps to the
next thread
- at each break you can explore thread's stack
- continue
- when iteration is complete, you return to the original
point (you can see thread id and a message as arguments of
the _st_show_thread_stack() function).
You can call _st_iterate_threads() in three ways:
- Insert it into your source code at the point you want to
go over threads.
- Just run application and this function will be called at
the first context switch.
- Call it directly from the debugger at any point.
This works with gdb and dbx.
Example using gdb:
(gdb) set _st_iterate_threads_flag = 1
(gdb) b _st_show_thread_stack
...
(gdb) call _st_iterate_threads()
...
(gdb) bt
...
(gdb) c
...
(gdb) bt
...
(gdb) c
...
and so on...
_st_iterate_threads_flag will be set to 0 automatically
after iteration is over or you can set it to 0 at any time
to stop iteration.
Sometimes gdb complains about SIGSEGV when you call a function
directly at gdb command-line. It can be ignored -- just call the
same function right away again, it works just fine. For example:
(gdb) set _st_iterate_threads_flag = 1
(gdb) b _st_show_thread_stack
Breakpoint 1 at 0x809bbbb: file sched.c, line 856.
(gdb) call _st_iterate_threads()
Program received signal SIGSEGV, Segmentation fault.
....
(gdb) # just call the function again:
(gdb) call _st_iterate_threads()
Breakpoint 1, _st_show_thread_stack (thread=0x4017aee4, messg=0x80ae7a2
"Iteration started") at sched.c:856
856 }
....
You can use simple gdb command-line scripting to display
all threads and their stack traces at once:
(gdb) while _st_iterate_threads_flag
>bt
>c
>end
....
Another script to stop at the thread with the specific thread id
(e.g., 0x40252ee4):
(gdb) # set the flag again:
(gdb) set _st_iterate_threads_flag = 1
(gdb) call _st_iterate_threads()
Breakpoint 1, _st_show_thread_stack (thread=0x4017aee4, messg=0x80ae7a2
"Iteration started") at sched.c:856
856 }
....
(gdb) while thread != 0x40252ee4
>c
>end
....
....
Breakpoint 1, _st_show_thread_stack (thread=0x40252ee4, messg=0x0) at
sched.c:856
856 }
(gdb) bt
....
(gdb) # don't want to continue iteration, unset the flag:
(gdb) set _st_iterate_threads_flag = 0
(gdb) c
Continuing.
Breakpoint 1, _st_show_thread_stack (thread=0x0, messg=0x80ae78e "Iteration
completed")
at sched.c:856
856 }
(gdb) c
Continuing.
(gdb) return
Make selected stack frame return now? (y or n) y
#0 0x4011254e in __select ()
from /lib/libc.so.6
(gdb) detach
CHANGE LOG
Changes from 1.8 to 1.9.
------------------------
o Support 32-bit and 64-bit Intel Macs.
o Added ST_VERSION string, and ST_VERSION_MAJOR and ST_VERSION_MINOR
[bug 1796801].
o Fixed some compiler warnings, based on a patch from Brian Wellington
[bug 1932741].
Changes from 1.7 to 1.8.
--------------------------
o Added support for kqueue and epoll on platforms that support them.
Added ability to choose the event notification system at program
startup.
o Long-overdue public definitions of ST_UTIME_NO_TIMEOUT (-1ULL) and
ST_UTIME_NO_WAIT (0) [bug 1514436].
o Documentation patch for st_utime() [bug 1514484].
o Documentation patch for st_timecache_set() [bug 1514486].
o Documentation patch for st_netfd_serialize_accept() [bug 1514494].
o Added st_writev_resid() [rfe 1538344].
o Added st_readv_resid() [rfe 1538768] and, for symmetry, st_readv().
Changes from 1.6 to 1.7.
------------------------
o Support glibc 2.4, which breaks programs that manipulate jump buffers.
Replaced Linux IA64 special cases with new md.S that covers all
Linux.
Changes from 1.5.2 to 1.6.
--------------------------
none
Changes from 1.5.1 to 1.5.2.
----------------------------
o Alfred Perlstein's context switch callback feature.
o Claus Assmann's st_recvmsg/st_sendmsg wrappers.
o Extra stack padding for platforms that need it.
o Ron Arts's timeout clarifications in the reference manual.
o Raymond Bero and Anton Berezin's AMD64 FreeBSD port.
o Claus Assmann's AMD64 SunOS 5.10 port.
o Claus Assmann's AMD64 OpenBSD port.
o Michael Abd-El-Malek's Mac OS X port.
o Michael Abd-El-Malek's stack printing patch.
Changes from 1.5.0 to 1.5.1.
----------------------------
o Andreas Gustafsson's USE_POLL fix.
o Gene's st_set_utime_function() enhancement.
Changes from 1.4 to 1.5.0.
--------------------------
o Andreas Gustafsson's performance patch.
o New extensions: Improved DNS resolver, generic LRU cache, in-process
DNS cache, and a program to test the resolver and cache.
o Support for AMD Opteron 64-bit CPUs under Linux.
o Support for SPARC-64 under Solaris.
o Andreas Gustafsson's support for VAX under NetBSD.
o Changed unportable #warning directives in md.h to #error.
Changes from 1.3 to 1.4.
------------------------
o Andreas Gustafsson's NetBSD port.
o Wesley W. Terpstra's Darwin (MacOS X) port.
o Support for many CPU architectures under Linux and *BSD.
o Renamed private typedefs so they don't conflict with public ones any
more.
o common.h now includes public.h for strict prototyping.
o Joshua Levy's recommendation to make st_connect() and st_sendto()
accept const struct sockaddr pointers, as the originals do.
o Clarified the documentation regarding blocking vs. non-blocking I/O.
o Cygwin support.
o Created the extensions directory.
o Fixed warnings from ia64asm.S.
Changes from 1.2 to 1.3.
------------------------
o Added st_read_resid() and st_write_resid() to allow the caller to know
how much data was transferred before an error occurred. Updated
documentation.
o Updated project link, copyrights, and documentation regarding
timeouts. Added comment to st_connect().
o Optimized the _st_add_sleep_q() function in sched.c. Now we walk the
sleep queue *backward* when inserting a thread into it. When you
have lots (hundreds) of threads and several timeout values, it takes
a while to insert a thread at the appropriate point in the sleep
queue. The idea is that often this appropriate point is closer to
the end of the queue rather than the beginning. Measurements show
performance improves with this change. In any case this change
should do no harm.
o Added a hint of when to define USE_POLL and when not to, to the
Makefile.
o Added debugging support (files common.h and sched.c). See above.
o Decreased the number of reallocations of _ST_POLLFDS in sched.c.
Inspired by Lev Walkin.
o Fixed st_usleep(-1) and st_sleep(-1), and added a warning to the
documentation about too-large timeouts.
o Linux/*BSD Alpha port.
o Wesley W. Terpstra modernized the build process:
- properly build relocatable libraries under bsd and linux
- use library versioning
- added rpm spec file
- added debian/ files
See above for build instructions.
Changes from 1.1 to 1.2.
------------------------
o Added st_randomize_stacks().
o Added a patch contributed by Sascha Schumann.
Changes from 1.0 to 1.1.
------------------------
o Relicensed under dual MPL-GPL.
o OpenBSD port.
o Compile-time option to use poll() instead of select() for
event polling (see Makefile).
This is useful if you want to support a large number of open
file descriptors (larger than FD_SETSIZE) within a single
process.
o Linux IA-64 port.
Two issues make IA-64 different from other platforms:
- Besides the traditional call stack in memory, IA-64 uses the
general register stack. Thus each thread needs a backing store
for the register stack in addition to the memory stack.
- Current implementation of setjmp()/longjmp() can not be used
for thread context-switching since it assumes that only one
register stack exists. Using special assembly functions for
context-switching is unavoidable.
o Thread stack capping on IRIX.
This allows some profiling tools (such as SpeedShop) to know when
to stop unwinding the stack. Without this libexc, used by SpeedShop,
traces right off the stack and crashes.
o Miscellaneous documentation additions.
COPYRIGHTS
Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
All Rights Reserved.
|