www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/06/14/07:35:13

Date: Sun, 14 Jun 1998 14:32:54 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: __dpmi_yield: a replacement
Message-ID: <Pine.SUN.3.91.980614143038.6294e-100000@is>
MIME-Version: 1.0

Here's a replacement for the __dpmi_yield function which should work 
around the bug in some versions of Windows 95:

*** src/libc/dpmi/api/2f_1680.S	Sun Mar 12 03:08:58 1995
--- /dev/null	Sat Jun 13 20:25:35 1998
***************
*** 1,9 ****
- /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
- #include <libc/asmdefs.h>
- 
- 	FUNC(___dpmi_yield)
- 
- 	movw	$0x1680, %ax
- 	int	$0x2f
- 
- 	ret
--- 0 ----
*** /dev/nul	Sat Jun 13 20:26:01 1998
--- src/libc/dpmi/api/2f_1680.c	Mon Jun  8 07:54:12 1998
***************
*** 0 ****
--- 1,14 ----
+ #include <errno.h>
+ #include <dpmi.h>
+ 
+ void
+ __dpmi_yield(void)
+ {
+   __dpmi_regs r;
+ 
+   r.x.ax = 0x1680;
+   r.x.ss = r.x.sp = r.x.flags = 0;
+   __dpmi_simulate_real_mode_interrupt (0x2f, &r);
+   if (r.h.al == 0x80)
+     errno = ENOSYS;
+ }
*** src/libc/dpmi/api/makefile.~0	Sun Dec 24 03:45:36 1995
--- src/libc/dpmi/api/makefile	Sat Jun 13 20:11:56 1998
***************
*** 1,7 ****
  # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
  TOP=../..
  
! SRC += 2f_1680.S
  SRC += d0000.S
  SRC += d0001.S
  SRC += d0002.S
--- 1,7 ----
  # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
  TOP=../..
  
! SRC += 2f_1680.c
  SRC += d0000.S
  SRC += d0001.S
  SRC += d0002.S
*** src/libc/dpmi/api/2f_1680.t~0	Mon Jul 10 05:40:42 1995
--- src/libc/dpmi/api/2f_1680.txh	Sat Jun 13 20:22:34 1998
***************
*** 9,23 ****
  
  @subheading Description
  
! Please refer to @ref{DPMI Specification} for details on DPMI
! function call operation.  Also see @ref{DPMI Overview} for general
! information.
  
! INT 0x2f, AX = 0x1680
! 
! This function yields the CPU to the next process.  This should be
! called in busy-wait loops.
  
  @subheading Return Value
  
! None.
--- 9,25 ----
  
  @subheading Description
  
! @code{__dpmi_yield} calls function 1680h of the interrupt 2Fh, which
! tells the task manager in a multitasking environment that the calling
! program doesn't need the rest of its time slice.  The task manager will
! then preempt the calling program and switch to another task that is
! ready to run.
  
! This function should be called in busy-wait loops, like when a program
! waits for user input via keyboard, after it finds the keyboard buffer
! empty, to enhance overall performance in a multitasking environment.
  
  @subheading Return Value
  
! None.  If the call isn't supported by the environment, like when running
! on plain DOS, @code{errno} is set to @code{ENOSYS}.
*** src/docs/kb/wc202.~13	Fri May 29 19:30:26 1998
--- src/docs/kb/wc202.txi	Sat Jun 13 20:24:42 1998
***************
*** 395,397 ****
--- 395,401 ----
  @code{fflush} now conforms to ANSI C standard when called with a
  @code{NULL} argument.
  @findex fflush
+ 
+ @code{__dpmi_yield} doesn't wedge the DOS box on some versions of
+ Windows 9X anymore.
+ @findex __dpmi_yield

- Raw text -


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