Changeset 416 for trunk/libs


Ignore:
Timestamp:
Jan 4, 2018, 10:05:47 AM (4 years ago)
Author:
alain
Message:

Improve sys_exec.

Location:
trunk/libs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/malloc.c

    r412 r416  
    107107// It uses the mmap( MAP_REMOTE ) syscall to allocate a new vseg mapped in cluster (cxy).
    108108////////////////////////////////////////////////////////////////////i//////////////////////
    109 // @ cxy       : target cluster identifier (fixed format).
    110 // @ size      : store size (bytes).
     109// @ cxy        : target cluster identifier (fixed format).
     110// @ store_size : store size (bytes).
    111111// # return without setting the initialized field in store(cxy) if failure.
    112112////////////////////////////////////////////////////////////////////i//////////////////////
     
    185185    }
    186186
    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]
    188190    // memset( (void *)alloc_base , 0 , alloc_size );
    189191 
     
    216218    store[cxy].initialized = MALLOC_INITIALIZED;
    217219
     220
    218221#if MALLOC_DEBUG
    219 printf("\n[MALLOC] %s completes store[%x] initialisation\n",
     222printf("\n[MALLOC] %s : completes store[%x] initialisation\n",
    220223__FUNCTION__, cxy );
     224
     225display_free_array( cxy );
    221226#endif
    222227
     
    344349    unsigned char * ptr    = (unsigned char*)(store[cxy].alloc_base + offset);
    345350
    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    // }
    354361
    355362    // update alloc_array
  • trunk/libs/malloc.h

    r412 r416  
    2424////////////////////////////////////////////////////////////////////////////////
    2525// General principles:
    26 // - In user space this HEAP zone has a fixed size, that spread between the
    27 //   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.
    2828// - 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.
    3435// - In each cluster, the available storage in virtual space is handled by a
    3536//   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.
    3742////////////////////////////////////////////////////////////////////////////////
    3843// Free blocks organisation in each cluster :
     
    4348//   given list have the same size.
    4449// - The NEXT pointer implementing those linked lists is written
    45 //   in the 4 first bytes of the block itself, using the unsigned int type.
     50//   in the first bytes of the block itself, using the unsigned int type.
    4651// - The pointers on the first free block for each size are stored in an
    47 //   array of pointers free[32] in the stotrage(x,y) descriptor.
     52//   array of pointers free[32] in the storage(x,y) descriptor.
    4853////////////////////////////////////////////////////////////////////////////////
    4954// Allocation policy:
     
    5661//   and returns the block B if the list[actual_size] is not empty.
    5762// - 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, returns
     63//   If a block B' is found, it breaks this block in 2 B/2 blocks, returns
    5964//   the first B/2 block and push the other B/2 block into list[actual_size].
    6065// - If the list[actual_size * 2] is empty, it pop the list[actual_size * 4].
     
    7378//   of the allocated block must be obtained from the base address of the block. 
    7479// - The number of entries in this array is equal to the max number
    75 //   of allocated block : MALLOC_LOCAL_STORAGE_SIZE / MALLOC_MIN_BLOCK_SIZE.
     80//   of allocated block : MALLOC_LOCAL_STORE_SIZE / MALLOC_MIN_BLOCK_SIZE.
    7681// - For each allocated block, the value registered in the alloc[] array
    7782//   is log2( size_of_allocated_block ).
  • trunk/libs/stdlib.c

    r412 r416  
    3636        __FUNCTION__ , __LINE__ , __FILE__ );
    3737
    38         pthread_exit( NULL );
     38        exit( 0 );
    3939    }
    4040}
Note: See TracChangeset for help on using the changeset viewer.