From fa5647ab331560f8ce4674e51a10b60ebc54adbf Mon Sep 17 00:00:00 2001
From: Ulrich Weigand <weigand@informatik.uni-erlangen.de>
Date: Mon, 17 Jan 2000 22:21:29 +0000
Subject: [PATCH] Fixed race between Win16 parent and child for first
 rescheduling of child process. This fixes WinExec returning too early.

---
 loader/task.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/loader/task.c b/loader/task.c
index 118696bf38f..69bdc8c4626 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -228,8 +228,11 @@ void TASK_CallToStart(void)
     SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
     CONTEXT86 context;
 
-    /* Add task to 16-bit scheduler pool */
-    TASK_Reschedule();
+    SYSLEVEL_EnterWin16Lock();
+
+    /* Add task to 16-bit scheduler pool if necessary */
+    if ( hCurrentTask != GetCurrentTask() )
+        TASK_Reschedule();
 
     /* Registers at initialization must be:
      * ax   zero