Changeset 6030


Ignore:
Timestamp:
Mar 12, 2007, 11:05:16 AM (13 years ago)
Author:
gb
Message:

Simplify interrupt_handler() a little.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/x86-exceptions.c

    r6025 r6030  
    10771077  TCR *tcr = get_interrupt_tcr(false);
    10781078  if (tcr) {
    1079     if (TCR_INTERRUPT_LEVEL(tcr) < 0) {
     1079    if ((TCR_INTERRUPT_LEVEL(tcr) < 0) ||
     1080        (tcr->valence != TCR_STATE_LISP) ||
     1081        (tcr->unwinding != 0)) {
    10801082      tcr->interrupt_pending = (1L << (nbits_in_word - 1L));
    10811083    } else {
     
    10851087          (header_subtag(header_of(cmain)) == subtag_macptr)) {
    10861088        /*
    1087            This thread can (allegedly) take an interrupt now.
    1088            It's tricky to do that if we're executing
    1089            foreign code (especially Linuxthreads code, much
    1090            of which isn't reentrant.)
    1091            If we're unwinding the stack, we also want to defer
    1092            the interrupt.
    1093         */
    1094         if ((tcr->valence != TCR_STATE_LISP) ||
    1095             (tcr->unwinding != 0)) {
    1096           tcr->interrupt_pending = (1L << (nbits_in_word - 1L));
    1097         } else {
    1098           xframe_list xframe_link;
    1099           int old_valence;
    1100           signed_natural alloc_displacement = 0;
    1101           LispObj
    1102             *next_tsp = tcr->next_tsp,
    1103             *save_tsp = tcr->save_tsp,
    1104             *p,
    1105             q;
     1089           This thread can (allegedly) take an interrupt now.
     1090        */
     1091
     1092        xframe_list xframe_link;
     1093        int old_valence;
     1094        signed_natural alloc_displacement = 0;
     1095        LispObj
     1096          *next_tsp = tcr->next_tsp,
     1097          *save_tsp = tcr->save_tsp,
     1098          *p,
     1099          q;
    11061100           
    1107           if (next_tsp != save_tsp) {
    1108             tcr->next_tsp = save_tsp;
    1109           } else {
    1110             next_tsp = NULL;
     1101        if (next_tsp != save_tsp) {
     1102          tcr->next_tsp = save_tsp;
     1103        } else {
     1104          next_tsp = NULL;
     1105        }
     1106        /* have to do this before allowing interrupts */
     1107        pc_luser_xp(context, tcr, &alloc_displacement);
     1108        old_valence = prepare_to_wait_for_exception_lock(tcr, context);
     1109        wait_for_exception_lock_in_handler(tcr, context, &xframe_link);
     1110        handle_exception(signum, info, context, tcr);
     1111        if (alloc_displacement) {
     1112          fprintf(stderr, "tcr = 0x%x, allocptr = 0x%lx, disp = %d\n",tcr,tcr->save_allocptr,alloc_displacement);
     1113          tcr->save_allocptr -= alloc_displacement;
     1114        }
     1115        if (next_tsp) {
     1116          tcr->next_tsp = next_tsp;
     1117          p = next_tsp;
     1118          while (p != save_tsp) {
     1119            *p++ = 0;
    11111120          }
    1112           pc_luser_xp(context, tcr, &alloc_displacement);
    1113           old_valence = prepare_to_wait_for_exception_lock(tcr, context);
    1114           wait_for_exception_lock_in_handler(tcr, context, &xframe_link);
    1115           handle_exception(signum, info, context, tcr);
    1116           if (alloc_displacement) {
    1117             tcr->save_allocptr -= alloc_displacement;
    1118           }
    1119           if (next_tsp) {
    1120             tcr->next_tsp = next_tsp;
    1121             p = next_tsp;
    1122             while (p != save_tsp) {
    1123               *p++ = 0;
    1124             }
    1125             q = (LispObj)save_tsp;
    1126             *next_tsp = q;
    1127           }
    1128           unlock_exception_lock_in_handler(tcr);
    1129           exit_signal_handler(tcr, old_valence);
    1130         }
     1121          q = (LispObj)save_tsp;
     1122          *next_tsp = q;
     1123        }
     1124        unlock_exception_lock_in_handler(tcr);
     1125        exit_signal_handler(tcr, old_valence);
    11311126      }
    11321127    }
Note: See TracChangeset for help on using the changeset viewer.