ソースを参照

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 年 前
コミット
8ac1cf5852
共有2 個のファイルを変更した0 個の追加8 個の削除を含む
  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);
             if(new_raw_block != NULL) {
-                LOCK_GLOBAL();
-                LOCK_RAW_BLOCK(new_raw_block);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, new_raw_block,
                         pointers);
-                UNLOCK_GLOBAL();
 
                 encapsulated_rb = (DEFAULT_RB_T *)
                     ((uintptr_t) new_raw_block + sizeof(raw_block_header_t));
                 ptr = dmmlib_malloc(encapsulated_rb, size);
-                UNLOCK_RAW_BLOCK(new_raw_block);
             }
         }
     } 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,
                     DEFAULT_RB_TYPE);
             if(raw_block != NULL) {
-                LOCK_GLOBAL();
-                LOCK_RAW_BLOCK(raw_block);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, raw_block, pointers);
-                UNLOCK_GLOBAL();
 
                 encapsulated_rb = (DEFAULT_RB_T *)
                     ((uintptr_t) raw_block + sizeof(raw_block_header_t));
                 memptr = freelist_memalign(encapsulated_rb, alignment, size);
-                UNLOCK_RAW_BLOCK(raw_block);
             }
         }
     } else { /* A big block has to be created */