From: "Yury A. Zaitsev" Newsgroups: comp.os.msdos.djgpp Subject: Re: __djgpp_map_physical_memory - some questions Date: Wed, 13 Jun 2001 18:55:15 +0300 Organization: Apex NCC Public InterNet News Server Lines: 73 Message-ID: <3d28g9.fqi.ln@nix-if1> References: NNTP-Posting-Host: dialup83.apex.dp.ua X-Trace: main.apex.dp.ua 992473599 83209 195.24.139.83 (13 Jun 2001 23:06:39 GMT) X-Complaints-To: abuse AT apex DOT dp DOT ua NNTP-Posting-Date: 13 Jun 2001 23:06:39 GMT User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (Linux/2.2.19 (i686)) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Tue, 12 Jun 2001, Eli Zaretskii wrote: >> >> But IMHO djgpp works better under windoze dos session, not under >> >> dosemu :(, isn't it? >> EZ> I wasn't thinking about DOSEmu. >> So, Win9x DOS box is the best environment for DJGPP, isn't it? EZ> It depends. For some uses, plain DOS with CWSDPMI is better. Which DOS is better? Is it MS-DOS, PC-DOS, some other DOS? >> >> I has been forced to use clock() (which works fast) instead of >> >> time() because I need to call it many times... >> EZ> Why do you need to call `time' many times? It's unusual that a >> EZ> program should need that. >> Do you know a _portable_ way to check timeouts? Time() (or >> gettimeofday()) is portable and fast (under Linux, for example ;). So, >> program looks like this: >> -------------------------------------------------- >> while (!timeout()) { >> if (do_a_piece_of_work()==SUCCESS) break; >> } >> -------------------------------------------------- EZ> If timeouts are the issue, you could use `alarm' or `setitimer' for a EZ> much better and more portable code. No, I can't use setitimer() with djgpp because setitimer() uses uclock() which doesn't works properly under win9x, when program is in background mode. Also I can't use alarm() because it uses setitimer()... :) I've writed simple test for this: ----------- cat timer-ex.cc ------------- #include #include #include #include struct itimerval tv; static int value=0; void sighandler(int sig) { value++; } int main () { cout << "--------------\n"; clock_t start=clock(); signal(SIGALRM,sighandler); tv.it_interval.tv_sec = 0; tv.it_interval.tv_usec = 100000; tv.it_value.tv_sec = 0; tv.it_value.tv_usec = 1; setitimer (ITIMER_REAL, &tv, 0); do_some_work_during_20_seconds(); cout << "value: " << value << "\n"; cout << "real time: " << 1.*(clock()-start)/CLOCKS_PER_SEC << "\n"; return 0; } ----------------------------------------- gxx -O2 timer-ex.cc -o timer-ex.exe ----------------------------------------- In foreground mode it prints: value: 200 real time: 19.84 In background: value: 12 real time: 19.84 ----------------------------------------- djdev-2.03/win95osr2 There were no CPU hogs :)