Changeset 9653


Ignore:
Timestamp:
Jun 2, 2008, 6:35:04 AM (11 years ago)
Author:
gb
Message:

windows raise_thread_interrupt: if the interrupted thread is obviously
blocked on input, cancel the pending I/O as best we can. (There are
lots of other things that we might be blocked on, and Windows sucks
too much to offer a general way of cancelling blocking syscalls.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/lisp-kernel/thread_manager.c

    r9557 r9653  
    5959extern void interrupt_handler(int, siginfo_t *, ExceptionInformation *);
    6060
     61BOOL (*pCancelIoEx)(HANDLE, OVERLAPPED*) = NULL;
     62
     63
     64extern void *windows_find_symbol(void*, char*);
     65
    6166int
    6267raise_thread_interrupt(TCR *target)
     
    6974  area *cs = target->cs_area, *ts = target->cs_area;
    7075  DWORD rc;
     76  BOOL io_pending;
    7177
    7278  pcontext = (CONTEXT *)((((natural)&_contextbuf)+15)&~15);
     
    8288    wperror("GetThreadContext");
    8389  }
     90
    8491  where = (pc)(xpPC(pcontext));
    8592 
     
    97104    /* If the thread's in a blocking syscall, it'd be nice to
    98105       get it out of that state here. */
     106    GetThreadIOPendingFlag(hthread,&io_pending);
    99107    target->interrupt_pending = (1LL << (nbits_in_word - 1LL));
    100108    ResumeThread(hthread);
     109    if (io_pending) {
     110      pending_io * pending = (pending_io *) (target->foreign_exception_status);
     111      if (pCancelIoEx) {
     112        pCancelIoEx(pending->h, pending->o);
     113      } else {
     114        CancelIo(pending->h);
     115      }
     116    }
    101117    return 0;
    102118  } else {
     
    104120       so that it calls out and then returns to the context,
    105121       handling any necessary pc-lusering. */
    106     LispObj foreign_rsp = (((LispObj)(target->foreign_sp))-128)&~15;
     122    LispObj foreign_rsp = (((LispObj)(target->foreign_sp))-0x200)&~15;
    107123    CONTEXT *icontext = ((CONTEXT *) foreign_rsp) -1;
    108124    icontext = (CONTEXT *)(((LispObj)icontext)&~15);
     
    11541170#ifdef WINDOWS
    11551171  lisp_global(TCR_KEY) = TlsAlloc();
     1172  pCancelIoEx = windows_find_symbol(NULL, "CancelIoEx");
    11561173#else
    11571174  pthread_key_create((pthread_key_t *)&(lisp_global(TCR_KEY)), shutdown_thread_tcr);
Note: See TracChangeset for help on using the changeset viewer.