From: "Alberto Chessa" Newsgroups: comp.os.msdos.djgpp Subject: signal & seitimer Date: 15 Apr 1999 10:16:48 GMT Organization: TIN Lines: 53 Message-ID: <01be8729$2599d500$92c809c0@chessa> NNTP-Posting-Host: a-mi53-9.tin.it X-Newsreader: Microsoft Internet News 4.70.1161 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello, I'm writing a simple multi-threading C++ library and I'm trying to use alarm/setitimer for preemptive rescheduing. It works only with "big" interval timer value (>1sec). Lower values works for the first 1/4 timeout expirations (depending on interval timer value - 10..90ms), then it simple stop to call the signal handler (but the program - the last thread - still running - the resched counter stop). The basic scheme is as follows: static volatile int resched; void Handler(int s) { resched++; setsignal(SIGALRM, Handler); // It's really required ? if (!rescheduling) Reschedule(); // Will swap stacks else abort(); // Just for debug, but it never fall here! } Setup() { setsignal(SIGALRM, Handler); seitime( 10ms ); // off course, I really feel both it_value and it_interval } I try with two threads: - First: simple write some box on a 800x600x256 SVGA screen (usign my custom driver) - Second: write a prompt (on the graphic screen) and check for user input (kbhit(), then getch()) Note that: - I change the stack point unsed the signal handler - I lock all the critical kernel code (cotext switching, rescheduling routine, signal handler) - I lock all kernel data used by rescheduling routine and signal handler - I'm using DJGPP 2.8.1 - I try under Win95B, both dos-box and command prompt only Thre are problem using setitime/signal on small timeout or I have to look in my program ? The last thread activated is always the second one. It could depend on DOS I/O (kbhit()) ? Thanks in advance -- Alberto Chessa achessa AT fiar DOT finmeccanica DOT it