From: Sengan DOT Short AT durham DOT ac DOT uk Message-Id: <27352.9607231848@ws-ai5.dur.ac.uk> Subject: Re: Multithread question To: salvador AT inti DOT edu DOT ar (Salvador Eduardo Tropea) Date: Tue, 23 Jul 1996 19:48:28 +0100 (BST) Cc: djgpp AT delorie DOT com In-Reply-To: <9607231343.aa19011@ailin.inti.edu.ar> from "Salvador Eduardo Tropea" at Jul 23, 96 01:43:31 pm Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > Topic: Multithreads, specially the LWP package: > > First the package is good, but like all the new things (fruits ;) is green. > I found 2 mayor problems in the package: > > 1) The Test program asumes 2 things: > a) printf is reentrant. Yes I'm aware of this, and am trying out a class solution at first. I think a good solution would need to recode some of the libc. Two possibilities there: * mess around with flags, which is cheap and cheerful, but not necessarily efficient * try to make libc moderately re-entrant: a transfer buffer per process, etc. The class system should provide a generic work-around for all non reentrant functions (and there will be quite a few in people's legacy code). Then we can have a look at libc. Clearly, if anything got to the heady heights of being approved by the inner cabal (DJ, Charles, and any unnamed ones) it might reach standard libc. > b) DOS is reentrant. For DOS there is no problem, as far as I know: The interrupt makes a signal. This is done by changing the SS and DS segment size to cause a fault when they are used by the protected mode program. BUT: that is under PROTECTED MODE, and since you switch to real mode for DOS, there are no problems for DOS. > 2) The kill doesn't kill anybody, or worst kills the program. I think you are wrong there. The kill is bugged, but that's something different. I've tracked down the bug so it works. However I think it illustrates an intrisic problem with malloc and DS. > 1) Please somebody correct me if I'm wrong but: > If the 1KHz interrupt (used for task switching) arrives when DOS is printing > (or writing to disk or wherever) the DPMI server reflects the IRQ to the > protected mode, then the program makes a task switch and if the new task > calls to DOS again the result is unpredictable. Yes, but see above. > This seems to be NOT enough, I don't see the code of printf but seems that > printf isn't reentrant. When I run the test some times work and some times > doesn't work. Yes. That's the cause. There's a really subtle bug that makes it work on the first releases :-). Oh, btw, if you wonder why I'm working on this too, it's because I really liked Josh's package, so decided to work on it. We are cooperating on it, to pool resources, knowledge, and so on. I hope we can produce something really useful, as we both need it! See ya! Sengan