complement-svn Mailing List for Complement (Page 19)
Status: Pre-Alpha
Brought to you by:
complement
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(61) |
Nov
(76) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(33) |
Feb
(41) |
Mar
(16) |
Apr
|
May
(22) |
Jun
(14) |
Jul
(64) |
Aug
(60) |
Sep
(35) |
Oct
(34) |
Nov
(10) |
Dec
(5) |
2008 |
Jan
(4) |
Feb
(24) |
Mar
(10) |
Apr
(30) |
May
(15) |
Jun
(50) |
Jul
(20) |
Aug
(7) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
|
From: <com...@us...> - 2007-02-15 12:38:54
|
Revision: 1528 http://svn.sourceforge.net/complement/?rev=1528&view=rev Author: complement Date: 2007-02-15 04:38:53 -0800 (Thu, 15 Feb 2007) Log Message: ----------- snapshot 2007-02-15 Added Paths: ----------- tags/complement-20070215/ Copied: tags/complement-20070215 (from rev 1527, trunk/complement) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-15 12:37:54
|
Revision: 1527 http://svn.sourceforge.net/complement/?rev=1527&view=rev Author: complement Date: 2007-02-15 04:37:22 -0800 (Thu, 15 Feb 2007) Log Message: ----------- space Modified Paths: -------------- trunk/complement/explore/test/sockios/sockios_test.h Modified: trunk/complement/explore/test/sockios/sockios_test.h =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.h 2007-02-12 15:35:17 UTC (rev 1526) +++ trunk/complement/explore/test/sockios/sockios_test.h 2007-02-15 12:37:22 UTC (rev 1527) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/07 10:51:25 ptr> +// -*- C++ -*- Time-stamp: <07/02/13 10:23:29 ptr> /* * @@ -37,6 +37,8 @@ void sigpipe(); void read0(); void read0_srv(); + + void srv2_fork(); }; #endif // __sockios_test_h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-12 15:35:26
|
Revision: 1526 http://svn.sourceforge.net/complement/?rev=1526&view=rev Author: complement Date: 2007-02-12 07:35:17 -0800 (Mon, 12 Feb 2007) Log Message: ----------- bit chenges in navigation; attach boiler1 Modified Paths: -------------- trunk/WWW/explore/Complement/Boiler1.shtml trunk/WWW/explore/Complement/ContentTech.shtml trunk/WWW/explore/Complement/MakeConfig.shtml trunk/WWW/explore/Complement/MakeMacros.shtml trunk/WWW/explore/Complement/MakeStart.shtml trunk/WWW/explore/Complement/MakeTags.shtml trunk/WWW/explore/Complement/Technical.shtml Added Paths: ----------- trunk/WWW/explore/Complement/ContentBoiler.shtml trunk/WWW/explore/Complement/ContentBuild.shtml trunk/WWW/explore/Complement/head-boiler.shtml trunk/WWW/explore/Complement/head-build.shtml Modified: trunk/WWW/explore/Complement/Boiler1.shtml =================================================================== --- trunk/WWW/explore/Complement/Boiler1.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/Boiler1.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -12,12 +12,12 @@ </head> <body> -<!--#include file="head-tech.shtml" --> +<!--#include file="head-boiler.shtml" --> <div class="toppic"> <img src="img/jpg/apropos.jpg"> </div> <div class="main"> - <h2 class="lheader"></h2> + <h2 class="lheader">Black box</h2> <p> Let's consider design of model of boiler (design of software model). </p> @@ -37,6 +37,7 @@ on question 'What I expect from this device?'. </p> + <h2 class="lheader">Interacting components</h2> <p> On the next step I should define components of the whole system and expected interaction between ones. @@ -46,6 +47,7 @@ <img src="img/fig/boiler-comp.png"> </center> + <h2 class="lheader">Decomposition: consider details</h2> <p> Now, descending in abstraction layer, consider every component separately. </p> Added: trunk/WWW/explore/Complement/ContentBoiler.shtml =================================================================== --- trunk/WWW/explore/Complement/ContentBoiler.shtml (rev 0) +++ trunk/WWW/explore/Complement/ContentBoiler.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -0,0 +1,10 @@ +<!-- Time-stamp: <06/12/08 00:48:21 ptr> --> +<div class="nodecor"> +<a href="index.shtml">Home</a><br> +<a href="Technical.shtml">Architecture, specifications,<br> technical descriptions</a><br> +<a href="Boiler1.shtml">EDA sample: design and coding bioler system</a><br> +<a href="compare.pdf">Comparison of STL Implementations (PDF)</a><br> +<br> +<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=63160&type=2" width="125" height="37" border="0" alt="SourceForge.net Logo"></a><br> +</div> +<!-- Created: Mon Oct 7 17:32:53 MSD 2002 --> Added: trunk/WWW/explore/Complement/ContentBuild.shtml =================================================================== --- trunk/WWW/explore/Complement/ContentBuild.shtml (rev 0) +++ trunk/WWW/explore/Complement/ContentBuild.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -0,0 +1,13 @@ +<!-- Time-stamp: <06/12/08 00:48:21 ptr> --> +<div class="nodecor"> +<a href="index.shtml">Home</a><br> +<a href="Technical.shtml">Architecture, specifications,<br> technical descriptions</a><br> +<a href="Anti-autotools.shtml">Anti-autotools</a><br> +<a href="MakeStart.shtml">Make system: quick start</a><br> +<a href="MakeConfig.shtml">Make system: global customization</a><br> +<a href="MakeTags.shtml">Make system: tags</a><br> +<a href="MakeMacros.shtml">Make system: macros</a><br> +<br> +<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=63160&type=2" width="125" height="37" border="0" alt="SourceForge.net Logo"></a><br> +</div> +<!-- Created: Mon Oct 7 17:32:53 MSD 2002 --> Modified: trunk/WWW/explore/Complement/ContentTech.shtml =================================================================== --- trunk/WWW/explore/Complement/ContentTech.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/ContentTech.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -1,11 +1,8 @@ <!-- Time-stamp: <06/12/08 00:48:21 ptr> --> <div class="nodecor"> <a href="index.shtml">Home</a><br> -<a href="Anti-autotools.shtml">Anti-autotools</a><br> -<a href="MakeStart.shtml">Make system: quick start</a><br> -<a href="MakeConfig.shtml">Make system: global customization</a><br> -<a href="MakeTags.shtml">Make system: tags</a><br> -<a href="MakeMacros.shtml">Make system: macros</a><br> +<a href="MakeStart.shtml">Make system</a><br> +<a href="Boiler1.shtml">EDA sample: design and coding bioler system</a><br> <a href="compare.pdf">Comparison of STL Implementations (PDF)</a><br> <br> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=63160&type=2" width="125" height="37" border="0" alt="SourceForge.net Logo"></a><br> Modified: trunk/WWW/explore/Complement/MakeConfig.shtml =================================================================== --- trunk/WWW/explore/Complement/MakeConfig.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/MakeConfig.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -5,6 +5,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="keywords" content="build, autotools, make, GNU, compilation, link"> <link rel="stylesheet" type="text/css" href="main.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="decor.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="float.css" media="screen" title="general"> @@ -12,15 +13,83 @@ </head> <body> -<!--#include file="head-tech.shtml" --> +<!--#include file="head-build.shtml" --> <div class="toppic"> <img src="img/jpg/apropos.jpg"> </div> <div class="main"> <h2 class="lheader">Global customization: configure again?</h2> + <p>Different projects assume different environment. Different + environment require customization by hands or auto-configuration.</p> + + <p>Of cause 'auto' assume 'user not involved into configuration process'. + Looks like good! But in reality this designate that make/configuration system propagate + own point of view for project's environment, and often hide this assumptions + from user.</p> + + <p>My desision is: I assume some 'default' configuration, but if this configuration not + serve you needs, you may explicitly say you preferance. In this terms, utility that help + you collect you specific requirements is useful.</p> + + <p>My makesystem provide 'configure' script too. But in contrast to autotools, this + script only provide help in writing useful options, show available options and describe ones. + Not more.</p> + + <p>If project require some component (say, <tt>boost::program_options</tt>), but apropriate + libraries and/or headers not available, then you will see explicit error during compilation + process, and this is only point where project depends upon <tt>boost::program_options</tt>. + If this would checked by configration process, the project would has two points of dependency + from <tt>boost::program_options</tt>: within configuration script and within project itself.</p> + <pre class="ddisplay"> +./configure --help +Configuration utility. + +Usage: + + configure [options] + +Available options: + + --target=<target> target platform (cross-compiling) + --help print this help message and exit + --with-stlport=<dir> use STLport in catalog <dir> + --without-stlport compile without STLport (default) + --with-boost=<dir> use boost headers in catalog <dir> + --with-system-boost use boost installed on this system + --with-msvc=<dir> use MS VC from this catalog + --with-mssdk=<dir> use MS SDK from this catalog + --with-mwcw=<dir> Metrowerks CodeWarrior compiler catalog (useful for mw* compilers) + i.e. something like "c:/Program Files/Metrowerks/CodeWarrior" + --with-nwsdk=<dir> use Novell NDK/SDK from this catalog (useful for *-*-netware target) + i.e. something like "c:/Novell/ndk/nwsdk" + --with-extra-cxxflags=<options> + pass extra options to C++ compiler + --use-static-gcc use static gcc libs instead of shared libgcc_s (useful for gcc compiler, + that was builded with --enable-shared [default]; if compiler was builded + with --disable-shared, static libraries will be used in any case) + --clean remove custom settings (file Makefiles/config.mak) + and use default values + --with-cxx=<name> use <name> as C++ compiler + --with-cc=<name> use <name> as C compiler + --use-compiler-family=<name> use compiler family; one of: + gcc GNU compilers + icc Intel compilers + mwccnlm Metrowerks CodeWarrior for Novell Netware + aCC HP\'s aCC compilers + CC SunPro\'s CC compilers + + default is 'gcc' family + --without-debug don\'t build debug variant + --without-stldebug don\'t build STLport\'s STLP_DEBUG mode + --enable-static build static + --disable-shared don\'t build shared </pre> + <center> + <a href="MakeStart.shtml"><< Prev</a> <a href="MakeTags.shtml">Next >></a> + </center> + </div> <!--#include file="foot.shtml" --> <!-- Created: Mon Oct 7 16:33:17 MSD 2002 --> Modified: trunk/WWW/explore/Complement/MakeMacros.shtml =================================================================== --- trunk/WWW/explore/Complement/MakeMacros.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/MakeMacros.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -5,6 +5,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="keywords" content="build, autotools, make, GNU, compilation, link"> <link rel="stylesheet" type="text/css" href="main.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="decor.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="float.css" media="screen" title="general"> @@ -12,7 +13,7 @@ </head> <body> -<!--#include file="head-tech.shtml" --> +<!--#include file="head-build.shtml" --> <div class="toppic"> <img src="img/jpg/apropos.jpg"> </div> @@ -112,6 +113,11 @@ <dt>EXTRA_POST_STLDBG</dt> <dd>tags that should be made after stldbg-shared; not defined</dd> </dl> + + <center> + <a href="MakeTags.shtml"><< Prev</a> + </center> + </div> <!--#include file="foot.shtml" --> <!-- Created: Fri Dec 8 14:11:17 MSD 2006 --> Modified: trunk/WWW/explore/Complement/MakeStart.shtml =================================================================== --- trunk/WWW/explore/Complement/MakeStart.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/MakeStart.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -5,6 +5,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="keywords" content="build, autotools, make, GNU, compilation, link"> <link rel="stylesheet" type="text/css" href="main.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="decor.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="float.css" media="screen" title="general"> @@ -12,7 +13,7 @@ </head> <body> -<!--#include file="head-tech.shtml" --> +<!--#include file="head-build.shtml" --> <div class="toppic"> <img src="img/jpg/apropos.jpg"> </div> @@ -163,9 +164,6 @@ !include $(SRCROOT)/Makefiles/nmake/top.mak </pre> - <h2 class="lheader">Global settings: configure again?</h2> -<pre class="ddisplay"> -</pre> <center> <a href="MakeConfig.shtml">Next >></a> </center> Modified: trunk/WWW/explore/Complement/MakeTags.shtml =================================================================== --- trunk/WWW/explore/Complement/MakeTags.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/MakeTags.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -5,6 +5,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="keywords" content="build, autotools, make, GNU, compilation, link"> <link rel="stylesheet" type="text/css" href="main.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="decor.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="float.css" media="screen" title="general"> @@ -12,7 +13,7 @@ </head> <body> -<!--#include file="head-tech.shtml" --> +<!--#include file="head-build.shtml" --> <div class="toppic"> <img src="img/jpg/apropos.jpg"> </div> @@ -77,6 +78,10 @@ <pre class="ddisplay"> </pre> + <center> + <a href="MakeConfig.shtml"><< Prev</a> <a href="MakeMacros.shtml">Next >></a> + </center> + </div> <!--#include file="foot.shtml" --> <!-- Created: Mon Oct 7 16:33:17 MSD 2002 --> Modified: trunk/WWW/explore/Complement/Technical.shtml =================================================================== --- trunk/WWW/explore/Complement/Technical.shtml 2007-02-12 12:17:50 UTC (rev 1525) +++ trunk/WWW/explore/Complement/Technical.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -5,6 +5,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="keywords" content="C++, build, autotools, threads, multithreads, event, stream, IO, library, socket, IPC, EDA"> <link rel="stylesheet" type="text/css" href="main.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="decor.css" media="screen" title="general"> <link rel="stylesheet" type="text/css" href="float.css" media="screen" title="general"> @@ -17,7 +18,20 @@ <img src="img/jpg/apropos.jpg"> </div> <div class="main"> - <h2 class="lheader">Technology</h2> + <!-- <h2 class="lheader">Technology</h2> --> + <h2 class="lheader">Build system</h2> + Build system, that used for this set of projects. + <h2 class="lheader">Multi-threading programming and IPC</h2> + Tools that introduce higher abstraction layer under native system capabilities + for multi-threading and IPC. + <h2 class="lheader">Communication with sockets</h2> + Abstraction layer that make utilisatoin of C++ iostream interfaces to work with + tcp sockets, as on server as on client side. + <h2 class="lheader">EDA tools</h2> + Abstraction layer that allow propagate EDA (events-driven architecture) design + directly into C++ programming. + <h2 class="lheader">STL implementations</h2> + Compare STL implementations and related programming techniques. </div> <!--#include file="foot.shtml" --> <!-- Created: Mon Oct 7 16:33:17 MSD 2002 --> Added: trunk/WWW/explore/Complement/head-boiler.shtml =================================================================== --- trunk/WWW/explore/Complement/head-boiler.shtml (rev 0) +++ trunk/WWW/explore/Complement/head-boiler.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -0,0 +1,9 @@ +<!-- Time-stamp: <03/05/04 16:12:38 ptr> --> + +<div class="logo1 margines20"><img src="img/jpg/Co-yw1.jpg"></div> +<div class="rightfloat"> + <div class="logo2 margines20"><!-- <img src="img/png/ermine.png"> --></div> + <div class="toc"> +<!--#include file="ContentBoiler.shtml" --> + </div> <!-- toc --> +</div> <!-- rightfloat --> Added: trunk/WWW/explore/Complement/head-build.shtml =================================================================== --- trunk/WWW/explore/Complement/head-build.shtml (rev 0) +++ trunk/WWW/explore/Complement/head-build.shtml 2007-02-12 15:35:17 UTC (rev 1526) @@ -0,0 +1,9 @@ +<!-- Time-stamp: <03/05/04 16:12:38 ptr> --> + +<div class="logo1 margines20"><img src="img/jpg/Co-yw1.jpg"></div> +<div class="rightfloat"> + <div class="logo2 margines20"><!-- <img src="img/png/ermine.png"> --></div> + <div class="toc"> +<!--#include file="ContentBuild.shtml" --> + </div> <!-- toc --> +</div> <!-- rightfloat --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-12 12:17:56
|
Revision: 1525 http://svn.sourceforge.net/complement/?rev=1525&view=rev Author: complement Date: 2007-02-12 04:17:50 -0800 (Mon, 12 Feb 2007) Log Message: ----------- use Init technique to initialize static idx [thread-specific data index]---avoid global mutex initialization [lead to problems after fork?]; reinitilize idx after fork; libsockios: Version 1.11.0 Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile.inc trunk/complement/explore/lib/sockios/_sockmgr.cc Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-02-12 11:22:03 UTC (rev 1524) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-02-12 12:17:50 UTC (rev 1525) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/01 16:10:07 ptr> +// -*- C++ -*- Time-stamp: <07/02/12 14:50:57 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -52,22 +52,23 @@ class basic_sockmgr : public sock_base { + private: + class Init + { + public: + Init(); + ~Init(); + private: + static void _guard( int ); + static void __at_fork_prepare(); + static void __at_fork_child(); + static void __at_fork_parent(); + }; + public: - basic_sockmgr() : - _errno( 0 ), - _mode( ios_base::in | ios_base::out ), - _state( ios_base::goodbit ), - _fd( -1 ) - { - xmt::Locker _l( _idx_lck ); - if ( _idx == -1 ) { - _idx = xmt::Thread::xalloc(); - } - } + basic_sockmgr(); + virtual ~basic_sockmgr(); - virtual ~basic_sockmgr() - { basic_sockmgr::close(); } - protected: __FIT_DECLSPEC void open( const in_addr& addr, int port, sock_base::stype type, sock_base::protocol prot ); __FIT_DECLSPEC void open( unsigned long addr, int port, sock_base::stype type, sock_base::protocol prot ); @@ -109,10 +110,8 @@ protected: static int _idx; + friend class Init; - private: - static xmt::Mutex _idx_lck; - protected: xmt::Mutex _fd_lck; xmt::Condition _loop_cnd; @@ -274,7 +273,7 @@ bool accept_udp(); private: - xmt::Thread loop_id; + xmt::Thread loop_id; protected: typedef sockmgr_stream_MP<Connect> _Self_type; Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-02-12 11:22:03 UTC (rev 1524) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-02-12 12:17:50 UTC (rev 1525) @@ -1,3 +1,12 @@ +2007-02-12 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h, _sockmgr.cc: use Init technique to initialize + static idx [thread-specific data index]---avoid global + mutex initialization [lead to problems after fork?]; + reinitilize idx after fork; + + * libsockios: Version 1.11.0 + 2007-02-01 Petr Ovtchenkov <pt...@is...> * sockmgr.cc: clean container with sockstreams, Modified: trunk/complement/explore/lib/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/Makefile.inc 2007-02-12 11:22:03 UTC (rev 1524) +++ trunk/complement/explore/lib/sockios/Makefile.inc 2007-02-12 12:17:50 UTC (rev 1525) @@ -2,8 +2,8 @@ LIBNAME = sockios MAJOR = 1 -MINOR = 10 -PATCH = 4 +MINOR = 11 +PATCH = 0 SRC_CC = _sockstream.cc _sockmgr.cc SRC_C = freebsd/getaddrinfo.c \ freebsd/ns_parse.c \ Modified: trunk/complement/explore/lib/sockios/_sockmgr.cc =================================================================== --- trunk/complement/explore/lib/sockios/_sockmgr.cc 2007-02-12 11:22:03 UTC (rev 1524) +++ trunk/complement/explore/lib/sockios/_sockmgr.cc 2007-02-12 12:17:50 UTC (rev 1525) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/06/28 10:35:10 ptr> +// -*- C++ -*- Time-stamp: <07/02/12 14:49:26 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -35,8 +35,58 @@ #endif int basic_sockmgr::_idx = -1; -xmt::Mutex basic_sockmgr::_idx_lck; +void basic_sockmgr::Init::__at_fork_prepare() +{ +} + +void basic_sockmgr::Init::__at_fork_child() +{ + basic_sockmgr::_idx = xmt::Thread::xalloc(); +} + +void basic_sockmgr::Init::__at_fork_parent() +{ +} + +void basic_sockmgr::Init::_guard( int direction ) +{ + static xmt::Mutex _init_lock; + static int _count = 0; + + if ( direction ) { + if ( _count++ == 0 ) { +#ifdef _PTHREADS + pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); +#endif + basic_sockmgr::_idx = xmt::Thread::xalloc(); + } + } +} + +basic_sockmgr::Init::Init() +{ _guard( 1 ); } + +basic_sockmgr::Init::~Init() +{ _guard( 0 ); } + +char Init_buf[128]; + +basic_sockmgr::basic_sockmgr() : + _errno( 0 ), + _mode( ios_base::in | ios_base::out ), + _state( ios_base::goodbit ), + _fd( -1 ) +{ + new( Init_buf ) Init(); +} + +basic_sockmgr::~basic_sockmgr() +{ + basic_sockmgr::close(); + ((Init *)Init_buf)->~Init(); +} + void basic_sockmgr::open( const in_addr& addr, int port, sock_base::stype type, sock_base::protocol prot ) { MT_REENTRANT( _fd_lck, _1 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-12 11:22:05
|
Revision: 1524 http://svn.sourceforge.net/complement/?rev=1524&view=rev Author: complement Date: 2007-02-12 03:22:03 -0800 (Mon, 12 Feb 2007) Log Message: ----------- fix typo Modified Paths: -------------- trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test_suite.cc Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-09 13:57:52 UTC (rev 1523) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-12 11:22:03 UTC (rev 1524) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/09 15:55:31 ptr> +// -*- C++ -*- Time-stamp: <07/02/12 11:01:56 ptr> /* * Copyright (c) 2006, 2007 @@ -771,7 +771,7 @@ void mt_test::shm_init() { - seg.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); + seg1.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); } /* ****************************************************** Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-09 13:57:52 UTC (rev 1523) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-12 11:22:03 UTC (rev 1524) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/09 16:00:57 ptr> +// -*- C++ -*- Time-stamp: <07/02/12 11:24:11 ptr> /* * Copyright (c) 2006, 2007 @@ -38,8 +38,8 @@ test_case *thr_mgr_tc = BOOST_CLASS_TEST_CASE( &mt_test::thr_mgr, instance ); - test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_init_mgr, instance ); - test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_finit_mgr, instance ); + test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_init, instance ); + test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_finit, instance ); barrier2_tc->depends_on( barrier_tc ); barrier2_tc->depends_on( join_tc ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-09 13:57:53
|
Revision: 1523 http://svn.sourceforge.net/complement/?rev=1523&view=rev Author: complement Date: 2007-02-09 05:57:52 -0800 (Fri, 09 Feb 2007) Log Message: ----------- add shm_init/finit, for future use Modified Paths: -------------- trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test.h trunk/complement/explore/test/mt/mt_test_suite.cc Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-09 10:34:41 UTC (rev 1522) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-09 13:57:52 UTC (rev 1523) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/07 08:29:41 ptr> +// -*- C++ -*- Time-stamp: <07/02/09 15:55:31 ptr> /* * Copyright (c) 2006, 2007 @@ -764,8 +764,25 @@ } } +/* ****************************************************** + */ +static const char fname1[] = "/tmp/mt_test.shm.1"; +xmt::shm_alloc<1> seg1; +void mt_test::shm_init() +{ + seg.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); +} + /* ****************************************************** + */ +void mt_test::shm_finit() +{ + seg1.deallocate(); + fs::remove( fname1 ); +} + +/* ****************************************************** * Thread pool (aka ThreadMgr) test. * * Start 200 threads under ThreadMgr; check that all threads Modified: trunk/complement/explore/test/mt/mt_test.h =================================================================== --- trunk/complement/explore/test/mt/mt_test.h 2007-02-09 10:34:41 UTC (rev 1522) +++ trunk/complement/explore/test/mt/mt_test.h 2007-02-09 13:57:52 UTC (rev 1523) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/06 09:48:27 ptr> +// -*- C++ -*- Time-stamp: <07/02/09 15:56:27 ptr> /* * Copyright (c) 2006, 2007 @@ -30,6 +30,9 @@ void shm_named_obj(); void thr_mgr(); + void shm_init(); + void shm_finit(); + private: // static xmt::Thread::ret_code thread_entry_call( void * ); // static int x; Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-09 10:34:41 UTC (rev 1522) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-09 13:57:52 UTC (rev 1523) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/06 10:06:37 ptr> +// -*- C++ -*- Time-stamp: <07/02/09 16:00:57 ptr> /* * Copyright (c) 2006, 2007 @@ -38,6 +38,9 @@ test_case *thr_mgr_tc = BOOST_CLASS_TEST_CASE( &mt_test::thr_mgr, instance ); + test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_init_mgr, instance ); + test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_finit_mgr, instance ); + barrier2_tc->depends_on( barrier_tc ); barrier2_tc->depends_on( join_tc ); yield_tc->depends_on( barrier2_tc ); @@ -52,6 +55,9 @@ fork_shm_tc->depends_on( shm_alloc_tc ); shm_nm_obj_tc->depends_on( fork_shm_tc ); + shm_init_tc->depends_on( shm_alloc_tc ); + shm_finit_tc->depends_on( shm_init_tc ); + add( barrier_tc, 0, 2 ); add( join_tc ); add( barrier2_tc, 0, 3 ); @@ -70,4 +76,7 @@ add( shm_nm_obj_tc, 0, 5 ); add( thr_mgr_tc ); + + add( shm_init_tc ); + add( shm_finit_tc ); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-09 10:34:43
|
Revision: 1522 http://svn.sourceforge.net/complement/?rev=1522&view=rev Author: complement Date: 2007-02-09 02:34:41 -0800 (Fri, 09 Feb 2007) Log Message: ----------- clean tests Modified Paths: -------------- trunk/complement/explore/test/sockios/Makefile.inc trunk/complement/explore/test/sockios/sockios_test.cc trunk/complement/explore/test/sockios/sockios_test.h trunk/complement/explore/test/sockios/sockios_test_suite.cc trunk/complement/explore/test/sockios/unit_test.cc Added Paths: ----------- trunk/complement/explore/test/sockios/names.cc Removed Paths: ------------- trunk/complement/explore/test/sockios/read0_on_exec.cc Modified: trunk/complement/explore/test/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/test/sockios/Makefile.inc 2007-02-09 10:31:07 UTC (rev 1521) +++ trunk/complement/explore/test/sockios/Makefile.inc 2007-02-09 10:34:41 UTC (rev 1522) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <06/12/18 16:43:21 ptr> +# -*- makefile -*- Time-stamp: <07/02/07 10:26:26 ptr> PRGNAME = sockios_ut SRC_CC = unit_test.cc ConnectionProcessor.cc message.cc client.cc client-mw.cc \ - client-wc.cc close_socket.cc bytes_in_socket.cc bytes_in_socket2.cc read0_on_exec.cc \ - sockios_test.cc sockios_test_suite.cc + client-wc.cc close_socket.cc bytes_in_socket.cc bytes_in_socket2.cc \ + names.cc sockios_test.cc sockios_test_suite.cc Added: trunk/complement/explore/test/sockios/names.cc =================================================================== --- trunk/complement/explore/test/sockios/names.cc (rev 0) +++ trunk/complement/explore/test/sockios/names.cc 2007-02-09 10:34:41 UTC (rev 1522) @@ -0,0 +1,140 @@ +// -*- C++ -*- Time-stamp: <07/02/07 10:28:34 ptr> + +/* + * + * Copyright (c) 2002, 2003, 2005-2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_test.h" + +#include <boost/test/unit_test.hpp> + +#include <sockios/sockstream> +#include <sockios/sockmgr.h> + +#include <list> + +#include <arpa/inet.h> + +using namespace boost::unit_test_framework; +using namespace std; + +/* ************************************************************ */ + +void names_sockios_test::hostname_test() +{ + unsigned long local = htonl( 0x7f000001 ); // 127.0.0.1 + +#ifdef _LITTLE_ENDIAN + BOOST_CHECK_EQUAL( local, 0x0100007f ); +#endif + +#ifdef _BIG_ENDIAN + BOOST_CHECK_EQUAL( local, 0x7f000001 ); +#endif + + BOOST_CHECK_EQUAL( std::hostname( local ), "localhost [127.0.0.1]" ); + +#ifdef __unix + char buff[1024]; + + gethostname( buff, 1024 ); + + BOOST_CHECK_EQUAL( std::hostname(), buff ); +#endif +} + +/* ************************************************************ */ + +void names_sockios_test::service_test() +{ +#ifdef __unix + BOOST_CHECK( std::service( "ftp", "tcp" ) == 21 ); + BOOST_CHECK( std::service( 7, "udp" ) == "echo" ); +#else + BOOST_ERROR( "requests for service (/etc/services) not implemented on this platform" ); +#endif +} + +/* ************************************************************ */ + +void names_sockios_test::hostaddr_test1() +{ +#ifdef __unix + in_addr addr = std::findhost( "localhost" ); + +# ifdef _LITTLE_ENDIAN + BOOST_CHECK_EQUAL( addr.s_addr, 0x0100007f ); +# endif + +# ifdef _BIG_ENDIAN + BOOST_CHECK_EQUAL( addr.s_addr, 0x7f000001 ); +# endif + +#else + BOOST_ERROR( "Not implemented" ); +#endif +} + +/* ************************************************************ */ + +void names_sockios_test::hostaddr_test2() +{ +#ifdef __unix + list<in_addr> haddrs; + std::gethostaddr( "localhost", back_inserter(haddrs) ); + + bool localhost_found = false; + + for ( list<in_addr>::const_iterator i = haddrs.begin(); i != haddrs.end(); ++i ) { + if ( i->s_addr == htonl( 0x7f000001 ) ) { // 127.0.0.1 + localhost_found = true; + break; + } + } + + BOOST_CHECK( localhost_found == true ); + +#else + BOOST_ERROR( "Not implemented" ); +#endif +} + +/* ************************************************************ */ + +void names_sockios_test::hostaddr_test3() +{ +#ifdef __unix + list<sockaddr> haddrs; + gethostaddr2( "localhost", back_inserter(haddrs) ); + + bool localhost_found = false; + + for ( list<sockaddr>::const_iterator i = haddrs.begin(); i != haddrs.end(); ++i ) { + switch ( i->sa_family ) { + case PF_INET: + if ( ((sockaddr_in *)&*i)->sin_addr.s_addr == htonl( 0x7f000001 ) ) { + localhost_found = true; + } + break; + case PF_INET6: + if ( ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[0] == 0 && + ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[1] == 0 && + ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[2] == 0 && + ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[3] == 1 ) { + localhost_found = true; + } + break; + } + } + + BOOST_CHECK( localhost_found == true ); + +#else + BOOST_ERROR( "Not implemented" ); +#endif +} Deleted: trunk/complement/explore/test/sockios/read0_on_exec.cc =================================================================== --- trunk/complement/explore/test/sockios/read0_on_exec.cc 2007-02-09 10:31:07 UTC (rev 1521) +++ trunk/complement/explore/test/sockios/read0_on_exec.cc 2007-02-09 10:34:41 UTC (rev 1522) @@ -1,259 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/01/29 19:17:54 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 3.0 - * - */ - -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <iostream> -#include <mt/xmt.h> - -#include <sockios/sockstream> -#include <sockios/sockmgr.h> - -#include <sys/types.h> -#include <sys/wait.h> - -#include <mt/shm.h> - -using namespace std; -using namespace xmt; - -/* - * The problem: - * 1. Server listen socket (process A) - * 2. Client connect to server (process B, server --- process A) - * 3. Client try to read from socket (from server) and block on it, - * due to server write nothing (thread i) [Hmm, really here - poll with POLLIN flag and then read] - * 4. In another thread (thread ii) client call system() - * 5. Due to fork/execl (in system()) client return from read (step 3) - * with 0, i.e. as on close connection - * - * The POSIX say: - * (execl) - * If the Asynchronous Input and Output option is supported, any - * outstanding asynchronous I/O operations may be canceled. Those - * asynchronous I/O operations that are not canceled will complete - * as if the exec function had not yet occurred, but any associated - * signal notifications are suppressed. It is unspecified whether - * the exec function itself blocks awaiting such I/O completion. In no event, - * however, will the new process image created by the exec function be affected - * by the presence of outstanding asynchronous I/O operations at the time - * the exec function is called. Whether any I/O is cancelled, and which I/O may - * be cancelled upon exec, is implementation-dependent. - * - * Client open socket --------- system() - * \ - * read...[poll signaled, read -> 0] - * - * The same issue on server side: poll that wait POLLIN from clients - * signaled too. - * - */ - -extern int port; -extern xmt::Mutex pr_lock; - -// static __Condition<true> cndf; - -class ConnectionProcessor5 // dummy variant -{ - public: - ConnectionProcessor5( std::sockstream& ); - - void connect( std::sockstream& ); - void close(); -}; - -ConnectionProcessor5::ConnectionProcessor5( std::sockstream& s ) -{ - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); - - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); - - // cerr << "ConnectionProcessor5::ConnectionProcessor5\n"; - delay( xmt::timespec(3,0) ); - - int n = 1; - // cerr << "ConnectionProcessor5::ConnectionProcessor5, write\n"; - s.write( (const char *)&n, sizeof( int ) ).flush(); -} - -void ConnectionProcessor5::connect( std::sockstream& s ) -{ -} - -void ConnectionProcessor5::close() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); -} - -Thread::ret_code thread_entry( void *par ) -{ - Thread::ret_code rt; - Condition& cnd = *reinterpret_cast<Condition *>(par); - - // sem.wait(); // wait server for listen us - sockstream sock( "localhost", ::port ); - int buff = 0; - // cerr << "thread_entry" << endl; - cnd.set( true ); - // Note: due to this is another process then main, boost can report - // about errors here, but don't count error it in summary, if it occur! - BOOST_CHECK( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line - BOOST_CHECK( buff == 1 ); - // cerr << "Read pass" << endl; - - rt.iword = 0; - return rt; -} - -void test_read0() -{ - const char fname[] = "/tmp/sockios_test.shm"; - try { - xmt::shm_alloc<0> seg; - - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); - // xmt::shm_name_mgr<0>& nm = seg.name_mgr(); - - xmt::allocator_shm<xmt::__Condition<true>,0> shm; - - xmt::__Condition<true>& fcnd = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); - // nm.named( fcnd, 1 ); - fcnd.set( false ); - - try { - xmt::fork(); // <---- key line - fcnd.try_wait(); // wait server for listen us - - Condition cnd; - cnd.set( false ); - - xmt::Thread thr( thread_entry, &cnd ); - - cnd.try_wait(); // wait for read call - - delay( xmt::timespec(1,0) ); - - // cerr << "system" << endl; - system( "echo > /dev/null" ); // <------ key line - // cerr << "after system" << endl; - - thr.join(); - // cerr << "exit child" << endl; - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - // cerr << "** 3" << endl; - sockmgr_stream_MP<ConnectionProcessor5> srv( ::port ); // start server - - fcnd.set( true ); - - int stat; - waitpid( child.pid(), &stat, 0 ); - srv.close(); - srv.wait(); - } - - (&fcnd)->~__Condition<true>(); - shm.deallocate( &fcnd, 1 ); - - seg.deallocate(); - unlink( fname ); - } - catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); - } -} - -class ConnectionProcessor6 // dummy variant -{ - public: - ConnectionProcessor6( std::sockstream& ); - - void connect( std::sockstream& ); - void close(); -}; - -static Condition cnd6; - -ConnectionProcessor6::ConnectionProcessor6( std::sockstream& s ) -{ - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); - - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); - - cnd6.set( true ); -} - -void ConnectionProcessor6::connect( std::sockstream& s ) -{ -} - -void ConnectionProcessor6::close() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); -} - -void test_read0_srv() -{ - try { - sockmgr_stream_MP<ConnectionProcessor6> srv( ::port ); - - BOOST_CHECK( srv.good() ); - cnd6.set( false ); - - { - // It should work as before system call... - sockstream s( "localhost", ::port ); - - s << "1" << endl; - - BOOST_CHECK( s.good() ); - - cnd6.try_wait(); - } - - cnd6.set( false ); - - system( "echo > /dev/null" ); // <------ key line - - BOOST_CHECK( srv.good() ); - - { - // ... as after system call. - sockstream s( "localhost", ::port ); - - s << "1" << endl; - - BOOST_CHECK( s.good() ); - - cnd6.try_wait(); - } - - BOOST_CHECK( srv.good() ); // server must correctly process interrupt during system call - - srv.close(); - srv.wait(); - } - catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); - } -} Modified: trunk/complement/explore/test/sockios/sockios_test.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.cc 2007-02-09 10:31:07 UTC (rev 1521) +++ trunk/complement/explore/test/sockios/sockios_test.cc 2007-02-09 10:34:41 UTC (rev 1522) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/31 23:47:57 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 11:32:06 ptr> /* * @@ -17,126 +17,44 @@ #include <sockios/sockstream> #include <sockios/sockmgr.h> -#include <list> - -#include <arpa/inet.h> - #include <mt/shm.h> - -// #include <sys/shm.h> #include <sys/wait.h> - #include <signal.h> using namespace boost::unit_test_framework; using namespace std; -void sockios_test::hostname_test() -{ - unsigned long local = htonl( 0x7f000001 ); // 127.0.0.1 +const char fname[] = "/tmp/sockios_test.shm"; +xmt::shm_alloc<0> seg; +xmt::allocator_shm<xmt::__Condition<true>,0> shm_cnd; +xmt::allocator_shm<xmt::__Barrier<true>,0> shm_b; -#ifdef _LITTLE_ENDIAN - BOOST_CHECK_EQUAL( local, 0x0100007f ); -#endif - -#ifdef _BIG_ENDIAN - BOOST_CHECK_EQUAL( local, 0x7f000001 ); -#endif - - BOOST_CHECK_EQUAL( std::hostname( local ), "localhost [127.0.0.1]" ); - -#ifdef __unix - char buff[1024]; - - gethostname( buff, 1024 ); - - BOOST_CHECK_EQUAL( std::hostname(), buff ); -#endif -} - -void sockios_test::service_test() +sockios_test::sockios_test() { -#ifdef __unix - BOOST_CHECK( std::service( "ftp", "tcp" ) == 21 ); - BOOST_CHECK( std::service( 7, "udp" ) == "echo" ); -#else - BOOST_ERROR( "requests for service (/etc/services) not implemented on this platform" ); -#endif } -void sockios_test::hostaddr_test1() +sockios_test::~sockios_test() { -#ifdef __unix - in_addr addr = std::findhost( "localhost" ); - -# ifdef _LITTLE_ENDIAN - BOOST_CHECK_EQUAL( addr.s_addr, 0x0100007f ); -# endif - -# ifdef _BIG_ENDIAN - BOOST_CHECK_EQUAL( addr.s_addr, 0x7f000001 ); -# endif - -#else - BOOST_ERROR( "Not implemented" ); -#endif } -void sockios_test::hostaddr_test2() +void sockios_test::init() { -#ifdef __unix - list<in_addr> haddrs; - std::gethostaddr( "localhost", back_inserter(haddrs) ); - - bool localhost_found = false; - - for ( list<in_addr>::const_iterator i = haddrs.begin(); i != haddrs.end(); ++i ) { - if ( i->s_addr == htonl( 0x7f000001 ) ) { // 127.0.0.1 - localhost_found = true; - break; - } + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); } - - BOOST_CHECK( localhost_found == true ); - -#else - BOOST_ERROR( "Not implemented" ); -#endif + catch ( const xmt::shm_bad_alloc& err ) { + BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + } } -void sockios_test::hostaddr_test3() +void sockios_test::finit() { -#ifdef __unix - list<sockaddr> haddrs; - gethostaddr2( "localhost", back_inserter(haddrs) ); + seg.deallocate(); + unlink( fname ); +} - bool localhost_found = false; +/* ************************************************************ */ - for ( list<sockaddr>::const_iterator i = haddrs.begin(); i != haddrs.end(); ++i ) { - switch ( i->sa_family ) { - case PF_INET: - if ( ((sockaddr_in *)&*i)->sin_addr.s_addr == htonl( 0x7f000001 ) ) { - localhost_found = true; - } - break; - case PF_INET6: - if ( ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[0] == 0 && - ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[1] == 0 && - ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[2] == 0 && - ((sockaddr_in6 *)&*i)->sin6_addr.in6_u.u6_addr32[3] == 1 ) { - localhost_found = true; - } - break; - } - } - - BOOST_CHECK( localhost_found == true ); - -#else - BOOST_ERROR( "Not implemented" ); -#endif -} - class Cnt { public: @@ -182,7 +100,7 @@ BOOST_CHECK( s1.good() ); BOOST_CHECK( s1.is_open() ); while ( Cnt::get_visits() == 0 ) { - xmt::delay( xmt::timespec(0,10000) ); + xmt::Thread::yield(); } Cnt::lock.lock(); BOOST_CHECK( Cnt::cnt == 1 ); @@ -222,7 +140,7 @@ BOOST_CHECK( s2.good() ); BOOST_CHECK( s2.is_open() ); while ( Cnt::get_visits() < 2 ) { - xmt::delay( xmt::timespec(0,10000) ); + xmt::Thread::yield(); } Cnt::lock.lock(); BOOST_CHECK( Cnt::cnt == 2 ); @@ -242,6 +160,8 @@ Cnt::lock.unlock(); } +/* ************************************************************ */ + class loader { public: @@ -268,7 +188,7 @@ { } -xmt::Thread::ret_code client_thr( void * ) +xmt::Thread::ret_code client_thr( void *p ) { xmt::Thread::ret_code ret; @@ -280,11 +200,15 @@ fill( buf, buf + 1024, 0 ); + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + while( true ) { s.write( buf, 1024 ); s.flush(); s.read( buf, 1024 ); + xmt::Thread::yield(); } return ret; @@ -292,34 +216,22 @@ void sigpipe_handler( int sig, siginfo_t *si, void * ) { +#if 0 cerr << "-----------------------------------------------\n" << "my pid: " << xmt::getpid() << ", ppid: " << xmt::getppid() << "\n" << "signal: " << sig << ", number " << si->si_signo << " errno " << si->si_errno << " code " << si->si_code << endl; +#endif } void sockios_test::sigpipe() { - const char fname[] = "/tmp/sockios_test.shm"; - enum { - in_Child_Condition = 1, - threads_Started_Condition = 2 - }; try { - xmt::shm_alloc<0> seg; - - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); - xmt::shm_name_mgr<0>& nm = seg.name_mgr(); - - xmt::allocator_shm<xmt::__Condition<true>,0> shm; - - xmt::__Condition<true>& fcnd = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); - nm.named( fcnd, in_Child_Condition ); + xmt::__Condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); fcnd.set( false ); - xmt::__Condition<true>& tcnd = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); - nm.named( tcnd, threads_Started_Condition ); + xmt::__Condition<true>& tcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); tcnd.set( false ); try { @@ -332,15 +244,15 @@ * This process will be killed, * so I don't care about safe termination. */ - xmt::Thread *th1 = new xmt::Thread( client_thr ); - for ( int i = 0; i < /* 10 */ 2; ++i ) { - new xmt::Thread( client_thr ); - new xmt::Thread( client_thr ); - new xmt::Thread( client_thr ); - new xmt::Thread( client_thr ); + const int b_count = 10; + xmt::Barrier b( b_count ); + xmt::Thread *th1 = new xmt::Thread( client_thr, &b ); + + for ( int i = 0; i < (b_count - 1); ++i ) { + new xmt::Thread( client_thr, &b ); } - xmt::delay( xmt::timespec(1,0) ); + xmt::delay( xmt::timespec(0,500000000) ); tcnd.set( true ); @@ -373,18 +285,17 @@ } (&tcnd)->~__Condition<true>(); - shm.deallocate( &tcnd, 1 ); + shm_cnd.deallocate( &tcnd, 1 ); (&fcnd)->~__Condition<true>(); - shm.deallocate( &fcnd, 1 ); - - seg.deallocate(); - unlink( fname ); + shm_cnd.deallocate( &fcnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); } } +/* ************************************************************ */ + class long_msg_processor // { public: @@ -420,21 +331,13 @@ xmt::__Condition<true> *long_msg_processor::cnd; -void sockios_test::long_msg_test() +void sockios_test::long_msg() { - const char fname[] = "/tmp/sockios_test.shm"; try { - xmt::shm_alloc<0> seg; - - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); - xmt::shm_name_mgr<0>& nm = seg.name_mgr(); - - xmt::allocator_shm<xmt::__Condition<true>,0> shm; - - xmt::__Condition<true>& fcnd = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); + xmt::__Condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); fcnd.set( false ); - xmt::__Condition<true>& srv_cnd = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); + xmt::__Condition<true>& srv_cnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); srv_cnd.set( false ); long_msg_processor::cnd = &srv_cnd; @@ -478,16 +381,244 @@ } (&fcnd)->~__Condition<true>(); - shm.deallocate( &fcnd, 1 ); + shm_cnd.deallocate( &fcnd, 1 ); (&srv_cnd)->~__Condition<true>(); - shm.deallocate( &srv_cnd, 1 ); + shm_cnd.deallocate( &srv_cnd, 1 ); + } + catch ( xmt::shm_bad_alloc& err ) { + BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + } +} - seg.deallocate(); - unlink( fname ); +/* ************************************************************ + * The problem: + * 1. Server listen socket (process A) + * 2. Client connect to server (process B, server --- process A) + * 3. Client try to read from socket (from server) and block on it, + * due to server write nothing (thread i) [Hmm, really here + * poll with POLLIN flag and then read] + * 4. In another thread (thread ii) client call system() + * 5. Due to fork/execl (in system()) client return from read (step 3) + * with 0, i.e. as on close connection + * + * The POSIX say: + * (execl) + * If the Asynchronous Input and Output option is supported, any + * outstanding asynchronous I/O operations may be canceled. Those + * asynchronous I/O operations that are not canceled will complete + * as if the exec function had not yet occurred, but any associated + * signal notifications are suppressed. It is unspecified whether + * the exec function itself blocks awaiting such I/O completion. In no event, + * however, will the new process image created by the exec function be affected + * by the presence of outstanding asynchronous I/O operations at the time + * the exec function is called. Whether any I/O is cancelled, and which I/O may + * be cancelled upon exec, is implementation-dependent. + * + * Client open socket --------- system() + * \ + * read...[poll signaled, read -> 0] + * + * The same issue on server side: poll that wait POLLIN from clients + * signaled too. + * + */ + +class ConnectionProcessor5 // dummy variant +{ + public: + ConnectionProcessor5( std::sockstream& ); + + void connect( std::sockstream& ); + void close(); + + static xmt::__Barrier<true> *b; +}; + + +xmt::__Barrier<true> *ConnectionProcessor5::b = 0; + +ConnectionProcessor5::ConnectionProcessor5( std::sockstream& s ) +{ + // pr_lock.lock(); + // BOOST_MESSAGE( "Server seen connection" ); + + BOOST_REQUIRE( s.good() ); + // pr_lock.unlock(); + + // cerr << "ConnectionProcessor5::ConnectionProcessor5\n"; + // delay( xmt::timespec(3,0) ); + + int n = 1; + // cerr << "ConnectionProcessor5::ConnectionProcessor5, write\n"; + b->wait(); + s.write( (const char *)&n, sizeof( int ) ).flush(); +} + +void ConnectionProcessor5::connect( std::sockstream& s ) +{ +} + +void ConnectionProcessor5::close() +{ + // pr_lock.lock(); + // BOOST_MESSAGE( "Server: client close connection" ); + // pr_lock.unlock(); +} + +xmt::Thread::ret_code thread_entry( void *par ) +{ + xmt::Thread::ret_code rt; + xmt::Condition& cnd = *reinterpret_cast<xmt::Condition *>(par); + + // sem.wait(); // wait server for listen us + sockstream sock( "localhost", ::port ); + int buff = 0; + // cerr << "thread_entry" << endl; + cnd.set( true ); + // Note: due to this is another process then main, boost can report + // about errors here, but don't count error it in summary, if it occur! + BOOST_CHECK( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line + BOOST_CHECK( buff == 1 ); + // cerr << "Read pass" << endl; + + rt.iword = 0; + return rt; +} + +void sockios_test::read0() +{ + try { + xmt::__Condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); + xmt::__Barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__Barrier<true>(); + ConnectionProcessor5::b = &b; + // nm.named( fcnd, 1 ); + fcnd.set( false ); + + try { + xmt::fork(); // <---- key line + fcnd.try_wait(); // wait server for listen us + + xmt::Condition cnd; + cnd.set( false ); + + xmt::Thread thr( thread_entry, &cnd ); + + cnd.try_wait(); // wait for read call + + // delay( xmt::timespec(1,0) ); + + // cerr << "system" << endl; + system( "echo > /dev/null" ); // <------ key line + // cerr << "after system" << endl; + + b.wait(); + + thr.join(); + // cerr << "exit child" << endl; + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + // cerr << "** 3" << endl; + sockmgr_stream_MP<ConnectionProcessor5> srv( ::port ); // start server + + fcnd.set( true ); + + int stat; + waitpid( child.pid(), &stat, 0 ); + srv.close(); + srv.wait(); + } + + (&b)->~__Barrier<true>(); + shm_b.deallocate( &b, 1 ); + (&fcnd)->~__Condition<true>(); + shm_cnd.deallocate( &fcnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); } +} +/* ************************************************************ */ + +class ConnectionProcessor6 // dummy variant +{ + public: + ConnectionProcessor6( std::sockstream& ); + + void connect( std::sockstream& ); + void close(); + + static xmt::Condition cnd; +}; + +xmt::Condition ConnectionProcessor6::cnd; + +ConnectionProcessor6::ConnectionProcessor6( std::sockstream& s ) +{ + // pr_lock.lock(); + // BOOST_MESSAGE( "Server seen connection" ); + + BOOST_REQUIRE( s.good() ); + // pr_lock.unlock(); + + cnd.set( true ); } + +void ConnectionProcessor6::connect( std::sockstream& s ) +{ +} + +void ConnectionProcessor6::close() +{ + // pr_lock.lock(); + // BOOST_MESSAGE( "Server: client close connection" ); + // pr_lock.unlock(); +} + +void sockios_test::read0_srv() +{ + try { + sockmgr_stream_MP<ConnectionProcessor6> srv( ::port ); + + BOOST_CHECK( srv.good() ); + ConnectionProcessor6::cnd.set( false ); + + { + // It should work as before system call... + sockstream s( "localhost", ::port ); + + s << "1" << endl; + + BOOST_CHECK( s.good() ); + + ConnectionProcessor6::cnd.try_wait(); + } + + ConnectionProcessor6::cnd.set( false ); + + system( "echo > /dev/null" ); // <------ key line + + BOOST_CHECK( srv.good() ); + + { + // ... as after system call. + sockstream s( "localhost", ::port ); + + s << "1" << endl; + + BOOST_CHECK( s.good() ); + + ConnectionProcessor6::cnd.try_wait(); + } + + BOOST_CHECK( srv.good() ); // server must correctly process interrupt during system call + + srv.close(); + srv.wait(); + } + catch ( xmt::shm_bad_alloc& err ) { + BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + } +} Modified: trunk/complement/explore/test/sockios/sockios_test.h =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.h 2007-02-09 10:31:07 UTC (rev 1521) +++ trunk/complement/explore/test/sockios/sockios_test.h 2007-02-09 10:34:41 UTC (rev 1522) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/30 10:55:51 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 10:51:25 ptr> /* * @@ -12,7 +12,7 @@ #ifndef __sockios_test_h #define __sockios_test_h -struct sockios_test +struct names_sockios_test { void hostname_test(); void service_test(); @@ -20,11 +20,23 @@ void hostaddr_test1(); void hostaddr_test2(); void hostaddr_test3(); +}; +struct sockios_test +{ + sockios_test(); + ~sockios_test(); + + void init(); + void finit(); + void ctor_dtor(); + void long_msg(); + void sigpipe(); - void long_msg_test(); + void read0(); + void read0_srv(); }; #endif // __sockios_test_h Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-02-09 10:31:07 UTC (rev 1521) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-02-09 10:34:41 UTC (rev 1522) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/30 10:57:38 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 11:00:07 ptr> /* * @@ -20,18 +20,14 @@ sockios_test_suite::sockios_test_suite() : test_suite( "sockios library test suite" ) { - boost::shared_ptr<sockios_test> instance( new sockios_test() ); - test_case *hostname_tc = BOOST_CLASS_TEST_CASE( &sockios_test::hostname_test, instance ); - test_case *service_tc = BOOST_CLASS_TEST_CASE( &sockios_test::service_test, instance ); + boost::shared_ptr<names_sockios_test> names_instance( new names_sockios_test() ); - test_case *hostaddr1_tc = BOOST_CLASS_TEST_CASE( &sockios_test::hostaddr_test1, instance ); - test_case *hostaddr2_tc = BOOST_CLASS_TEST_CASE( &sockios_test::hostaddr_test2, instance ); - test_case *hostaddr3_tc = BOOST_CLASS_TEST_CASE( &sockios_test::hostaddr_test3, instance ); - test_case *ctor_dtor_tc = BOOST_CLASS_TEST_CASE( &sockios_test::ctor_dtor, instance ); - test_case *sigpipe_tc = BOOST_CLASS_TEST_CASE( &sockios_test::sigpipe, instance ); - test_case *long_msg_tc = BOOST_CLASS_TEST_CASE( &sockios_test::long_msg_test, instance ); + test_case *hostname_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostname_test, names_instance ); + test_case *service_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::service_test, names_instance ); - // hostaddr2_tc->depends_on( hostaddr1_tc ); + test_case *hostaddr1_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test1, names_instance ); + test_case *hostaddr2_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test2, names_instance ); + test_case *hostaddr3_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test3, names_instance ); add( hostname_tc ); add( service_tc ); @@ -39,7 +35,32 @@ add( hostaddr1_tc ); add( hostaddr2_tc ); add( hostaddr3_tc ); + + + boost::shared_ptr<sockios_test> instance( new sockios_test() ); + test_case *init_tc = BOOST_CLASS_TEST_CASE( &sockios_test::init, instance ); + test_case *finit_tc = BOOST_CLASS_TEST_CASE( &sockios_test::finit, instance ); + + test_case *ctor_dtor_tc = BOOST_CLASS_TEST_CASE( &sockios_test::ctor_dtor, instance ); + test_case *long_msg_tc = BOOST_CLASS_TEST_CASE( &sockios_test::long_msg, instance ); + test_case *sigpipe_tc = BOOST_CLASS_TEST_CASE( &sockios_test::sigpipe, instance ); + + test_case *read0_tc = BOOST_CLASS_TEST_CASE( &sockios_test::read0, instance ); + test_case *read0_srv_tc = BOOST_CLASS_TEST_CASE( &sockios_test::read0_srv, instance ); + + long_msg_tc->depends_on( init_tc ); + long_msg_tc->depends_on( ctor_dtor_tc ); + sigpipe_tc->depends_on( ctor_dtor_tc ); + sigpipe_tc->depends_on( init_tc ); + read0_tc->depends_on( sigpipe_tc ); + read0_srv_tc->depends_on( sigpipe_tc ); + finit_tc->depends_on( init_tc ); + + add( init_tc ); add( ctor_dtor_tc ); + add( long_msg_tc ); add( sigpipe_tc ); - add( long_msg_tc ); + add( read0_tc, 0, 5 ); + add( read0_srv_tc ); + add( finit_tc ); } Modified: trunk/complement/explore/test/sockios/unit_test.cc =================================================================== --- trunk/complement/explore/test/sockios/unit_test.cc 2007-02-09 10:31:07 UTC (rev 1521) +++ trunk/complement/explore/test/sockios/unit_test.cc 2007-02-09 10:34:41 UTC (rev 1522) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/01/29 19:19:10 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 10:09:14 ptr> /* * - * Copyright (c) 2002, 2003, 2005, 2006 + * Copyright (c) 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -344,23 +344,13 @@ void test_client_close_socket(); void test_more_bytes_in_socket(); void test_more_bytes_in_socket2(); -void test_read0(); -void test_read0_srv(); - test_suite *init_unit_test_suite( int argc, char **argv ) { test_suite *ts = BOOST_TEST_SUITE( "libsockios test" ); ts->add( new sockios_test_suite() ); - // ts->add( BOOST_TEST_CASE( &hostname_test ) ); - // ts->add( BOOST_TEST_CASE( &service_test ) ); - - // ts->add( BOOST_TEST_CASE( &hostaddr_test1 ) ); - // ts->add( BOOST_TEST_CASE( &hostaddr_test2 ) ); - // ts->add( BOOST_TEST_CASE( &hostaddr_test3 ) ); - ts->add( BOOST_TEST_CASE( &test_client_server_poll ) ); // ts->add( BOOST_TEST_CASE( &test_client_server_select ) ); @@ -385,8 +375,6 @@ ts->add( BOOST_TEST_CASE( &test_client_close_socket ) ); ts->add( BOOST_TEST_CASE( &test_more_bytes_in_socket ), 0, 5 ); ts->add( BOOST_TEST_CASE( &test_more_bytes_in_socket2 ), 0, 5 ); - ts->add( BOOST_TEST_CASE( &test_read0 ), 0, 7 ); - ts->add( BOOST_TEST_CASE( &test_read0_srv ) ); return ts; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-09 10:31:13
|
Revision: 1521 http://svn.sourceforge.net/complement/?rev=1521&view=rev Author: complement Date: 2007-02-09 02:31:07 -0800 (Fri, 09 Feb 2007) Log Message: ----------- use deque instead of queue for events in main dispetcher; this allow to use container's swap, not exchange via temporary objects [via copy]; destroy and create EvManager in child process after fork, if there are was EvManager; libstem version 4.4.0 use same name for all variants of dlopen'd within test Modified Paths: -------------- trunk/complement/explore/include/stem/EvManager.h trunk/complement/explore/include/stem/EventHandler.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/Makefile.inc trunk/complement/explore/lib/stem/_EventHandler.cc trunk/complement/explore/test/stem/Makefile trunk/complement/explore/test/stem/dl/Makefile trunk/complement/explore/test/stem/dl/loadable_stem.cc trunk/complement/explore/test/stem/unit_test.cc Modified: trunk/complement/explore/include/stem/EvManager.h =================================================================== --- trunk/complement/explore/include/stem/EvManager.h 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/include/stem/EvManager.h 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/04 17:32:31 ptr> +// -*- C++ -*- Time-stamp: <07/02/08 16:38:05 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -22,7 +22,7 @@ #include <string> #include <map> -#include <queue> +#include <deque> #include <mt/xmt.h> #include <mt/uid.h> @@ -96,7 +96,7 @@ tracefault = 4 }; - typedef std::queue< Event > queue_type; + typedef std::deque< Event > queue_type; __FIT_DECLSPEC EvManager(); __FIT_DECLSPEC ~EvManager(); @@ -156,7 +156,7 @@ void push( const Event& e ) { MT_REENTRANT( _lock_queue, _x1 ); - in_ev_queue.push( e ); + in_ev_queue.push_back( e ); _cnd_queue.set( true ); } Modified: trunk/complement/explore/include/stem/EventHandler.h =================================================================== --- trunk/complement/explore/include/stem/EventHandler.h 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/include/stem/EventHandler.h 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/30 20:50:13 ptr> +// -*- C++ -*- Time-stamp: <07/02/08 17:24:21 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -553,6 +553,9 @@ ~Init(); private: static void _guard( int ); + static void __at_fork_prepare(); + static void __at_fork_child(); + static void __at_fork_parent(); }; __FIT_DECLSPEC EventHandler(); Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,3 +1,15 @@ +2007-02-08 Petr Ovtchenkov <pt...@is...> + + * EvManager.h, EvManager.cc: use deque instead of queue; + this allow to use container's swap, not exchange via temporary + objects [via copy]; + + * EventHandler.h, _EventHandler.cc: destroy and create + EvManager in child process after fork, if there are was + EvManager; + + * libstem: library version 4.4.0 + 2006-12-13 Petr Ovtchenkov <pt...@is...> * NetTransport.h, NetTransport.cc: NetTransportMgr Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/04 19:08:21 ptr> +// -*- C++ -*- Time-stamp: <07/02/08 16:38:41 ptr> /* * @@ -85,11 +85,11 @@ while ( me.not_finished() ) { MT_LOCK( me._lock_queue ); - swap( me.in_ev_queue, me.out_ev_queue ); + me.in_ev_queue.swap( me.out_ev_queue ); MT_UNLOCK( me._lock_queue ); while ( !me.out_ev_queue.empty() ) { me.Send( me.out_ev_queue.front() ); - me.out_ev_queue.pop(); + me.out_ev_queue.pop_front(); } MT_LOCK( me._lock_queue ); if ( me.in_ev_queue.empty() && me.not_finished() ) { Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-02-09 10:31:07 UTC (rev 1521) @@ -2,7 +2,7 @@ LIBNAME = stem MAJOR = 4 -MINOR = 3 +MINOR = 4 PATCH = 0 SRC_CC = _EventHandler.cc NetTransport.cc EvManager.cc EvPack.cc crc.cc \ Names.cc Cron.cc Modified: trunk/complement/explore/lib/stem/_EventHandler.cc =================================================================== --- trunk/complement/explore/lib/stem/_EventHandler.cc 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/lib/stem/_EventHandler.cc 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/28 20:32:35 ptr> +// -*- C++ -*- Time-stamp: <07/02/08 17:27:44 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -29,20 +29,21 @@ EvManager *EventHandler::_mgr = 0; Names *EventHandler::_ns = 0; -#if 0 // depends where fork happens: in the EvManager loop (stack) or not. -extern "C" void __at_fork_prepare() +static int *_rcount = 0; +#if 1 // depends where fork happens: in the EvManager loop (stack) or not. +void EventHandler::Init::__at_fork_prepare() { } -extern "C" void __at_fork_child() +void EventHandler::Init::__at_fork_child() { - if ( EventHandler::Init::_count != 0 ) { - // delete EventHandler::_mgr; + if ( *_rcount != 0 ) { + delete EventHandler::_mgr; EventHandler::_mgr = new( EventHandler::_mgr ) EvManager(); } } -extern "C" void __at_fork_parent() +void EventHandler::Init::__at_fork_parent() { } #endif @@ -54,6 +55,10 @@ if ( direction ) { if ( _count++ == 0 ) { +#ifdef _PTHREADS + _rcount = &_count; + pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); +#endif EventHandler::_mgr = new EvManager(); EventHandler::_ns = new Names( ns_addr, "ns" ); } @@ -61,8 +66,10 @@ --_count; if ( _count == 1 ) { delete EventHandler::_ns; + EventHandler::_ns = 0; } else if ( _count == 0 ) { delete EventHandler::_mgr; + EventHandler::_mgr = 0; } } } Modified: trunk/complement/explore/test/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/test/stem/Makefile 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <06/12/13 01:07:22 ptr> +# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -18,16 +18,16 @@ LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf -ldl stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_test_utfstlg -ldl dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lboost_test_utfg -ldl -dbg-shared: DEFS += -DDEBUG +# dbg-shared: DEFS += -DDEBUG PHONY += dl dl-dbg dl-stldbg @@ -39,3 +39,6 @@ dl-stldbg: ${MAKE} -C dl stldbg-shared + +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C dl $@ Modified: trunk/complement/explore/test/stem/dl/Makefile =================================================================== --- trunk/complement/explore/test/stem/dl/Makefile 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/test/stem/dl/Makefile 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,18 +1,28 @@ -# -*- Makefile -*- Time-stamp: <06/08/04 12:09:33 ptr> +# -*- Makefile -*- Time-stamp: <07/02/07 12:13:04 ptr> SRCROOT := ../../.. COMPILER_NAME := gcc +DBG_SUFFIX := +STLDBG_SUFFIX := +INSTALL_TAGS := + include Makefile.inc include ${SRCROOT}/Makefiles/top.mak +LIBSTEM_DIR = ${CoMT_DIR}/lib/stem - INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) #LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR} +stldbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} +dbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} #release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf +release-shared: LDLIBS = -lstem #stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_test_utfstlg +stldbg-shared: LDLIBS = -lstemstlg #dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lboost_test_utfg +dbg-shared: LDLIBS = -lstemg #LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR}:${CoMT_LIB_DIR} Modified: trunk/complement/explore/test/stem/dl/loadable_stem.cc =================================================================== --- trunk/complement/explore/test/stem/dl/loadable_stem.cc 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/test/stem/dl/loadable_stem.cc 2007-02-09 10:31:07 UTC (rev 1521) @@ -9,9 +9,9 @@ * */ -#include <boost/test/unit_test.hpp> +// #include <boost/test/unit_test.hpp> -using namespace boost::unit_test_framework; +// using namespace boost::unit_test_framework; #include "../NodeDL.h" Modified: trunk/complement/explore/test/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-02-09 10:27:13 UTC (rev 1520) +++ trunk/complement/explore/test/stem/unit_test.cc 2007-02-09 10:31:07 UTC (rev 1521) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/13 02:08:08 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 13:05:32 ptr> /* * Copyright (c) 2002, 2003, 2006 @@ -14,6 +14,7 @@ #include <iostream> #include <mt/xmt.h> +#include <mt/shm.h> #include <stem/EventHandler.h> #include <stem/Names.h> @@ -35,7 +36,6 @@ using namespace __gnu_cxx; #endif -#include <sys/shm.h> #include <sys/wait.h> #include <signal.h> @@ -44,6 +44,9 @@ struct stem_test { + void shm_init(); + void shm_finit(); + void basic1(); void basic2(); void basic1new(); @@ -148,21 +151,21 @@ void stem_test::dl() { -#ifdef _STLP_DEBUG - void *lh = dlopen( "dl/obj/gcc/so_stlg/libloadable_stemstlg.so", RTLD_LAZY ); -#elif defined(DEBUG) - void *lh = dlopen( "dl/obj/gcc/so_g/libloadable_stemg.so", RTLD_LAZY ); -#else - void *lh = dlopen( "dl/obj/gcc/so/libloadable_stem.so", RTLD_LAZY ); -#endif + void *lh = dlopen( "libloadable_stem.so", RTLD_LAZY ); // Path was passed via -Wl,--rpath= + BOOST_REQUIRE( lh != NULL ); - void *(*f)(unsigned) = reinterpret_cast<void *(*)(unsigned)>( dlsym( lh, "create_NewNodeDL" ) ); + void *(*f)(unsigned); + void (*g)(void *); + void (*w)(void *); + int (*v)(void *); + + *(void **)(&f) = dlsym( lh, "create_NewNodeDL" ); BOOST_REQUIRE( f != NULL ); - void (*g)(void *) = reinterpret_cast<void (*)(void *)>( dlsym( lh, "destroy_NewNodeDL" ) ); + *(void **)(&g) = dlsym( lh, "destroy_NewNodeDL" ); BOOST_REQUIRE( g != NULL ); - void (*w)(void *) = reinterpret_cast<void (*)(void *)>( dlsym( lh, "wait_NewNodeDL" ) ); + *(void **)(&w) = dlsym( lh, "wait_NewNodeDL" ); BOOST_REQUIRE( w != NULL ); - int (*v)(void *) = reinterpret_cast<int (*)(void *)>( dlsym( lh, "v_NewNodeDL" ) ); + *(void **)(&v) = dlsym( lh, "v_NewNodeDL" ); BOOST_REQUIRE( v != NULL ); NewNodeDL *node = reinterpret_cast<NewNodeDL *>( f( 2002 ) ); @@ -289,25 +292,29 @@ } } -void stem_test::echo_net() +const char fname[] = "/tmp/stem_test.shm"; +xmt::shm_alloc<0> seg; +xmt::allocator_shm<xmt::__Condition<true>,0> shm_cnd; + +void stem_test::shm_init() { - shmid_ds ds; - int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); - BOOST_REQUIRE( id != -1 ); - // if ( id == -1 ) { - // cerr << "Error on shmget" << endl; - // } - BOOST_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); - // if ( shmctl( id, IPC_STAT, &ds ) == -1 ) { - // cerr << "Error on shmctl" << endl; - // } - void *buf = shmat( id, 0, 0 ); - BOOST_REQUIRE( buf != reinterpret_cast<void *>(-1) ); - // if ( buf == reinterpret_cast<void *>(-1) ) { - // cerr << "Error on shmat" << endl; - // } + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + } + catch ( const xmt::shm_bad_alloc& err ) { + BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + } +} - xmt::__Condition<true>& fcnd = *new( buf ) xmt::__Condition<true>(); +void stem_test::shm_finit() +{ + seg.deallocate(); + unlink( fname ); +} + +void stem_test::echo_net() +{ + xmt::__Condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); fcnd.set( false ); try { @@ -361,10 +368,8 @@ } (&fcnd)->~__Condition<true>(); + shm_cnd.deallocate( &fcnd, 1 ); - shmdt( buf ); - shmctl( id, IPC_RMID, &ds ); - // cerr << "Fine\n"; } @@ -396,29 +401,13 @@ pid_t fpid; - shmid_ds ds; - int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); - BOOST_REQUIRE( id != -1 ); - // if ( id == -1 ) { - // cerr << "Error on shmget" << endl; - // } - BOOST_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); - // if ( shmctl( id, IPC_STAT, &ds ) == -1 ) { - // cerr << "Error on shmctl" << endl; - // } - void *buf = shmat( id, 0, 0 ); - BOOST_REQUIRE( buf != reinterpret_cast<void *>(-1) ); - // if ( buf == reinterpret_cast<void *>(-1) ) { - // cerr << "Error on shmat" << endl; - // } - - xmt::__Condition<true>& fcnd = *new( buf ) xmt::__Condition<true>(); + xmt::__Condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); fcnd.set( false ); - xmt::__Condition<true>& pcnd = *new( (char *)buf + sizeof(xmt::__Condition<true>) ) xmt::__Condition<true>(); + xmt::__Condition<true>& pcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); pcnd.set( false ); - xmt::__Condition<true>& scnd = *new( (char *)buf + sizeof(xmt::__Condition<true>) * 2 ) xmt::__Condition<true>(); + xmt::__Condition<true>& scnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); scnd.set( false ); try { @@ -563,7 +552,7 @@ pcnd.set( true ); c2.wait(); - cerr << "Fine!" << endl; + // cerr << "Fine!" << endl; scnd.set( true ); mgr.close(); @@ -589,32 +578,16 @@ } (&fcnd)->~__Condition<true>(); + shm_cnd.deallocate( &fcnd, 1 ); (&pcnd)->~__Condition<true>(); + shm_cnd.deallocate( &pcnd, 1 ); (&scnd)->~__Condition<true>(); - - shmdt( buf ); - shmctl( id, IPC_RMID, &ds ); + shm_cnd.deallocate( &scnd, 1 ); } void stem_test::boring_manager() { - shmid_ds ds; - int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); - BOOST_REQUIRE( id != -1 ); - // if ( id == -1 ) { - // cerr << "Error on shmget" << endl; - // } - BOOST_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); - // if ( shmctl( id, IPC_STAT, &ds ) == -1 ) { - // cerr << "Error on shmctl" << endl; - // } - void *buf = shmat( id, 0, 0 ); - BOOST_REQUIRE( buf != reinterpret_cast<void *>(-1) ); - // if ( buf == reinterpret_cast<void *>(-1) ) { - // cerr << "Error on shmat" << endl; - // } - - xmt::__Condition<true>& fcnd = *new( buf ) xmt::__Condition<true>(); + xmt::__Condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__Condition<true>(); fcnd.set( false ); try { @@ -659,9 +632,7 @@ } (&fcnd)->~__Condition<true>(); - - shmdt( buf ); - shmctl( id, IPC_RMID, &ds ); + shm_cnd.deallocate( &fcnd, 1 ); } struct stem_test_suite : @@ -683,9 +654,12 @@ test_case *dl_tc = BOOST_CLASS_TEST_CASE( &stem_test::dl, instance ); test_case *ns_tc = BOOST_CLASS_TEST_CASE( &stem_test::ns, instance ); test_case *echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo, instance ); + test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &stem_test::shm_init, instance ); test_case *echo_net_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo_net, instance ); test_case *peer_tc = BOOST_CLASS_TEST_CASE( &stem_test::peer, instance ); test_case *boring_manager_tc = BOOST_CLASS_TEST_CASE( &stem_test::boring_manager, instance ); + test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &stem_test::shm_finit, instance ); + basic2_tc->depends_on( basic1_tc ); basic1n_tc->depends_on( basic1_tc ); basic2n_tc->depends_on( basic2_tc ); @@ -694,9 +668,13 @@ ns_tc->depends_on( basic1_tc ); echo_tc->depends_on( basic2_tc ); + echo_net_tc->depends_on( shm_init_tc ); echo_net_tc->depends_on( echo_tc ); peer_tc->depends_on( echo_tc ); + peer_tc->depends_on( shm_init_tc ); boring_manager_tc->depends_on( peer_tc ); + boring_manager_tc->depends_on( shm_init_tc ); + shm_finit_tc->depends_on( shm_init_tc ); add( basic1_tc ); add( basic2_tc ); @@ -706,9 +684,11 @@ add( ns_tc ); add( echo_tc ); + add( shm_init_tc ); add( echo_net_tc ); add( peer_tc ); add( boring_manager_tc ); + add( shm_finit_tc ); } test_suite *init_unit_test_suite( int argc, char **argv ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-09 10:27:15
|
Revision: 1520 http://svn.sourceforge.net/complement/?rev=1520&view=rev Author: complement Date: 2007-02-09 02:27:13 -0800 (Fri, 09 Feb 2007) Log Message: ----------- process-shared barrier may be allocated in shared memory segment; libxmt version 1.10.2 Modified Paths: -------------- trunk/complement/explore/include/mt/shm.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/test/mt/mt_test.cc Modified: trunk/complement/explore/include/mt/shm.h =================================================================== --- trunk/complement/explore/include/mt/shm.h 2007-02-09 10:24:23 UTC (rev 1519) +++ trunk/complement/explore/include/mt/shm.h 2007-02-09 10:27:13 UTC (rev 1520) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/29 18:59:35 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 10:11:34 ptr> /* * Copyright (c) 2006, 2007 @@ -82,6 +82,12 @@ }; template <> +struct ipc_sharable<xmt::__Barrier<true> > +{ + typedef std::__true_type is_ipc_sharable; +}; + +template <> struct ipc_sharable<xmt::__Mutex<false,true> > { typedef std::__true_type is_ipc_sharable; Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-02-09 10:24:23 UTC (rev 1519) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-02-09 10:27:13 UTC (rev 1520) @@ -1,3 +1,10 @@ +2007-02-08 Petr Ovtchenkov <pt...@is...> + + * shm.h: process-shared barrier may be allocated in shared + memory segment; + + * libxmt: version 1.10.2 + 2007-02-06 Petr Ovtchenkov <pt...@is...> * xmt.h: add Barrier; add yield; Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-02-09 10:24:23 UTC (rev 1519) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-02-09 10:27:13 UTC (rev 1520) @@ -3,6 +3,6 @@ LIBNAME = xmt MAJOR = 1 MINOR = 10 -PATCH = 1 +PATCH = 2 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc SRC_C = fl.c Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-09 10:24:23 UTC (rev 1519) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-09 10:27:13 UTC (rev 1520) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/06 10:36:47 ptr> +// -*- C++ -*- Time-stamp: <07/02/07 08:29:41 ptr> /* * Copyright (c) 2006, 2007 @@ -32,7 +32,7 @@ namespace fs = boost::filesystem; /* ****************************************************** - * Degenerative case: check that one thread pass throw + * Degenerate case: check that one thread pass throw * own barrier. */ void mt_test::barrier() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-09 10:24:29
|
Revision: 1519 http://svn.sourceforge.net/complement/?rev=1519&view=rev Author: complement Date: 2007-02-09 02:24:23 -0800 (Fri, 09 Feb 2007) Log Message: ----------- workaround for gmake 3.80 (case, when libname and installation path same as for release, as for dbg) Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/unix/lib.mak Modified: trunk/complement/explore/Makefiles/gmake/unix/lib.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/unix/lib.mak 2007-02-09 10:22:47 UTC (rev 1518) +++ trunk/complement/explore/Makefiles/gmake/unix/lib.mak 2007-02-09 10:24:23 UTC (rev 1519) @@ -9,8 +9,8 @@ # Licensed under the Academic Free License version 3.0 # -DBG_SUFFIX := g -STLDBG_SUFFIX := stl${DBG_SUFFIX} +DBG_SUFFIX ?= g +STLDBG_SUFFIX ?= stl${DBG_SUFFIX} # Shared libraries: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-09 10:22:48
|
Revision: 1518 http://svn.sourceforge.net/complement/?rev=1518&view=rev Author: complement Date: 2007-02-09 02:22:47 -0800 (Fri, 09 Feb 2007) Log Message: ----------- workaround for gmake 3.80 (case, when libname and installation path same as for release, as for dbg) Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/linux/rules-install-so.mak Modified: trunk/complement/explore/Makefiles/gmake/linux/rules-install-so.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/linux/rules-install-so.mak 2007-02-06 15:01:03 UTC (rev 1517) +++ trunk/complement/explore/Makefiles/gmake/linux/rules-install-so.mak 2007-02-09 10:22:47 UTC (rev 1518) @@ -1,4 +1,4 @@ -# -*- makefile -*- Time-stamp: <06/11/11 00:23:29 ptr> +# -*- makefile -*- Time-stamp: <07/02/07 14:58:53 ptr> # # Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 # Petr Ovtchenkov @@ -85,7 +85,7 @@ install-strip: $(INSTALL_STRIP_TAGS) -# Workaround forGNU make 3.80; see comments in rules-so.mak +# Workaround for GNU make 3.80; see comments in rules-so.mak define do_install_so_links $${INSTALL_LIB_DIR$(1)}/$${SO_NAME$(1)xxx}: $${SO_NAME_OUT$(1)xxx} $$(INSTALL_SO) $${SO_NAME_OUT$(1)xxx} $$(INSTALL_LIB_DIR$(1)) @@ -94,18 +94,36 @@ @$(call do_so_links_1,$$(INSTALL_LIB_DIR$(1)),$${SO_NAME$(1)},$${SO_NAME$(1)x}) endef +# Workaround for GNU make 3.80; see comments in rules-so.mak define do_install_so_links_wk +# expand to nothing, if equal +ifneq (${INSTALL_LIB_DIR}/${SO_NAMExxx},${INSTALL_LIB_DIR_STLDBG}/${SO_NAME_STLDBGxxx}) # expand to nothing, if WITHOUT_STLPORT ifndef WITHOUT_STLPORT $(call do_install_so_links,$(1)) endif +endif endef +# Workaround for GNU make 3.80; see comments in rules-so.mak +define do_install_so_links_wk2 +# expand to nothing, if equal +ifneq (${INSTALL_LIB_DIR}/${SO_NAMExxx},${INSTALL_LIB_DIR_DBG}/${SO_NAME_DBGxxx}) +$(call do_install_so_links,$(1)) +endif +endef + + $(eval $(call do_install_so_links,)) -$(eval $(call do_install_so_links,_DBG)) +# ifneq (${INSTALL_LIB_DIR}/${SO_NAMExxx},${INSTALL_LIB_DIR_DBG}/${SO_NAME_DBGxxx}) +# $(eval $(call do_install_so_links,_DBG)) +$(eval $(call do_install_so_links_wk2,_DBG)) +# endif +# ifneq (${INSTALL_LIB_DIR}/${SO_NAMExxx},${INSTALL_LIB_DIR_STLDBG}/${SO_NAME_STLDBGxxx}) # ifndef WITHOUT_STLPORT $(eval $(call do_install_so_links_wk,_STLDBG)) # endif +# endif install-release-shared: release-shared $(INSTALL_LIB_DIR) $(INSTALL_LIB_DIR)/${SO_NAMExxx} ${POST_INSTALL} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 15:01:08
|
Revision: 1517 http://svn.sourceforge.net/complement/?rev=1517&view=rev Author: complement Date: 2007-02-06 07:01:03 -0800 (Tue, 06 Feb 2007) Log Message: ----------- expand 'for' within make Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/subdirs.mak Modified: trunk/complement/explore/Makefiles/gmake/subdirs.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/subdirs.mak 2007-02-06 14:36:17 UTC (rev 1516) +++ trunk/complement/explore/Makefiles/gmake/subdirs.mak 2007-02-06 15:01:03 UTC (rev 1517) @@ -1,6 +1,6 @@ # Time-stamp: <06/11/01 22:55:23 ptr> # -# Copyright (c) 2006 +# Copyright (c) 2006, 2007 # Petr Ovtchenkov # # Licensed under the Academic Free License version 3.0 @@ -8,7 +8,5 @@ # Do the same target in all catalogs as arg define doinsubdirs -for d in $(1); do \ - ${MAKE} -C $$d $@ || exit -1; \ -done +$(foreach d,$(1),${MAKE} -C ${d} $@;) endef This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 14:36:19
|
Revision: 1516 http://svn.sourceforge.net/complement/?rev=1516&view=rev Author: complement Date: 2007-02-06 06:36:17 -0800 (Tue, 06 Feb 2007) Log Message: ----------- remove @ token Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/subdirs.mak Modified: trunk/complement/explore/Makefiles/gmake/subdirs.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/subdirs.mak 2007-02-06 14:34:57 UTC (rev 1515) +++ trunk/complement/explore/Makefiles/gmake/subdirs.mak 2007-02-06 14:36:17 UTC (rev 1516) @@ -8,7 +8,7 @@ # Do the same target in all catalogs as arg define doinsubdirs -@for d in $(1); do \ - ${MAKE} -C $$d $@ || exit 1; \ +for d in $(1); do \ + ${MAKE} -C $$d $@ || exit -1; \ done endef This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 14:34:59
|
Revision: 1515 http://svn.sourceforge.net/complement/?rev=1515&view=rev Author: complement Date: 2007-02-06 06:34:57 -0800 (Tue, 06 Feb 2007) Log Message: ----------- use + token, to allow -j (parallel build) Modified Paths: -------------- trunk/complement/explore/lib/Makefile Modified: trunk/complement/explore/lib/Makefile =================================================================== --- trunk/complement/explore/lib/Makefile 2007-02-06 13:25:50 UTC (rev 1514) +++ trunk/complement/explore/lib/Makefile 2007-02-06 14:34:57 UTC (rev 1515) @@ -12,6 +12,6 @@ include ${SRCROOT}/Makefiles/gmake/subdirs.mak all install depend clean clobber distclean check: - $(call doinsubdirs,${SUBDIRS}) + +$(call doinsubdirs,${SUBDIRS}) .PHONY: all install depend clean clobber distclean check This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 13:25:52
|
Revision: 1514 http://svn.sourceforge.net/complement/?rev=1514&view=rev Author: complement Date: 2007-02-06 05:25:50 -0800 (Tue, 06 Feb 2007) Log Message: ----------- clean Removed Paths: ------------- tags/complement-20070205/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 13:25:27
|
Revision: 1513 http://svn.sourceforge.net/complement/?rev=1513&view=rev Author: complement Date: 2007-02-06 05:25:24 -0800 (Tue, 06 Feb 2007) Log Message: ----------- snapshot 2007-02-06 Added Paths: ----------- tags/complement-20070206/ Copied: tags/complement-20070206 (from rev 1512, trunk/complement) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 11:13:19
|
Revision: 1512 http://svn.sourceforge.net/complement/?rev=1512&view=rev Author: complement Date: 2007-02-06 03:13:17 -0800 (Tue, 06 Feb 2007) Log Message: ----------- fix and simplify test Modified Paths: -------------- trunk/complement/explore/test/sockios/read0_on_exec.cc Modified: trunk/complement/explore/test/sockios/read0_on_exec.cc =================================================================== --- trunk/complement/explore/test/sockios/read0_on_exec.cc 2007-02-06 10:47:44 UTC (rev 1511) +++ trunk/complement/explore/test/sockios/read0_on_exec.cc 2007-02-06 11:13:17 UTC (rev 1512) @@ -188,7 +188,7 @@ void close(); }; -static __Semaphore<true> *sem2; +static Condition cnd6; ConnectionProcessor6::ConnectionProcessor6( std::sockstream& s ) { @@ -198,7 +198,7 @@ BOOST_REQUIRE( s.good() ); pr_lock.unlock(); - sem2->post(); + cnd6.set( true ); } void ConnectionProcessor6::connect( std::sockstream& s ) @@ -214,17 +214,12 @@ void test_read0_srv() { - const char fname[] = "/tmp/sockios_test.shm"; try { - xmt::shm_alloc<0> seg; - - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); - xmt::allocator_shm<xmt::__Semaphore<true>,0> shm; - - sem2 = new ( shm.allocate( 1 ) ) xmt::__Semaphore<true>( 2 ); - sockmgr_stream_MP<ConnectionProcessor6> srv( ::port ); + BOOST_CHECK( srv.good() ); + cnd6.set( false ); + { // It should work as before system call... sockstream s( "localhost", ::port ); @@ -233,11 +228,15 @@ BOOST_CHECK( s.good() ); - sem2->wait(); + cnd6.try_wait(); } + cnd6.set( false ); + system( "echo > /dev/null" ); // <------ key line + BOOST_CHECK( srv.good() ); + { // ... as after system call. sockstream s( "localhost", ::port ); @@ -246,19 +245,13 @@ BOOST_CHECK( s.good() ); - sem2->wait(); + cnd6.try_wait(); } BOOST_CHECK( srv.good() ); // server must correctly process interrupt during system call srv.close(); - srv.wait(); - - sem2->~__Semaphore<true>(); - shm.deallocate( sem2, 1 ); - seg.deallocate(); - unlink( fname ); } catch ( xmt::shm_bad_alloc& err ) { BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 10:47:45
|
Revision: 1511 http://svn.sourceforge.net/complement/?rev=1511&view=rev Author: complement Date: 2007-02-06 02:47:44 -0800 (Tue, 06 Feb 2007) Log Message: ----------- one yield may be not enough on hi-end SMP Modified Paths: -------------- trunk/complement/explore/test/mt/mt_test.cc Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-06 10:13:58 UTC (rev 1510) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-06 10:47:44 UTC (rev 1511) @@ -158,7 +158,9 @@ { xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); b.wait(); - xmt::Thread::yield(); + for ( int i = 0; i < 128; ++i ) { + xmt::Thread::yield(); + } m1.lock(); BOOST_CHECK( x == 1 ); @@ -223,7 +225,9 @@ { xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); b.wait(); - xmt::Thread::yield(); + for ( int i = 0; i < 128; ++i ) { + xmt::Thread::yield(); + } sl1.lock(); BOOST_CHECK( x == 1 ); @@ -325,7 +329,9 @@ xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); b.wait(); - xmt::Thread::yield(); + for ( int i = 0; i < 128; ++i ) { + xmt::Thread::yield(); + } m2.lock(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-06 10:14:03
|
Revision: 1510 http://svn.sourceforge.net/complement/?rev=1510&view=rev Author: complement Date: 2007-02-06 02:13:58 -0800 (Tue, 06 Feb 2007) Log Message: ----------- add Barrier; add yield; libxmt 1.10.1 Modified Paths: -------------- trunk/complement/explore/COPYRIGHTS trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/test/mt/Makefile.inc trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test.h trunk/complement/explore/test/mt/mt_test_suite.cc trunk/complement/explore/test/mt/unit_test.cc Removed Paths: ------------- trunk/complement/explore/test/mt/join.cc trunk/complement/explore/test/mt/mutex_test.cc trunk/complement/explore/test/mt/recursive_mutex.cc trunk/complement/explore/test/mt/spinlock_test.cc Modified: trunk/complement/explore/COPYRIGHTS =================================================================== --- trunk/complement/explore/COPYRIGHTS 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/COPYRIGHTS 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,4 +1,4 @@ -Copyright (c) 1997-1999, 2001-2006 Petr Ovtchenkov +Copyright (c) 1997-1999, 2001-2007 Petr Ovtchenkov Portion Copyright (c) 1999-2001 Parallel Graphics Ltd. Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/include/mt/xmt.h 2007-02-06 10:13:58 UTC (rev 1510) @@ -39,6 +39,7 @@ # ifdef _PTHREADS # include <pthread.h> # include <semaphore.h> +# include <sched.h> # else # include <thread.h> # include <synch.h> @@ -1466,7 +1467,43 @@ #endif } +template <bool SCOPE> +class __Barrier +{ + public: + __Barrier( unsigned cnt = 2 ) + { +#ifdef _PTHREADS + pthread_barrierattr_t attr; + pthread_barrierattr_init( &attr ); + pthread_barrierattr_setpshared( &attr, SCOPE ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE ); + pthread_barrier_init( &_barr, &attr, cnt ); + pthread_barrierattr_destroy( &attr ); +#endif + } + ~__Barrier() + { +#ifdef _PTHREADS + pthread_barrier_destroy( &_barr ); +#endif + } + + int wait() + { +#ifdef _PTHREADS + return pthread_barrier_wait( &_barr ); +#endif + } + + private: +#ifdef _PTHREADS + pthread_barrier_t _barr; +#endif +}; + +typedef __Barrier<false> Barrier; + __FIT_DECLSPEC void fork() throw( fork_in_parent, std::runtime_error ); __FIT_DECLSPEC void become_daemon() throw( fork_in_parent, std::runtime_error ); __FIT_DECLSPEC void block_signal( int sig ); @@ -1563,6 +1600,10 @@ static __FIT_DECLSPEC int join_all(); #endif static __FIT_DECLSPEC void signal_exit( int sig ); // signal handler +#if defined(_PTHREADS) + static int yield() + { return sched_yield(); } +#endif bool good() const { /* Locker lk( _llock ); */ return (_id != bad_thread_id); } Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,3 +1,9 @@ +2007-02-06 Petr Ovtchenkov <pt...@is...> + + * xmt.h: add Barrier; add yield; + + * libxmt: version 1.10.1 + 2007-02-02 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc: remove _state field, unuseful; add thread Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-02-06 10:13:58 UTC (rev 1510) @@ -3,6 +3,6 @@ LIBNAME = xmt MAJOR = 1 MINOR = 10 -PATCH = 0 +PATCH = 1 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc SRC_C = fl.c Modified: trunk/complement/explore/test/mt/Makefile.inc =================================================================== --- trunk/complement/explore/test/mt/Makefile.inc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/Makefile.inc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <06/12/16 00:37:10 ptr> +# -*- makefile -*- Time-stamp: <07/02/06 10:04:25 ptr> PRGNAME = mt_ut -SRC_CC = unit_test.cc timespec.cc mutex_test.cc spinlock_test.cc \ - recursive_mutex.cc join.cc signal-1.cc signal-2.cc signal-3.cc flck.cc lfs.cc \ +SRC_CC = unit_test.cc timespec.cc \ + signal-1.cc signal-2.cc signal-3.cc flck.cc lfs.cc \ mt_test.cc mt_test_suite.cc Deleted: trunk/complement/explore/test/mt/join.cc =================================================================== --- trunk/complement/explore/test/mt/join.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/join.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,48 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/08/04 11:09:21 ptr> - -/* - * Copyright (c) 2003, 2006 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <mt/xmt.h> - -using namespace xmt; - -static int x = 0; - -Thread::ret_code thread_entry_call( void * ) -{ - x = 1; - - Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -void join_test() -{ - BOOST_CHECK( x == 0 ); - - Thread t( thread_entry_call ); - - t.join(); - - BOOST_CHECK( x == 1 ); -} Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <07/02/02 20:53:03 ptr> +// -*- C++ -*- Time-stamp: <07/02/06 10:36:47 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 @@ -31,6 +31,334 @@ using namespace boost::unit_test_framework; namespace fs = boost::filesystem; +/* ****************************************************** + * Degenerative case: check that one thread pass throw + * own barrier. + */ +void mt_test::barrier() +{ + xmt::Barrier b( 1 ); + + b.wait(); +} + +/* ****************************************************** + * Start thread, join it. + */ + +static int x = 0; + +xmt::Thread::ret_code thread_entry_call( void * ) +{ + x = 1; + + xmt::Thread::ret_code rt; + rt.iword = 0; + + return rt; +} + +void mt_test::join_test() +{ + BOOST_CHECK( x == 0 ); + + xmt::Thread t( thread_entry_call ); + + t.join(); + + BOOST_CHECK( x == 1 ); +} + +/* ****************************************************** + * Start two threads, align ones on barrier, join. + */ + +xmt::Thread::ret_code thread2_entry_call( void *p ) +{ + xmt::Thread::ret_code rt; + rt.iword = 0; + + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + + return rt; +} + +void mt_test::barrier2() +{ + xmt::Barrier b; + + xmt::Thread t1( thread2_entry_call, &b ); + xmt::Thread t2( thread2_entry_call, &b ); + + t2.join(); + t1.join(); +} + +/* ****************************************************** + * Start two threads, align ones on barrier; one thread + * relinquish control to other; join (within Thread dtors) + */ + +xmt::Thread::ret_code thread3_entry_call( void *p ) +{ + xmt::Thread::ret_code rt; + rt.iword = 0; + + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + BOOST_CHECK( xmt::Thread::yield() == 0 ); + + return rt; +} + +void mt_test::yield() +{ + xmt::Barrier b; + + xmt::Thread t1( thread2_entry_call, &b ); + xmt::Thread t2( thread3_entry_call, &b ); + // .join()'s are in Thread's destructors +} + +/* ****************************************************** + * Test for plain mutex. + * + * Start two threads, align ones on barrier, thr2 relinquish + * control to thr1; + * thr1 acquire lock, try to yield control to thr2 (that + * should be blocked on m1); + * Correct order checked by values of x. + */ + +static xmt::Mutex m1; + +xmt::Thread::ret_code thr1( void *p ) +{ + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + + m1.lock(); + BOOST_CHECK( x == 0 ); + + xmt::Thread::yield(); + + BOOST_CHECK( x == 0 ); + x = 1; + + m1.unlock(); + + xmt::Thread::ret_code rt; + rt.iword = 0; + + return rt; +} + +xmt::Thread::ret_code thr2( void *p ) +{ + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + xmt::Thread::yield(); + + m1.lock(); + BOOST_CHECK( x == 1 ); + x = 2; + m1.unlock(); + + xmt::Thread::ret_code rt; + rt.iword = 0; + + return rt; +} + +void mt_test::mutex_test() +{ + x = 0; + xmt::Barrier b; + + xmt::Thread t1( thr1, &b ); + xmt::Thread t2( thr2, &b ); + + t1.join(); + t2.join(); + + BOOST_CHECK( x == 2 ); +} + +/* ****************************************************** + * Test for spinlocks. + * + * Start two threads, align ones on barrier, thr2 relinquish + * control to thr1; + * thr1 acquire lock, try to yield control to thr2 (that + * should be blocked on sl1); + * Correct order checked by values of x. + */ + +#ifdef __FIT_PTHREAD_SPINLOCK +static xmt::Spinlock sl1; + +xmt::Thread::ret_code thr1s( void *p ) +{ + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + + sl1.lock(); + BOOST_CHECK( x == 0 ); + + xmt::Thread::yield(); + + BOOST_CHECK( x == 0 ); + x = 1; + + sl1.unlock(); + + xmt::Thread::ret_code rt; + rt.iword = 0; + + return rt; +} + +xmt::Thread::ret_code thr2s( void *p ) +{ + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + xmt::Thread::yield(); + + sl1.lock(); + BOOST_CHECK( x == 1 ); + x = 2; + sl1.unlock(); + + xmt::Thread::ret_code rt; + rt.iword = 0; + + return rt; +} + +#endif + +void mt_test::spinlock_test() +{ +#ifdef __FIT_PTHREAD_SPINLOCK + x = 0; + xmt::Barrier b; + + xmt::Thread t1( thr1s, &b ); + xmt::Thread t2( thr2s, &b ); + + t1.join(); + t2.join(); + + BOOST_CHECK( x == 2 ); +#endif +} + +/* ****************************************************** */ + +/* + * Test for recursive-safe mutexes (detect deadlock) + * + * 1. Start thread 1. Acquire lock on m2. + * + * 2. Start thread 2. Yield control to thread 1, to be sure that thread 1 + * acquire lock on m2 first. Acquire lock on m2. + * Due to m2 locked in thread 1, waiting on m2.lock. + * + * 3. Thread 1 relinquish control to thread 2, to give it chance. + * + * 4. From thread 1 call function 'recursive', where acquire lock on m2, + * relinquish control to thread2, and then release m2. + * If mutex recursive-safe, function 'recursive' will finished correctly. + * Otherwise, deedlock will happen on m2.lock in 'recursive'. + * + * 5. Release m2 in thread 1. + * + * 6. Pass through m2 lock in thread 2. Call function 'recursive', + * where acquire lock on m2, relinquish control, and then release m2. See item 4 before. + * + * 7. Release m2 in thread 2. + * + * 8. Test finished. + * + */ + +xmt::__Mutex<true,false> m2; + +void recursive() +{ + m2.lock(); + + x = 2; + xmt::Thread::yield(); + BOOST_CHECK( x == 2 ); + + m2.unlock(); +} + +xmt::Thread::ret_code thr1r( void *p ) +{ + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + + m2.lock(); + + BOOST_CHECK( x == 0 ); + x = 1; + xmt::Thread::yield(); + BOOST_CHECK( x == 1 ); + recursive(); + BOOST_CHECK( x == 2 ); + x = 3; + + m2.unlock(); + + xmt::Thread::ret_code rt; + + rt.iword = 0; + + return rt; +} + +xmt::Thread::ret_code thr2r( void *p ) +{ + xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + b.wait(); + + xmt::Thread::yield(); + + m2.lock(); + + BOOST_CHECK( x == 3 ); + xmt::Thread::yield(); + recursive(); + BOOST_CHECK( x == 2 ); + + m2.unlock(); + + xmt::Thread::ret_code rt; + + rt.iword = 0; + + return rt; +} + +void mt_test::recursive_mutex_test() +{ + x = 0; + xmt::Barrier b; + + xmt::Thread t1( thr1r, &b ); + xmt::Thread t2( thr2r, &b ); + + t1.join(); + t2.join(); + + BOOST_CHECK( x == 2 ); +} + +/* ****************************************************** */ + void mt_test::fork() { shmid_ds ds; @@ -86,6 +414,8 @@ shmctl( id, IPC_RMID, &ds ); } +/* ****************************************************** */ + void mt_test::pid() { shmid_ds ds; @@ -148,6 +478,8 @@ shmctl( id, IPC_RMID, &ds ); } +/* ****************************************************** */ + void mt_test::shm_segment() { const char fname[] = "/tmp/mt_test.shm"; @@ -216,6 +548,8 @@ } } +/* ****************************************************** */ + void mt_test::shm_alloc() { const char fname[] = "/tmp/mt_test.shm"; @@ -290,7 +624,7 @@ } -/* +/* ****************************************************** * This test is similar mt_test::fork() above, but instead plain shm_* * functions it use allocator based on shared memory segment */ @@ -344,8 +678,8 @@ } } -/* - * Test: how to take named object +/* ****************************************************** + * Test: how to take named object in shared memory segment */ void mt_test::shm_named_obj() { @@ -425,13 +759,23 @@ } +/* ****************************************************** + * Thread pool (aka ThreadMgr) test. + * + * Start 200 threads under ThreadMgr; check that all threads + * started, check that all theads finished, no garbage in + * ThreadMgr remains. + */ + static int my_thr_cnt = 0; +static int my_thr_scnt = 0; static xmt::Mutex lock; xmt::Thread::ret_code thread_mgr_entry_call( void * ) { lock.lock(); ++my_thr_cnt; + ++my_thr_scnt; lock.unlock(); xmt::Thread::ret_code rt; @@ -455,6 +799,7 @@ // cerr << "Join!\n"; mgr.join(); + BOOST_CHECK( my_thr_scnt == 200 ); BOOST_CHECK( my_thr_cnt == 0 ); BOOST_CHECK( mgr.size() == 0 ); } Modified: trunk/complement/explore/test/mt/mt_test.h =================================================================== --- trunk/complement/explore/test/mt/mt_test.h 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/mt_test.h 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <07/02/02 16:45:13 ptr> +// -*- C++ -*- Time-stamp: <07/02/06 09:48:27 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 @@ -11,8 +11,17 @@ #ifndef __MT_TEST_H #define __MT_TEST_H -struct mt_test +class mt_test { + public: + void barrier(); + void join_test(); + void barrier2(); + void yield(); + void mutex_test(); + void spinlock_test(); + void recursive_mutex_test(); + void fork(); void pid(); void shm_segment(); @@ -20,6 +29,10 @@ void fork_shm(); void shm_named_obj(); void thr_mgr(); + + private: + // static xmt::Thread::ret_code thread_entry_call( void * ); + // static int x; }; #endif // __MT_TEST_H Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/02 17:15:47 ptr> +// -*- C++ -*- Time-stamp: <07/02/06 10:06:37 ptr> /* * Copyright (c) 2006, 2007 @@ -11,6 +11,8 @@ #include "mt_test_suite.h" #include "mt_test.h" +#include <config/feature.h> + using namespace boost::unit_test_framework; mt_test_suite::mt_test_suite() : @@ -18,6 +20,15 @@ { boost::shared_ptr<mt_test> instance( new mt_test() ); + test_case *barrier_tc = BOOST_CLASS_TEST_CASE( &mt_test::barrier, instance ); + test_case *join_tc = BOOST_CLASS_TEST_CASE( &mt_test::join_test, instance ); + test_case *barrier2_tc = BOOST_CLASS_TEST_CASE( &mt_test::barrier2, instance ); + test_case *yield_tc = BOOST_CLASS_TEST_CASE( &mt_test::yield, instance ); + test_case *mutex_test_tc = BOOST_CLASS_TEST_CASE( &mt_test::mutex_test, instance ); +#ifdef __FIT_PTHREAD_SPINLOCK + test_case *spinlock_test_tc = BOOST_CLASS_TEST_CASE( &mt_test::spinlock_test, instance ); +#endif + test_case *recursive_mutex_test_tc = BOOST_CLASS_TEST_CASE( &mt_test::recursive_mutex_test, instance ); test_case *fork_tc = BOOST_CLASS_TEST_CASE( &mt_test::fork, instance ); test_case *pid_tc = BOOST_CLASS_TEST_CASE( &mt_test::pid, instance ); test_case *shm_segment_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_segment, instance ); @@ -27,11 +38,30 @@ test_case *thr_mgr_tc = BOOST_CLASS_TEST_CASE( &mt_test::thr_mgr, instance ); + barrier2_tc->depends_on( barrier_tc ); + barrier2_tc->depends_on( join_tc ); + yield_tc->depends_on( barrier2_tc ); + mutex_test_tc->depends_on( yield_tc ); +#ifdef __FIT_PTHREAD_SPINLOCK + spinlock_test_tc->depends_on( yield_tc ); +#endif + recursive_mutex_test_tc->depends_on( mutex_test_tc ); + pid_tc->depends_on( fork_tc ); shm_alloc_tc->depends_on( shm_segment_tc ); fork_shm_tc->depends_on( shm_alloc_tc ); shm_nm_obj_tc->depends_on( fork_shm_tc ); + add( barrier_tc, 0, 2 ); + add( join_tc ); + add( barrier2_tc, 0, 3 ); + add( yield_tc, 0, 3 ); + add( mutex_test_tc, 0, 3 ); +#ifdef __FIT_PTHREAD_SPINLOCK + add( spinlock_test_tc, 0, 3 ); +#endif + add( recursive_mutex_test_tc, 0, 3 ); + add( fork_tc ); add( pid_tc ); add( shm_segment_tc ); Deleted: trunk/complement/explore/test/mt/mutex_test.cc =================================================================== --- trunk/complement/explore/test/mt/mutex_test.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/mutex_test.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,121 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/12/15 10:37:09 ptr> - -/* - * Copyright (c) 2002, 2003, 2006 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 3.0 - * - */ - -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <mt/xmt.h> - -using namespace std; -using namespace xmt; - -static Mutex m1; - -static int v = 0; -static volatile int msync = 0; - -xmt::Thread::ret_code thr1( void * ) -{ - m1.lock(); - msync = 1; - BOOST_CHECK( v == 0 ); - - delay( xmt::timespec( 1, 0 ) ); - - BOOST_CHECK( v == 0 ); - v = 1; - - m1.unlock(); - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -xmt::Thread::ret_code thr2( void * ) -{ - int j = 0; - while ( !msync ) { - ++j; - } - m1.lock(); - BOOST_CHECK( v == 1); - v = 2; - m1.unlock(); - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -xmt::Thread::ret_code thr3( void * ) -{ - m1.lock(); - msync = 1; - - BOOST_CHECK( v == 0 ); - - delay( xmt::timespec( 1, 0 ) ); - - v = 1; - - m1.unlock(); - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -xmt::Thread::ret_code thr4( void * ) -{ -#ifndef _WIN32 // no trylock - int j = 0; - while ( !msync ) { - ++j; - } - if ( m1.trylock() == 0 ) { - BOOST_CHECK( v == 1 ); - m1.unlock(); - BOOST_ERROR( "m1.trylock() return zero!" ); - } -#endif // _WIN32 - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - - -void mutex_test() -{ - v = 0; - Thread t1( thr1 ); - Thread t2( thr2 ); - - t1.join(); - t2.join(); - - msync = 0; - - BOOST_CHECK( v == 2 ); - -#ifndef _WIN32 - v = 0; - Thread t3( thr3 ); - Thread t4( thr4 ); - - t3.join(); - t4.join(); -#endif // _WIN32 -} Deleted: trunk/complement/explore/test/mt/recursive_mutex.cc =================================================================== --- trunk/complement/explore/test/mt/recursive_mutex.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/recursive_mutex.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,170 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/12/15 10:39:45 ptr> - -/* - * Copyright (c) 2003, 2006 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 3.0 - * - */ - - -/* - * Test for recursive-safe mutexes (detect deadlock) - * - * 1. Start thread 1. Acquire lock on m. Sleep hread 1 sec. - * - * 2. Start thread 2. Acquire lock on m. Due to m locked - * in thread 1, waiting on m.lock. - * - * 3. From thread 1 call function 'recursive', where acquire lock on m, - * sleep 1 sec, and release m. - * If mutex recursive-safe, function 'recursive' will finished correctly. - * Otherwise, deedlock will happen on m.lock in 'recursive'. - * - * 4. Release m in thread 1. - * - * 5. Pass through m lock in thread 2. Call function 'recursive', - * where acquire lock on m, sleep 1 sec, and release m. See item 3 before. - * - * 6. Release m in thread 2. - * - * 7. Program finished. - * - */ - -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <mt/xmt.h> -#include <iostream> - -using namespace xmt; -using namespace std; - -// Mutex pm; - -__Mutex<true,false> m; -static int v = 0; - -void recursive() -{ - // pm.lock(); - // cerr << "before lock recursive" << endl; - // pm.unlock(); - - m.lock(); - v = 2; - - xmt::sleep( xmt::timespec(1,0) ); - BOOST_CHECK( v == 2 ); - m.unlock(); - - // pm.lock(); - // cerr << "after lock recursive" << endl; - // pm.unlock(); -} - -Thread::ret_code thread_one( void * ) -{ - // pm.lock(); - // cerr << "before lock in thread one" << endl; - // pm.unlock(); - - m.lock(); - - BOOST_CHECK( v == 0 ); - - v = 1; - - // pm.lock(); - // cerr << "after lock in thread one" << endl; - // pm.unlock(); - - xmt::sleep( xmt::timespec(1,0) ); - - BOOST_CHECK( v == 1 ); - - recursive(); - - // pm.lock(); - // cerr << "before unlock in thread one" << endl; - // pm.unlock(); - - BOOST_CHECK( v == 2 ); - - v = 3; - - m.unlock(); - - // pm.lock(); - // cerr << "after unlock in thread one" << endl; - // pm.unlock(); - - Thread::ret_code rt; - - rt.iword = 0; - - return rt; -} - -Thread::ret_code thread_two( void * ) -{ - // pm.lock(); - // cerr << "before lock in thread two" << endl; - // pm.unlock(); - - m.lock(); - - // pm.lock(); - // cerr << "after lock in thread two" << endl; - // pm.unlock(); - BOOST_CHECK( v == 3 ); - - xmt::sleep( xmt::timespec(1,0) ); - recursive(); - - // pm.lock(); - // cerr << "before unlock in thread two" << endl; - // pm.unlock(); - - BOOST_CHECK( v == 2 ); - - m.unlock(); - - // pm.lock(); - // cerr << "after unlock in thread two" << endl; - // pm.unlock(); - - Thread::ret_code rt; - - rt.iword = 0; - - return rt; -} - - -void recursive_mutex_test() -{ - // pm.lock(); - // cerr << "main: create thread one" << endl; - // pm.unlock(); - - Thread t1( thread_one ); - - // pm.lock(); - // cerr << "main: create thread two" << endl; - // pm.unlock(); - - Thread t2( thread_two ); - - t1.join(); - t2.join(); - - // pm.lock(); - // cerr << "main: End" << endl; - // pm.unlock(); - - // return 0; -} Deleted: trunk/complement/explore/test/mt/spinlock_test.cc =================================================================== --- trunk/complement/explore/test/mt/spinlock_test.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/spinlock_test.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,106 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/12/15 10:38:16 ptr> - -/* - * Copyright (c) 2002, 2003, 2006 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 3.0 - * - */ - -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <mt/xmt.h> - -using namespace std; -using namespace xmt; - -static int v = 0; - -#ifdef __FIT_PTHREAD_SPINLOCK -static Spinlock sl1; - -xmt::Thread::ret_code thr1_sl( void * ) -{ - sl1.lock(); - BOOST_CHECK( v == 0 ); - - delay( xmt::timespec( 1, 0 ) ); - - BOOST_CHECK( v == 0 ); - v = 1; - - sl1.unlock(); - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -xmt::Thread::ret_code thr2_sl( void * ) -{ - sl1.lock(); - BOOST_CHECK( v == 1); - v = 2; - sl1.unlock(); - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -xmt::Thread::ret_code thr3_sl( void * ) -{ - sl1.lock(); - - BOOST_CHECK( v == 0 ); - - delay( xmt::timespec( 1, 0 ) ); - - v = 1; - - sl1.unlock(); - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -xmt::Thread::ret_code thr4_sl( void * ) -{ - if ( sl1.trylock() == 0 ) { - BOOST_CHECK( v == 1 ); - sl1.unlock(); - BOOST_ERROR( "m1.trylock() return zero!" ); - } - - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; -} - -void spinlock_test() -{ - v = 0; - Thread t1( thr1_sl ); - Thread t2( thr2_sl ); - - t1.join(); - t2.join(); - - BOOST_CHECK( v == 2 ); - - v = 0; - Thread t3( thr3_sl ); - Thread t4( thr4_sl ); - - t3.join(); - t4.join(); -} -#endif // __FIT_PTHREAD_SPINLOCK Modified: trunk/complement/explore/test/mt/unit_test.cc =================================================================== --- trunk/complement/explore/test/mt/unit_test.cc 2007-02-05 13:09:03 UTC (rev 1509) +++ trunk/complement/explore/test/mt/unit_test.cc 2007-02-06 10:13:58 UTC (rev 1510) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/16 00:36:47 ptr> +// -*- C++ -*- Time-stamp: <07/02/06 10:08:47 ptr> /* * Copyright (c) 2002, 2003, 2004, 2006 @@ -16,12 +16,6 @@ using namespace boost::unit_test_framework; void timespec_diff(); -void join_test(); -void mutex_test(); -#ifdef __FIT_PTHREAD_SPINLOCK -void spinlock_test(); -#endif // __FIT_PTHREAD_SPINLOCK -void recursive_mutex_test(); void signal_1_test(); void signal_2_test(); void signal_3_test(); @@ -38,12 +32,6 @@ test_suite *ts = BOOST_TEST_SUITE( "libxmt test" ); ts->add( BOOST_TEST_CASE( ×pec_diff ) ); - ts->add( BOOST_TEST_CASE( &join_test ) ); - ts->add( BOOST_TEST_CASE( &mutex_test ) ); -#ifdef __FIT_PTHREAD_SPINLOCK - ts->add( BOOST_TEST_CASE( &spinlock_test ) ); -#endif - ts->add( BOOST_TEST_CASE( &recursive_mutex_test ) ); ts->add( BOOST_TEST_CASE( &signal_1_test ) ); // You can't throw exception from signal handler // (stack saved/restored, that confuse stack unwind); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-05 13:09:05
|
Revision: 1509 http://svn.sourceforge.net/complement/?rev=1509&view=rev Author: complement Date: 2007-02-05 05:09:03 -0800 (Mon, 05 Feb 2007) Log Message: ----------- sample: link with boost's utf Added Paths: ----------- trunk/complement/explore/inquiry/STLport/boost-sample/ trunk/complement/explore/inquiry/STLport/boost-sample/Makefile trunk/complement/explore/inquiry/STLport/boost-sample/Makefile.inc trunk/complement/explore/inquiry/STLport/boost-sample/test_parser_lowlevel4.cpp Property changes on: trunk/complement/explore/inquiry/STLport/boost-sample ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/inquiry/STLport/boost-sample/Makefile =================================================================== --- trunk/complement/explore/inquiry/STLport/boost-sample/Makefile (rev 0) +++ trunk/complement/explore/inquiry/STLport/boost-sample/Makefile 2007-02-05 13:09:03 UTC (rev 1509) @@ -0,0 +1,15 @@ +# -*- Makefile -*- Time-stamp: <03/07/09 18:08:47 ptr> + +SRCROOT := ../../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/top.mak + +INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) + +LDFLAGS += -Wl,-rpath=$(STLPORT_LIB_DIR):${CoMT_LIB_DIR} + +release-shared : LDLIBS = -L${CoMT_LIB_DIR} -lboost_test_utf +stldbg-shared : LDLIBS = -L${CoMT_LIB_DIR} -lboost_test_utfstlg +dbg-shared : LDLIBS = -L${CoMT_LIB_DIR} -lboost_test_utfg Added: trunk/complement/explore/inquiry/STLport/boost-sample/Makefile.inc =================================================================== --- trunk/complement/explore/inquiry/STLport/boost-sample/Makefile.inc (rev 0) +++ trunk/complement/explore/inquiry/STLport/boost-sample/Makefile.inc 2007-02-05 13:09:03 UTC (rev 1509) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> + +PRGNAME = test +SRC_CPP = test_parser_lowlevel4.cpp Added: trunk/complement/explore/inquiry/STLport/boost-sample/test_parser_lowlevel4.cpp =================================================================== --- trunk/complement/explore/inquiry/STLport/boost-sample/test_parser_lowlevel4.cpp (rev 0) +++ trunk/complement/explore/inquiry/STLport/boost-sample/test_parser_lowlevel4.cpp 2007-02-05 13:09:03 UTC (rev 1509) @@ -0,0 +1,68 @@ +// g++ -g -Wall -o test_parser_lowlevel4 test_parser_lowlevel4.cpp `pkg-config --cflags --libs avisynth-3.0` -lboost_unit_test_framework-gcc-mt-p-1_33_1 -lboost_thread-gcc-mt-p-1_33_1 + +// g++ -g -Wall -o test_parser_lowlevel4 test_parser_lowlevel4.cpp -I$HOME/local/include/boost-1_33_1 -pthread -L$HOME/local/lib -lboost_unit_test_framework-gcc-mt-p-1_33_1 -lboost_thread-gcc-mt-p-1_33_1 + + + +// STL includes +#include <iostream> +#include <sstream> +#include <string> + +// Boost includes +#include <boost/test/unit_test.hpp> + +struct parse_test +{ +private: + + std::string msg_; + +public: // constructor + + parse_test (std::string const& msg) + : msg_(msg) { } + +public: // tests + + void test_integer (); + +private: + + std::string parse_script (std::string const& src); +}; + +void parse_test::test_integer () +{ + BOOST_CHECK_EQUAL (parse_script ("2"), "2"); + BOOST_CHECK_EQUAL (parse_script ("3"), "2"); +} + +std::string parse_test::parse_script (std::string const& src) +{ + return src; +} + +struct parse_test_suite : public boost::unit_test::test_suite +{ + parse_test_suite (std::string const& msg) + : test_suite ("low level test") + { + boost::shared_ptr<parse_test> instance (new parse_test (msg)); + + boost::unit_test::test_case *integer_test_case = + BOOST_CLASS_TEST_CASE (&parse_test::test_integer, instance); + add (integer_test_case, 1); + } +}; + +boost::unit_test::test_suite * +init_unit_test_suite (int argc, char *argv[]) +{ + boost::unit_test::test_suite *tests = BOOST_TEST_SUITE ("unit test"); + std::string msg = "2"; + + tests->add (new parse_test_suite (msg)); + + return tests; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-05 12:24:35
|
Revision: 1508 http://svn.sourceforge.net/complement/?rev=1508&view=rev Author: complement Date: 2007-02-05 04:24:34 -0800 (Mon, 05 Feb 2007) Log Message: ----------- clean Removed Paths: ------------- tags/complement-20070131/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-05 12:24:14
|
Revision: 1507 http://svn.sourceforge.net/complement/?rev=1507&view=rev Author: complement Date: 2007-02-05 04:24:09 -0800 (Mon, 05 Feb 2007) Log Message: ----------- snapshot 2007-02-05 Added Paths: ----------- tags/complement-20070205/ Copied: tags/complement-20070205 (from rev 1506, trunk/complement) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-05 10:05:51
|
Revision: 1506 http://svn.sourceforge.net/complement/?rev=1506&view=rev Author: complement Date: 2007-02-05 02:05:46 -0800 (Mon, 05 Feb 2007) Log Message: ----------- fix tags generation Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/depend.mak trunk/complement/explore/inquiry/STLport/multimap/Makefile Modified: trunk/complement/explore/Makefiles/gmake/depend.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/depend.mak 2007-02-05 08:58:40 UTC (rev 1505) +++ trunk/complement/explore/Makefiles/gmake/depend.mak 2007-02-05 10:05:46 UTC (rev 1506) @@ -1,4 +1,4 @@ -# Time-stamp: <07/01/23 14:58:21 ptr> +# Time-stamp: <07/02/05 12:57:11 ptr> # # Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 # Petr Ovtchenkov @@ -35,9 +35,9 @@ @cat -s $(_ALL_DEP) /dev/null > $(DEPENDS_COLLECTION) TAGS: $(OUTPUT_DIRS) ${_DASH_DEP} - @etags -i -m `cat -s $(_ALL_DEP) /dev/null | sed 's/^.*://;s/\\\\$$//' | uniq -u` + @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs etags -i -m tags: $(OUTPUT_DIRS) ${_DASH_DEP} - @ctags -d --globals --declarations -t -w `cat -s $(_ALL_DEP) /dev/null | sed 's/^.*://;s/\\\\$$//' | uniq -u` + @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | ctags -d --globals --declarations -t -w -include $(DEPENDS_COLLECTION) Modified: trunk/complement/explore/inquiry/STLport/multimap/Makefile =================================================================== --- trunk/complement/explore/inquiry/STLport/multimap/Makefile 2007-02-05 08:58:40 UTC (rev 1505) +++ trunk/complement/explore/inquiry/STLport/multimap/Makefile 2007-02-05 10:05:46 UTC (rev 1506) @@ -2,6 +2,7 @@ SRCROOT := ../../.. COMPILER_NAME := gcc +STLPORT_DIR := /export/home/ptr/STLport.lab/STLport.5_0 include Makefile.inc include ${SRCROOT}/Makefiles/top.mak This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-05 08:58:43
|
Revision: 1505 http://svn.sourceforge.net/complement/?rev=1505&view=rev Author: complement Date: 2007-02-05 00:58:40 -0800 (Mon, 05 Feb 2007) Log Message: ----------- fix subdirs traverse Modified Paths: -------------- trunk/complement/extern/custom/boost/libs/Makefile Modified: trunk/complement/extern/custom/boost/libs/Makefile =================================================================== --- trunk/complement/extern/custom/boost/libs/Makefile 2007-02-02 18:54:52 UTC (rev 1504) +++ trunk/complement/extern/custom/boost/libs/Makefile 2007-02-05 08:58:40 UTC (rev 1505) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <06/11/01 22:56:34 ptr> +# -*- makefile -*- Time-stamp: <07/02/03 09:26:04 ptr> # -# Copyright (c) 2006 +# Copyright (c) 2006, 2007 # Petr Ovtchenkov # # Licensed under the Academic Free License version 3.0 @@ -14,6 +14,6 @@ include ${SRCROOT}/Makefiles/gmake/subdirs.mak all install install-release-static depend clean clobber distclean check: - $(doinsubdirs) + $(call doinsubdirs,${SUBDIRS}) .PHONY: all install install-release-static depend clean clobber distclean check This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-02-02 18:54:54
|
Revision: 1504 http://svn.sourceforge.net/complement/?rev=1504&view=rev Author: complement Date: 2007-02-02 10:54:52 -0800 (Fri, 02 Feb 2007) Log Message: ----------- remove _state field, unuseful; add thread id for RIP---_id used for living thread [and show that thread alive], while _rip_id used in join only libxmt: version 1.10.0 Modified Paths: -------------- trunk/complement/explore/include/mt/thr_mgr.h trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/thr_mgr.cc trunk/complement/explore/lib/mt/xmt.cc trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test.h trunk/complement/explore/test/mt/mt_test_suite.cc Modified: trunk/complement/explore/include/mt/thr_mgr.h =================================================================== --- trunk/complement/explore/include/mt/thr_mgr.h 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/include/mt/thr_mgr.h 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/01 18:39:25 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 20:54:44 ptr> /* * Copyright (c) 1997-1999, 2002, 2005, 2006 @@ -42,7 +42,7 @@ __FIT_DECLSPEC void join(); __FIT_DECLSPEC void signal( int ); - container_type::size_type size(); + container_type::size_type size() const; protected: _Sequence _M_c; Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/include/mt/xmt.h 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/29 18:58:49 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 21:32:58 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -1565,11 +1565,11 @@ static __FIT_DECLSPEC void signal_exit( int sig ); // signal handler bool good() const - { return (_state == goodbit) && (_id != bad_thread_id); } + { /* Locker lk( _llock ); */ return (_id != bad_thread_id); } bool bad() const - { return (_state != goodbit) || (_id == bad_thread_id); } - bool is_join_req() // if true, you can (and should) use join() - { return (_id != bad_thread_id) && ((_flags & (daemon | detached)) == 0); } + { /* Locker lk( _llock ); */ return (_id == bad_thread_id); } + bool is_join_req() const // if true, you can (and should) use join() + { /* Locker lk( _llock ); */ return (_rip_id != bad_thread_id) && ((_flags & (daemon | detached)) == 0); } __FIT_DECLSPEC bool is_self(); @@ -1597,6 +1597,8 @@ Thread( const Thread& ) { } + bool _not_run() const + { /* Locker lk( _llock ); */ return _id == bad_thread_id; } void _create( const void *p, size_t psz ) throw( std::runtime_error); static void *_call( void *p ); @@ -1617,12 +1619,11 @@ static int _idx; // user words index static int _self_idx; // user words index, that word point to self static Mutex _idx_lock; - static Mutex _start_lock; static thread_key_type& _mt_key; size_t uw_alloc_size; thread_id_type _id; - int _state; // state flags + thread_id_type _rip_id; #ifdef _PTHREADS # ifndef __hpux // sorry, POSIX threads don't have suspend/resume calls, so it should @@ -1641,7 +1642,7 @@ size_t _param_sz; unsigned _flags; size_t _stack_sz; // stack size, if not 0 - // Mutex _params_lock; --- no needs + // Mutex _llock; friend class Init; // extern "C", wrap for thread_create #ifdef __unix Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,3 +1,20 @@ +2007-02-02 Petr Ovtchenkov <pt...@is...> + + * xmt.h, xmt.cc: remove _state field, unuseful; add thread + id for RIP---_id used for living thread [and show that + thread alive], while _rip_id used in join only; this reflect + two independent [well, almost independent] states---thread + run/not run and thread require join/not require join. + When I trying to made all operations with _id and _rip_id + with MT guards, the speed of sockstreams was VERY slow, + so I remove ones; atomics in a few places? + Here remains one thing---what I should do, if I made few + Threads and then fork? + + * thr_mgr.cc: sync with changes in xmt[.h.cc]. + + * libxmt: version 1.10.0 + 2007-02-01 Petr Ovtchenkov <pt...@is...> * thr_mgr.cc: reduce amount of code; try to 'join' to already Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,8 +1,8 @@ -# -*- Makefile -*- Time-stamp: <07/02/01 11:14:39 ptr> +# -*- Makefile -*- Time-stamp: <07/02/02 20:56:56 ptr> LIBNAME = xmt MAJOR = 1 -MINOR = 9 -PATCH = 5 +MINOR = 10 +PATCH = 0 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/thr_mgr.cc =================================================================== --- trunk/complement/explore/lib/mt/thr_mgr.cc 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/lib/mt/thr_mgr.cc 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/01 20:17:50 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 20:55:08 ptr> /* * Copyright (c) 1997-1999, 2002, 2005-2007 @@ -17,6 +17,8 @@ // #include <iostream> +// extern int my_thr_cnt; + namespace xmt { // int _supercount = 0; @@ -48,14 +50,29 @@ if ( __x == 0 ) { return true; } + // cerr << (void *)__x << " "; if ( __x->bad() ) { + // cerr << "delete\n"; // --_supercount; delete __x; return true; } + // cerr << "?\n"; return false; } +struct rm_thread : + public unary_function<Thread *,bool> +{ + bool operator()(Thread *__x); +}; + +bool rm_thread::operator()(Thread *__x) +{ + delete __x; + return true; +} + struct thread_signal : public binary_function<Thread *,int,void> { @@ -82,14 +99,20 @@ // xmt::block_signal( SIGCHLD ); // xmt::block_signal( SIGPOLL ); + /* + * This 'soft' variant better, than walk through _M_c and call 'delete' + * (that assume join); following approach remain chance to see size() + * somewhere else, and, may be make some action, because it not block + * on join within lock all the time. + */ _lock.lock(); _M_c.erase( remove_if( _M_c.begin(), _M_c.end(), rm_if_bad_thread() ), _M_c.end() ); while ( !_M_c.empty() ) { + // cerr << "### " << _supercount << " " << _M_c.size() << " " << my_thr_cnt << endl; _lock.unlock(); xmt::delay( xmt::timespec(0,50000000) ); _lock.lock(); _M_c.erase( remove_if( _M_c.begin(), _M_c.end(), rm_if_bad_thread() ), _M_c.end() ); - // cerr << "### " << _supercount << " " << _M_c.size() << endl; } // _supercount = 0; _lock.unlock(); @@ -100,6 +123,8 @@ { Locker lk( _lock ); _M_c.erase( remove_if( _M_c.begin(), _M_c.end(), rm_if_bad_thread() ), _M_c.end() ); + // Thread *t = new Thread( entrance, p, psz, flags, stack_sz ); + // cerr << (void *)t << " created\n"; _M_c.push_back( new Thread( entrance, p, psz, flags, stack_sz ) ); // ++_supercount; } @@ -111,7 +136,7 @@ _M_c.erase( remove_if( _M_c.begin(), _M_c.end(), rm_if_bad_thread() ), _M_c.end() ); } -ThreadMgr::container_type::size_type ThreadMgr::size() +ThreadMgr::container_type::size_type ThreadMgr::size() const { Locker lk( _lock ); // ThreadMgr::container_type::size_type sz = count_if( _M_c.begin(), _M_c.end(), good_thread() ); Modified: trunk/complement/explore/lib/mt/xmt.cc =================================================================== --- trunk/complement/explore/lib/mt/xmt.cc 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/lib/mt/xmt.cc 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/01 19:35:59 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 21:34:56 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -230,7 +230,6 @@ int Thread::_idx = 0; int Thread::_self_idx = 0; Mutex Thread::_idx_lock; -Mutex Thread::_start_lock; #ifdef __FIT_WIN32THREADS const Thread::thread_id_type Thread::bad_thread_id = INVALID_HANDLE_VALUE; @@ -350,7 +349,7 @@ __FIT_DECLSPEC Thread::Thread( unsigned __f ) : _id( bad_thread_id ), - _state( badbit ), + _rip_id( bad_thread_id ), _entrance( 0 ), _param( 0 ), _param_sz( 0 ), @@ -364,7 +363,7 @@ __FIT_DECLSPEC Thread::Thread( Thread::entrance_type entrance, const void *p, size_t psz, unsigned __f, size_t stack_sz ) : _id( bad_thread_id ), - _state( badbit ), + _rip_id( bad_thread_id ), _entrance( entrance ), _param( 0 ), _param_sz( 0 ), @@ -373,6 +372,7 @@ uw_alloc_size( 0 ) { new( Init_buf ) Init(); + // Locker lk( _llock ); _create( p, psz ); } @@ -380,6 +380,14 @@ Thread::~Thread() { Thread::join(); + + if ( (_flags & (daemon | detached)) != 0 ) { // not joinable + // Locker lk( _llock ); + if ( _id != bad_thread_id ) { // still run? + cerr << "Crash on daemon thread exit expected, threas id " << _id << endl; + } + } + ((Init *)Init_buf)->~Init(); // _STLP_ASSERT( _id == bad_thread_id ); @@ -390,14 +398,15 @@ __FIT_DECLSPEC bool Thread::is_self() { + // Locker lk( _llock ); #ifdef _PTHREADS - return good() && (_id == pthread_self()); + return (_id != bad_thread_id) && (_id == pthread_self()); #elif defined(__FIT_UITHREADS) - return good() && (_id == thr_self()); + return (_id != bad_thread_id) && (_id == thr_self()); #elif defined(__FIT_NOVELL_THREADS) - return good() && (_id == GetThreadID()); + return (_id != bad_thread_id) && (_id == GetThreadID()); #elif defined(__FIT_WIN32THREADS) - return good() && (_id == GetCurrentThread()); + return (_id != bad_thread_id) && (_id == GetCurrentThread()); #else # error "Fix me! (replace pthread_self())" #endif @@ -406,8 +415,9 @@ __FIT_DECLSPEC void Thread::launch( entrance_type entrance, const void *p, size_t psz, size_t stack_sz ) { + // Locker lk( _llock ); _stack_sz = stack_sz; - if ( _id == bad_thread_id ) { + if ( _not_run() ) { _entrance = entrance; _create( p, psz ); } @@ -420,31 +430,34 @@ #ifdef __FIT_WIN32THREADS rt.iword = 0; - if ( _id != bad_thread_id ) { + if ( !_not_run() ) { WaitForSingleObject( _id, -1 ); GetExitCodeThread( _id, &rt.iword ); CloseHandle( _id ); + // Locker lk( _llock ); _id = bad_thread_id; } #endif // __FIT_WIN32THREADS #if defined(__FIT_UITHREADS) || defined(_PTHREADS) rt.pword = 0; - if ( _id != bad_thread_id && (_flags & (daemon | detached) ) == 0 ) { + if ( is_join_req() ) { # ifdef _PTHREADS - pthread_join( _id, &rt.pword ); + pthread_join( _rip_id, &rt.pword ); # endif # ifdef __FIT_UITHREADS - thr_join( _id, 0, &rt.pword ); + thr_join( _rip_id, 0, &rt.pword ); # endif - _id = bad_thread_id; + // Locker lk( _llock ); + _rip_id = bad_thread_id; } #endif // __FIT_UITHREADS || PTHREADS #ifdef __FIT_NOVELL_THREADS rt.iword = 0; - if ( _id != bad_thread_id ) { + if ( !_not_run() ) { _thr_join.wait(); - _id = bad_thread_id; + // Locker lk( _llock ); + _rip_id = bad_thread_id; } #endif // __FIT_NOVELL_THREADS @@ -454,7 +467,8 @@ __FIT_DECLSPEC int Thread::suspend() { - if ( _id != bad_thread_id ) { + if ( good() ) { + // to do: fix possible race with _id, when it used here #ifdef __FIT_WIN32THREADS return SuspendThread( _id ); #endif @@ -484,7 +498,8 @@ __FIT_DECLSPEC int Thread::resume() { - if ( _id != bad_thread_id ) { + if ( good() ) { + // to do: fix possible race with _id, when it used here #ifdef __FIT_WIN32THREADS return ResumeThread( _id ); #endif @@ -514,6 +529,8 @@ __FIT_DECLSPEC int Thread::kill( int sig ) { + // Locker lk( _llock ); + if ( _id != bad_thread_id ) { #ifdef __FIT_UITHREADS return thr_kill( _id, sig ); @@ -576,9 +593,11 @@ Thread *me = reinterpret_cast<Thread *>(*reinterpret_cast<void **>(user_words)); // _STLP_ASSERT( me->is_self() ); - me->_state = badbit; // follow part of _call if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected + // Locker lk( me->_llock ); // !!!!??? in the signal handler? + me->_rip_id = me->_id = bad_thread_id; + } else { me->_id = bad_thread_id; } me->_dealloc_uw(); // clear user words @@ -750,38 +769,33 @@ // pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); // pthread_attr_setschedpolicy(&attr,SCHED_OTHER); } - // _start_lock.lock(); // allow finish new thread creation before this - // thread will start to run err = pthread_create( &_id, _flags != 0 || _stack_sz != 0 ? &attr : 0, _xcall, this ); - if ( err == 0 ) { - _state = goodbit; + if ( err != 0 ) { + _rip_id = _id = bad_thread_id; + } else { + _rip_id = _id; } - // _start_lock.unlock(); if ( _flags != 0 || _stack_sz != 0 ) { pthread_attr_destroy( &attr ); } #endif #ifdef __FIT_UITHREADS - // _start_lock.lock(); err = thr_create( 0, 0, _xcall, this, _flags, &_id ); - // _start_lock.unlock(); #endif #ifdef __FIT_WIN32THREADS - // _start_lock.lock(); - _id = CreateThread( 0, 0, _xcall, this, (_flags & suspended), &_thr_id ); + _rip_id = _id = CreateThread( 0, 0, _xcall, this, (_flags & suspended), &_thr_id ); err = GetLastError(); - // _start_lock.unlock(); #endif #ifdef __FIT_NOVELL_THREADS - // _start_lock.lock(); _id = BeginThread( _xcall, 0, 65536, this ); if ( _id == bad_thread_id ) { err = errno; // not ::errno, due to #define errno *__get_errno_ptr() if ( (_flags & detached) == 0 ) { _thr_join.signal(); } + } else { + _rip_id = _id; } - // _start_lock.unlock(); #endif if ( err != 0 ) { @@ -821,9 +835,7 @@ void *Thread::_call( void *p ) { - // _start_lock.lock(); // allow finish thread creation in parent thread Thread *me = static_cast<Thread *>(p); - // me->_state = goodbit; // After exit of me->_entrance, there is may be no more *me itself, // so it's members may be unaccessible. Don't use me->"*" after call @@ -854,29 +866,37 @@ // In most cases for Linux there are problems with signals processing, // so I don't set it default more // signal_handler( SIGTERM, signal_exit ); // set handler for sanity - // _start_lock.unlock(); try { ret = me->_entrance( _param ); - me->_state = badbit; + // I should make me->_id = bad_thread_id; here... // This is in conflict what I say in the begin of this function. // So don't delete Thread before it termination! if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected + // Locker lk( me->_llock ); #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif me->_id = bad_thread_id; + me->_rip_id = bad_thread_id; + } else { + // Locker lk( me->_llock ); + me->_id = bad_thread_id; } me->_dealloc_uw(); // free user words } catch ( std::exception& e ) { - me->_state = badbit; if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected + // Locker lk( me->_llock ); #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif me->_id = bad_thread_id; + me->_rip_id = bad_thread_id; + } else { + // Locker lk( me->_llock ); + me->_id = bad_thread_id; } me->_dealloc_uw(); // free user words #ifndef _WIN32 @@ -885,13 +905,18 @@ ret.iword = -1; } catch ( int sig ) { - me->_state = badbit; if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected + // Locker lk( me->_llock ); #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif me->_id = bad_thread_id; + me->_rip_id = bad_thread_id; + } else { + // Locker lk( me->_llock ); + me->_id = bad_thread_id; } + me->_dealloc_uw(); // free user words // const char *_sig_ = strsignal( sig ); #ifndef _WIN32 @@ -900,12 +925,16 @@ ret.iword = sig; } catch ( ... ) { - me->_state = badbit; if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected + // Locker lk( me->_llock ); #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif me->_id = bad_thread_id; + me->_rip_id = bad_thread_id; + } else { + // Locker lk( me->_llock ); + me->_id = bad_thread_id; } me->_dealloc_uw(); // free user words #ifndef _WIN32 Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/29 15:35:05 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 20:53:03 ptr> /* * Copyright (c) 2006 @@ -14,6 +14,7 @@ #include <mt/xmt.h> #include <mt/shm.h> +#include <mt/thr_mgr.h> #include <sys/shm.h> #include <sys/wait.h> @@ -422,3 +423,38 @@ BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); } } + + +static int my_thr_cnt = 0; +static xmt::Mutex lock; + +xmt::Thread::ret_code thread_mgr_entry_call( void * ) +{ + lock.lock(); + ++my_thr_cnt; + lock.unlock(); + + xmt::Thread::ret_code rt; + rt.iword = 0; + + lock.lock(); + --my_thr_cnt; + lock.unlock(); + + return rt; +} + +void mt_test::thr_mgr() +{ + xmt::ThreadMgr mgr; + + for ( int i = 0; i < 200; ++i ) { + mgr.launch( thread_mgr_entry_call, (void *)this, 0, 0, 0 ); + } + + // cerr << "Join!\n"; + mgr.join(); + + BOOST_CHECK( my_thr_cnt == 0 ); + BOOST_CHECK( mgr.size() == 0 ); +} Modified: trunk/complement/explore/test/mt/mt_test.h =================================================================== --- trunk/complement/explore/test/mt/mt_test.h 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/test/mt/mt_test.h 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/29 13:49:41 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 16:45:13 ptr> /* * Copyright (c) 2006 @@ -19,6 +19,7 @@ void shm_alloc(); void fork_shm(); void shm_named_obj(); + void thr_mgr(); }; #endif // __MT_TEST_H Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-01 17:24:46 UTC (rev 1503) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-02 18:54:52 UTC (rev 1504) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/01/31 23:51:46 ptr> +// -*- C++ -*- Time-stamp: <07/02/02 17:15:47 ptr> /* * Copyright (c) 2006, 2007 @@ -25,6 +25,8 @@ test_case *fork_shm_tc = BOOST_CLASS_TEST_CASE( &mt_test::fork_shm, instance ); test_case *shm_nm_obj_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_named_obj, instance ); + test_case *thr_mgr_tc = BOOST_CLASS_TEST_CASE( &mt_test::thr_mgr, instance ); + pid_tc->depends_on( fork_tc ); shm_alloc_tc->depends_on( shm_segment_tc ); fork_shm_tc->depends_on( shm_alloc_tc ); @@ -36,4 +38,6 @@ add( shm_alloc_tc ); add( fork_shm_tc, 0, 5 ); add( shm_nm_obj_tc, 0, 5 ); + + add( thr_mgr_tc ); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |