Date: Mon, 1 May 2000 18:54:16 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: "Alexei A. Frounze" cc: djgpp AT delorie DOT com Subject: Re: 3rd Try: Maybe an asm problem? (Problems linking) In-Reply-To: <390D7DD9.F55A5EF6@mtu-net.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 1 May 2000, Alexei A. Frounze wrote: > Eli Zaretskii wrote: > > On Mon, 1 May 2000, Alexei A. Frounze wrote: > > > But what for? DOS is not a multitasking OS. Windows does all the task/thread > > > switches itself. So what is it needed for? > > > > __dpmi_yield is not for task switching, it's for releasing the current > > time slice allotted by Windows (or any other multi-tasking scheduler). > > Just some kind of a synonym. :) Well, not really. Normally, Windows (or any other multitasker) waits for some period of time before it preempts a program and switches to another one. A call to __dpmi_yield causes Windows to reschedule immediately. > > When an interactive program waits for the user to type something and has > > nothing else to do, it generally should call __dpmi_yield to relinquish > > the CPU to other programs that might be waiting for the CPU. Without > > this call, Windows will not preempt the CPU before its time slice > > expires, and the system might behave is if it is very busy, even though > > the program just waits for input. > > Do you bother about that while you're programming? I.e. do you write a custom > keyboard read function that calls that thing? It depends. If I'm writing a program that is expected to sit idling for long periods of time, then I generally build some kind of an idle loop around `select' or `kbhit' with `__dpmi_yield' in the loop (`select' does that automatically). As an example, look at the DJGPP-specific sources of info.exe, where the keyboard loop is implemented. > How about old DOS programs? Are you sure all they release timeslice? Old DOS programs usually called Int 28h, the DOS Idle Interrupt, while they were waiting for input. This was used by resident software, such as a disk cache, as a signal that it can e.g. flush its buffers. > I bet most of programmers don't bother about that because it's not a thing to > worry too much about. You'd be surprised to know how many people are aware of programs which use up CPU time while idling. There were quite a few threads in this group started by people who payed attention to the CPU usage on their Windows systems and complained when programs like RHIDE (in its old versions) were using the CPU in their idle loop. The loss of CPU time is real: a program that runs in another DOS box will take more time if some idling program doesn't release its slices while doing nothing. So I think programmers do need to pay attention to these issues.