Ignore:
Timestamp:
Jan 5, 2009, 11:32:42 AM (11 years ago)
Author:
gb
Message:

Hold TCR_AREA_LOCK when calling pthread_create(), to avoid Darwin lossage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r11574 r11581  
    17731773  pthread_attr_t attr;
    17741774  pthread_t returned_thread = (pthread_t) 0;
     1775  TCR *current = get_tcr(true);
    17751776
    17761777  pthread_attr_init(&attr);
     
    17951796  /*
    17961797     I think that's just about enough ... create the thread.
     1798     Well ... not quite enough.  In Leopard (at least), many
     1799     pthread routines grab an internal spinlock when validating
     1800     their arguments.  If we suspend a thread that owns this
     1801     spinlock, we deadlock.  We can't in general keep that
     1802     from happening: if arbitrary C code is suspended while
     1803     it owns the spinlock, we still deadlock.  It seems that
     1804     the best that we can do is to keep -this- code from
     1805     getting suspended (by grabbing TCR_AREA_LOCK)
    17971806  */
     1807  LOCK(lisp_global(TCR_AREA_LOCK),current);
    17981808  pthread_create(&returned_thread, &attr, start_routine, param);
     1809  UNLOCK(lisp_global(TCR_AREA_LOCK),current);
    17991810  pthread_attr_destroy(&attr);
    18001811  return (LispObj) ptr_to_lispobj(returned_thread);
Note: See TracChangeset for help on using the changeset viewer.