Mail Archives: djgpp/1999/04/15/07:52:04
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
- Raw text -