X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fwin32%2FAsyncIO.c;h=5dedee0c70bebb8d728fb7d7b5999526c30b95f3;hb=fff1f6194c3c39de53cd645bda9865fb131b1c68;hp=20de8bb4abd73804d18d4b58dd257be31732c649;hpb=eb5791fe867f6441d270344298678f45ed4a75e4;p=ghc-hetmet.git diff --git a/rts/win32/AsyncIO.c b/rts/win32/AsyncIO.c index 20de8bb..5dedee0 100644 --- a/rts/win32/AsyncIO.c +++ b/rts/win32/AsyncIO.c @@ -12,7 +12,6 @@ #include #include #include "Schedule.h" -#include "RtsFlags.h" #include "Capability.h" #include "win32/AsyncIO.h" #include "win32/IOManager.h" @@ -189,6 +188,7 @@ shutdownAsyncIO(rtsBool wait_threads) CloseHandle(completed_table_sema); completed_table_sema = NULL; } + DeleteCriticalSection(&queue_lock); } /* @@ -274,8 +274,21 @@ start: unsigned int rID = completedTable[i].reqID; prev = NULL; - for(tso = blocked_queue_hd ; tso != END_TSO_QUEUE; prev = tso, tso = tso->link) { + for(tso = blocked_queue_hd ; tso != END_TSO_QUEUE; tso = tso->_link) { + if (tso->what_next == ThreadRelocated) { + /* Drop the TSO from blocked_queue */ + if (prev) { + setTSOLink(&MainCapability, prev, tso->_link); + } else { + blocked_queue_hd = tso->_link; + } + if (blocked_queue_tl == tso) { + blocked_queue_tl = prev ? prev : END_TSO_QUEUE; + } + continue; + } + switch(tso->why_blocked) { case BlockedOnRead: case BlockedOnWrite: @@ -289,17 +302,22 @@ start: /* Drop the matched TSO from blocked_queue */ if (prev) { - prev->link = tso->link; + setTSOLink(&MainCapability, prev, tso->_link); } else { - blocked_queue_hd = tso->link; + blocked_queue_hd = tso->_link; } if (blocked_queue_tl == tso) { blocked_queue_tl = prev ? prev : END_TSO_QUEUE; } /* Terminates the run queue + this inner for-loop. */ - tso->link = END_TSO_QUEUE; + tso->_link = END_TSO_QUEUE; tso->why_blocked = NotBlocked; + // save the StgAsyncIOResult in the + // stg_block_async_info stack frame, because + // the block_info field will be overwritten by + // pushOnRunQueue(). + tso->sp[1] = (W_)tso->block_info.async_result; pushOnRunQueue(&MainCapability, tso); break; } @@ -310,6 +328,8 @@ start: } break; } + + prev = tso; } /* Signal that there's completed table slots available */ if ( !ReleaseSemaphore(completed_table_sema, 1, NULL) ) {