All the files marked with the above copyright fall either under LGPL
(Library General Public
License) or under GPL (General Public License) as stated at the beginning
of each file, with the
following exception, that ALL the people in the THANKS file must receive
credit. The example*.*
files are FREEWARE. You can do whatever you want with them.
All these files are distributed in the hope that they will be useful,
but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License and
of the GNU Library
General Public License along with this program; see the files COPYING
and COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave., Cambridge,
MA 02139, USA.
A couple of months ago, I found on the Net the excellent LWP package
written by Josh Turpen and
Sengan Short. It provided basic services such as starting a new thread,
killing a thread, regulating the
time slice, and so on. But soon I discovered that it didn't provide
any synchronization facility
between the threads it could handle. Thus I decided to add a set of
synchronization
services to it. Anyhow, as I needed a C++ interface for a C++ program
I was (am!) going to
write, I decided to add a complete set of objects to handle not only
synchronization, but also
message posting, readers/writers locks, gates and Thread objects.
So cdid I begin writing this package. It is basically divided in three sections:
lwpasm.S (Capital "S"!): The assembler stuff
lwp.c The "C" part of the business
threads.cc The C++ interface.
Their usage is a sort of top-down: if you need C services, you just
plug in lwp.c and lwpasm.S. If you need C++ services you'll need all three
of them. They are quite small: when I compile them with optimization and
debugging on, the library size is about 85Kbytes. Of course, they run under
GCC.
This version of PDMLWP is much stabler than the last ones: it has never crashed in its current version, which I tested on my 486DX2/50. It doesn't eat up much memory, neither does it eat too many cycles. BUT there is a problem: non reentrant functions. There are lots and lots of them in libc and in the C++ libraries, beginning with raise()/signal(), which means that you cannot use exceptions, for they could be processed by ANY thread. Another example of non-reentrant procs are all the I/O routines, malloc,free,realloc (new and delete are non-reentrant too!). The true solution to this problem would be rewriting all the GCC libraries, but I don't have enough time for such an enormous job. The only, obviously imperfect solution is creating small patch header files that wrap every dangerous call in lwp_thread_disable/enable blocks. These files are lwpconio.h, lwppc.h, lwpstdio.h, lwpstdlib.h.
Mainly, PAY ATTENTION TO WHAT YOU DO! I have tried to shield the thing up as much as I could, isolating operator new, operator delete, malloc, realloc, free, calloc, cfree, but anyhow PAY ATTENTION to non-reentrant routines, and remember THERE ARE MANY!.
The package is still in development, so if you have ideas, suggestions, or just want to say hello, don't hesitate to E-Mail me.