Changeset 416 for trunk/libs
- Timestamp:
- Jan 4, 2018, 10:05:47 AM (7 years ago)
- Location:
- trunk/libs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/malloc.c
r412 r416 107 107 // It uses the mmap( MAP_REMOTE ) syscall to allocate a new vseg mapped in cluster (cxy). 108 108 ////////////////////////////////////////////////////////////////////i////////////////////// 109 // @ cxy : target cluster identifier (fixed format).110 // @ s ize: store size (bytes).109 // @ cxy : target cluster identifier (fixed format). 110 // @ store_size : store size (bytes). 111 111 // # return without setting the initialized field in store(cxy) if failure. 112 112 ////////////////////////////////////////////////////////////////////i////////////////////// … … 185 185 } 186 186 187 // reset the alloc_size array 187 // DEPRECATED: we don't reset the alloc_size array 188 // because we don't want to allocate the physical memory 189 // when the heap is created [AG] 188 190 // memset( (void *)alloc_base , 0 , alloc_size ); 189 191 … … 216 218 store[cxy].initialized = MALLOC_INITIALIZED; 217 219 220 218 221 #if MALLOC_DEBUG 219 printf("\n[MALLOC] %s completes store[%x] initialisation\n",222 printf("\n[MALLOC] %s : completes store[%x] initialisation\n", 220 223 __FUNCTION__, cxy ); 224 225 display_free_array( cxy ); 221 226 #endif 222 227 … … 344 349 unsigned char * ptr = (unsigned char*)(store[cxy].alloc_base + offset); 345 350 346 // check the alloc[] array 347 if ( *ptr != 0 ) 348 { 349 pthread_mutex_unlock( &store[cxy].mutex ); 350 printf("\n[PANIC] in %s : allocate an already allocated block...\n", 351 __FUNCTION__ ); 352 return NULL; 353 } 351 // DEPRECATED : we don't check the alloc[] array, 352 // because it has not been initialised, to avoid 353 // physical memory allocation at heap creation [AG] 354 // if ( *ptr != 0 ) 355 // { 356 // pthread_mutex_unlock( &store[cxy].mutex ); 357 // printf("\n[PANIC] in %s : allocate an already allocated block...\n", 358 // __FUNCTION__ ); 359 // return NULL; 360 // } 354 361 355 362 // update alloc_array -
trunk/libs/malloc.h
r412 r416 24 24 //////////////////////////////////////////////////////////////////////////////// 25 25 // General principles: 26 // - In user space th is HEAP zone has a fixed size, that spread between the27 // ELF zone and the STACK zone.26 // - In user space the HEAP zone spread between the ELF zone and the STACK zone, 27 // as defined in the kernel_config.h file. 28 28 // - The malloc library uses the mmap() syscall to create - on demand - 29 // up to one vseg per cluster. The size of these vsegs is defined by the 30 // MALLOC_LOCAL_STORAGE_SIZE parameter. 31 // - For a standard malloc(), the target cluster is the cluster of the client 32 // thread. For a remote_malloc(), the target cluster is explicitely defined 33 // by the arguments. 29 // one vseg in a given cluster. The size of this vseg is defined below 30 // by the MALLOC_LOCAL_STORE_SIZE parameter. 31 // - For a standard malloc(), the target cluster is the cluster containing 32 // the core running the client thread. 33 // - For a remote_malloc(), the target cluster is explicitely defined 34 // by the argument. 34 35 // - In each cluster, the available storage in virtual space is handled by a 35 36 // local allocator using the buddy algorithm. 36 // TODO : introduce the possibility to use a list of vsegs in each cluster... 37 // 38 // TODO : In this first implementation one single - fixed size - vseg 39 // is allocated on demand in each cluster. 40 // We should introduce the possibility to dynamically allocate 41 // several vsegs in each cluster, using several mmap when required. 37 42 //////////////////////////////////////////////////////////////////////////////// 38 43 // Free blocks organisation in each cluster : … … 43 48 // given list have the same size. 44 49 // - The NEXT pointer implementing those linked lists is written 45 // in the 4first bytes of the block itself, using the unsigned int type.50 // in the first bytes of the block itself, using the unsigned int type. 46 51 // - The pointers on the first free block for each size are stored in an 47 // array of pointers free[32] in the sto trage(x,y) descriptor.52 // array of pointers free[32] in the storage(x,y) descriptor. 48 53 //////////////////////////////////////////////////////////////////////////////// 49 54 // Allocation policy: … … 56 61 // and returns the block B if the list[actual_size] is not empty. 57 62 // - If the list[actual_size] is empty, it pop the list[actual_size * 2]. 58 // If a block B' is found, it break this block in 2 B/2 blocks, returns63 // If a block B' is found, it breaks this block in 2 B/2 blocks, returns 59 64 // the first B/2 block and push the other B/2 block into list[actual_size]. 60 65 // - If the list[actual_size * 2] is empty, it pop the list[actual_size * 4]. … … 73 78 // of the allocated block must be obtained from the base address of the block. 74 79 // - The number of entries in this array is equal to the max number 75 // of allocated block : MALLOC_LOCAL_STOR AGE_SIZE / MALLOC_MIN_BLOCK_SIZE.80 // of allocated block : MALLOC_LOCAL_STORE_SIZE / MALLOC_MIN_BLOCK_SIZE. 76 81 // - For each allocated block, the value registered in the alloc[] array 77 82 // is log2( size_of_allocated_block ). -
trunk/libs/stdlib.c
r412 r416 36 36 __FUNCTION__ , __LINE__ , __FILE__ ); 37 37 38 pthread_exit( NULL);38 exit( 0 ); 39 39 } 40 40 }
Note: See TracChangeset
for help on using the changeset viewer.