Browse Source

POSIX mutex for sbrk() should be given to sys_alloc() during allocator's initialization

Ioannis Koutras 13 years ago
parent
commit
aa7cac667b
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/initialize_allocator.c

+ 11 - 0
src/initialize_allocator.c

@@ -134,8 +134,19 @@ void initialize_allocator(allocator_t *allocator) {
      */
     current_heap = &allocator->heaps[0];
 
+#ifdef HAVE_LOCKS
+    /* sys_alloc() is going to use the sbrk() lock, so it needs to be released.
+     */
+    sbrk_unlock();
+#endif /* HAVE_LOCKS */
+
     maptablenode = (maptable_node_t *) sys_alloc(allocator, &allocator->heaps[0], 4*(sizeof(maptable_node_t)));
 
+#ifdef HAVE_LOCKS
+    /* Take back the sbrk() lock */
+    sbrk_lock();
+#endif /* HAVE_LOCKS */
+
     maptablenode->size = 32;
     maptablenode->fixed_list_head = NULL;
     maptablenode->next = maptablenode+1;