www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/07/22:29:21

Date: Fri, 8 Mar 1996 05:48:48 +0800 (GMT+0800)
From: "Orlando A. Andico" <orly AT natalie DOT eee DOT upd DOT edu DOT ph>
To: Holger Vogelsang <vogelsan AT i50s20 DOT ira DOT uka DOT de>
cc: DJGPP Mailing List <djgpp AT delorie DOT com>
Subject: Re: Multi-threads?
In-Reply-To: <4h6doc$n69@nz12.rz.uni-karlsruhe.de>
Message-ID: <Pine.LNX.3.91.960308053430.108B-100000@natalie.eee.upd.edu.ph>
MIME-Version: 1.0

On 1 Mar 1996, Holger Vogelsang wrote:

> Here is very simple solution for two processes, using longjmp,
> setjmp for task switching (without preemption).#include <stdio.h>
> 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.
<snip>

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
                                             ------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019