Browse Source

remove unneeded allocator locks

During the creation of a new raw block, it is unnecessary to lock globally the
tls_allocator, since no other new allocation can happen in parallel. Likewise,
it is unnecessary to lock the raw block while creating, since there cannot be
any free call for this particular raw block.
Ioannis Koutras 11 years ago
parent
commit
8ac1cf5852
2 changed files with 0 additions and 8 deletions
  1. 0 4
      src/malloc.c
  2. 0 4
      src/memalign.c

+ 0 - 4
src/malloc.c

@@ -106,16 +106,12 @@ void * malloc(size_t size) {
 
 
             new_raw_block = create_raw_block(sys_alloc_size, DEFAULT_RB_TYPE);
             new_raw_block = create_raw_block(sys_alloc_size, DEFAULT_RB_TYPE);
             if(new_raw_block != NULL) {
             if(new_raw_block != NULL) {
-                LOCK_GLOBAL();
-                LOCK_RAW_BLOCK(new_raw_block);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, new_raw_block,
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, new_raw_block,
                         pointers);
                         pointers);
-                UNLOCK_GLOBAL();
 
 
                 encapsulated_rb = (DEFAULT_RB_T *)
                 encapsulated_rb = (DEFAULT_RB_T *)
                     ((uintptr_t) new_raw_block + sizeof(raw_block_header_t));
                     ((uintptr_t) new_raw_block + sizeof(raw_block_header_t));
                 ptr = dmmlib_malloc(encapsulated_rb, size);
                 ptr = dmmlib_malloc(encapsulated_rb, size);
-                UNLOCK_RAW_BLOCK(new_raw_block);
             }
             }
         }
         }
     } else {
     } else {

+ 0 - 4
src/memalign.c

@@ -94,15 +94,11 @@ void *memalign(size_t alignment, size_t size) {
             raw_block = create_raw_block((size_t) SYS_ALLOC_SIZE,
             raw_block = create_raw_block((size_t) SYS_ALLOC_SIZE,
                     DEFAULT_RB_TYPE);
                     DEFAULT_RB_TYPE);
             if(raw_block != NULL) {
             if(raw_block != NULL) {
-                LOCK_GLOBAL();
-                LOCK_RAW_BLOCK(raw_block);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, raw_block, pointers);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, raw_block, pointers);
-                UNLOCK_GLOBAL();
 
 
                 encapsulated_rb = (DEFAULT_RB_T *)
                 encapsulated_rb = (DEFAULT_RB_T *)
                     ((uintptr_t) raw_block + sizeof(raw_block_header_t));
                     ((uintptr_t) raw_block + sizeof(raw_block_header_t));
                 memptr = freelist_memalign(encapsulated_rb, alignment, size);
                 memptr = freelist_memalign(encapsulated_rb, alignment, size);
-                UNLOCK_RAW_BLOCK(raw_block);
             }
             }
         }
         }
     } else { /* A big block has to be created */
     } else { /* A big block has to be created */