From 6d7f4089e1e8b2207df85ffd76b1cee9400292a7 Mon Sep 17 00:00:00 2001 From: yjqww6 Date: Sat, 11 Jun 2016 00:49:25 +0800 Subject: [PATCH 1/2] fix thread blocked by expeditor original commit: fa7516efa7bee58b2a7307e504ed97fc3bc69731 --- c/expeditor.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/c/expeditor.c b/c/expeditor.c index d04c79a977..556847d52b 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -95,8 +95,19 @@ static ptr s_ee_read_char(IBOOL blockp) { S_LastErrorString()); if (NumberOfEvents == 0) return Sfalse; } - - if (!ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead)) + +#ifdef PTHREADS + ptr tc = get_thread_context(); + deactivate_thread(tc); +#endif + + BOOL succ = ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead); + +#ifdef PTHREADS + reactivate_thread(tc); +#endif + + if (!succ) S_error1("expeditor", "error getting console info: ~a", S_LastErrorString()); From 6fd5cb7fddf19fb8ba339499d3aa46bf2c404fd2 Mon Sep 17 00:00:00 2001 From: yjqww6 Date: Tue, 14 Jun 2016 20:35:27 +0800 Subject: [PATCH 2/2] modification on previous commit for blocking in expeditor original commit: 02844bee98871bf03cf435441ba23556ad4fc6aa --- LOG | 2 ++ c/expeditor.c | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/LOG b/LOG index 51a95a0e07..0a06e5f824 100644 --- a/LOG +++ b/LOG @@ -200,3 +200,5 @@ release_notes.stex - fixed spelling of non-existent s/syntax.ss +- fixed unnessesary blocking in expeditor on Windows. + c/expeditor.c diff --git a/c/expeditor.c b/c/expeditor.c index 556847d52b..c93d29acc8 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -73,6 +73,10 @@ static IBOOL s_ee_init_term(void) { static ptr s_ee_read_char(IBOOL blockp) { DWORD cNumRead; INPUT_RECORD irInBuf[1]; +#ifdef PTHREADS + ptr tc; +#endif /* PTHREADS */ + BOOL succ; static char buf[10]; static int bufidx = 0; static int buflen = 0; @@ -97,15 +101,18 @@ static ptr s_ee_read_char(IBOOL blockp) { } #ifdef PTHREADS - ptr tc = get_thread_context(); - deactivate_thread(tc); -#endif + tc = get_thread_context(); + if (DISABLECOUNT(tc) == FIX(0)) { + deactivate_thread(tc); + succ = ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead); + reactivate_thread(tc); + } else { + succ = ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead); + } +#else /* PTHREADS */ + succ = ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead); +#endif /* PTHREADS */ - BOOL succ = ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead); - -#ifdef PTHREADS - reactivate_thread(tc); -#endif if (!succ) S_error1("expeditor", "error getting console info: ~a",