Date: Fri, 8 Mar 1996 05:48:48 +0800 (GMT+0800) From: "Orlando A. Andico" To: Holger Vogelsang cc: DJGPP Mailing List Subject: Re: Multi-threads? In-Reply-To: <4h6doc$n69@nz12.rz.uni-karlsruhe.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On 1 Mar 1996, Holger Vogelsang wrote: > Here is very simple solution for two processes, using longjmp, > setjmp for task switching (without preemption).#include > This can be expanded for many processes by modifying the "scheduler" > lwp_switch. This examples works under DJGPP 1.x and DJGPP 2.0. > The stack size for each process is set to 2000 bytes in this example. I thought of a way to make this technique preemptive; that is, the function lwp_switch () is actually set up as a signal handler for SIGALRM or SIGVTALRM, then we use alarm () or setitimer () to "toggle" the function at a regular rate. A couple of questions though: 1) is it possible for an alarm to be delivered in the middle of a library or kernel call? that is, because MS-DOG is nonreentrant. I'm not sure how the signal delivery mechanism works in DJGPP. 2) what is the resolution of the timer in setitimer ()? the timeval structure has a tv_usec field, but exactly what is the effective resolution of this thing? does DJGPP use the 18.2 Hz timer interrupt of DOS, or is it reprogrammed to interrupt at a faster rate? Thanks. ------------------------ Orlando A. Andico oandico AT eee DOT upd DOT edu DOT ph ------------------------