Changeset 13455


Ignore:
Timestamp:
Feb 22, 2010, 6:43:56 PM (9 years ago)
Author:
rme
Message:

In count_cpus(): we can use sysconf(_SC_NPROCESSORS_ONLN) on Mac OS X
now that we require at least Mac OS X 10.5.

In create_system_thread():

  • Mac OS X 10.5 has pthread_attr_setstack()
  • use return value from pthread_create() to determine success
File:
1 edited

Legend:

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

    r13434 r13455  
    16101610count_cpus()
    16111611{
    1612 #ifdef DARWIN
    1613   /* As of OSX 10.4, Darwin doesn't define _SC_NPROCESSORS_ONLN */
    1614 #include <mach/host_info.h>
    1615 
    1616   struct host_basic_info info;
    1617   mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
    1618  
    1619   if (KERN_SUCCESS == host_info(mach_host_self(), HOST_BASIC_INFO,(host_info_t)(&info),&count)) {
    1620     if (info.max_cpus > 1) {
    1621       spin_lock_tries = 1024;
    1622     }
    1623   }
    1624 #else
    16251612  int n = sysconf(_SC_NPROCESSORS_ONLN);
    16261613 
     
    16281615    spin_lock_tries = 1024;
    16291616  }
    1630 #endif
    16311617}
    16321618#endif
     
    18521838#else
    18531839Boolean
    1854 create_system_thread(size_t stack_size,
    1855                      void* stackaddr,
    1856                      void* (*start_routine)(void *),
    1857                      void* param)
     1840create_system_thread(size_t stack_size,  void *stackaddr,
     1841                     void *(*start_routine)(void *), void *param)
    18581842{
    18591843  pthread_attr_t attr;
    1860   pthread_t returned_thread = (pthread_t) 0;
     1844  pthread_t returned_thread;
     1845  int err;
    18611846  TCR *current = get_tcr(true);
    18621847
     
    18711856  if (stackaddr != NULL) {
    18721857    /* Size must have been specified.  Sort of makes sense ... */
    1873 #ifdef DARWIN
    1874     Fatal("no pthread_attr_setsetstack. "," Which end of stack does address refer to?");
    1875 #else
    18761858    pthread_attr_setstack(&attr, stackaddr, stack_size);
    1877 #endif
    18781859  } else if (stack_size != DEFAULT_THREAD_STACK_SIZE) {
    18791860    pthread_attr_setstacksize(&attr,stack_size);
     
    18921873  */
    18931874  LOCK(lisp_global(TCR_AREA_LOCK),current);
    1894   pthread_create(&returned_thread, &attr, start_routine, param);
     1875  err = pthread_create(&returned_thread, &attr, start_routine, param);
    18951876  UNLOCK(lisp_global(TCR_AREA_LOCK),current);
    18961877  pthread_attr_destroy(&attr);
    1897   return (returned_thread != (pthread_t)0);
     1878  return (err == 0);
    18981879}
    18991880#endif
Note: See TracChangeset for help on using the changeset viewer.