Browse Source

Jie Zhang writes:
I think the loop was written for MMU case. When there is MMU, mmap ()
is used to allocate the stack. If one segment is already mapped, we
should continue to see if we can use the next one. However, for NOMMU,
malloc () is used. It's waste of CPU cycles to continue to try if it
fails. Here is a new patch, which makes this change only for NOMMU.

Mike Frysinger 19 năm trước cách đây
mục cha
commit
cff695fb4c
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  1. 8 0
      libpthread/linuxthreads.old/manager.c

+ 8 - 0
libpthread/linuxthreads.old/manager.c

@@ -498,6 +498,14 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
                                  &new_thread, &new_thread_bottom,
                                  &guardaddr, &guardsize) == 0)
         break;
+#ifndef __ARCH_HAS_MMU__
+      else
+        /* When there is MMU, mmap () is used to allocate the stack. If one
+         * segment is already mapped, we should continue to see if we can
+         * use the next one. However, when there is no MMU, malloc () is used.
+         * It's waste of CPU cycles to continue to try if it fails.  */
+        return EAGAIN;
+#endif
     }
   __pthread_handles_num++;
   /* Allocate new thread identifier */