Ignore:
Timestamp:
Oct 1, 2015, 4:20:46 PM (9 years ago)
Author:
alain
Message:

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

  • classif
  • convol
  • transpose
  • gameoflife
  • raycast
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_libs/malloc.c

    r686 r709  
    9898
    9999    // checking heap segment constraints
    100     if ( heap_size == 0 )                                    // heap segment exist
    101     {
    102         giet_exit("ERROR in malloc() : heap not found \n");
    103     }
    104     if ( heap_size != (1<<heap_index) )                      // heap size power of 2
    105     {
    106         giet_exit("ERROR in malloc() : heap size must be power of 2\n");
    107     }
    108     if ( heap_base % heap_size )                             // heap segment aligned
    109     {
    110         giet_exit("ERROR in malloc() : heap segment must be aligned\n");
    111     }
     100    giet_pthread_assert( (heap_size != 0) ,
     101                         "error in heap_init() : heap not found");
     102    giet_pthread_assert( (heap_size == (1<<heap_index)) ,
     103                         "error in heap_init() : heap size must be power of 2");
     104    giet_pthread_assert( (heap_base%heap_size == 0) ,
     105                         "error in heap_init() : heap segment must be aligned\n");
    112106
    113107    // compute size of block containin alloc[] array
     
    231225
    232226    // checking arguments
    233     if (size == 0)
    234     {
    235         giet_exit("\nERROR in remote_malloc() : requested size = 0 \n");
    236     }
    237     if ( x >= X_SIZE )
    238     {
    239         giet_exit("\nERROR in remote_malloc() : x coordinate too large\n");
    240     }
    241     if ( y >= Y_SIZE )
    242     {
    243         giet_exit("\nERROR in remote_malloc() : y coordinate too large\n");
    244     }
    245 
    246     // checking initialization
    247     if ( heap[x][y].init != HEAP_INITIALIZED )
    248     {
    249         giet_exit("\nERROR in remote_malloc() : heap not initialized\n");
    250     }
     227    giet_pthread_assert( (size != 0) ,
     228                         "error in remote_malloc() : requested size = 0 \n");
     229    giet_pthread_assert( (x < X_SIZE) ,
     230                         "error in remote_malloc() : x coordinate too large\n");
     231    giet_pthread_assert( (y < Y_SIZE) ,
     232                         "error in remote_malloc() : y coordinate too large\n");
     233    giet_pthread_assert( (heap[x][y].init == HEAP_INITIALIZED) ,
     234                         "error in remote_malloc() : heap not initialized\n");
    251235
    252236    // normalize size
     
    265249
    266250    // check block found
    267     if ( base == 0 )
     251    if (base == 0)
    268252    {
    269253        lock_release( &heap[x][y].lock );
    270         giet_exit("\nERROR in remote_malloc() : no more space\n");
     254        giet_pthread_assert( 0 , "error in remote_malloc() : no more space\n" );
    271255    }
    272256
     
    279263    {
    280264        lock_release( &heap[x][y].lock );
    281         giet_exit("\nERROR in remote_malloc() : block already allocated ???\n");
     265        giet_pthread_assert( 0 , "error in remote_malloc() : block already allocated");
    282266    }
    283267
     
    390374    // check ptr value
    391375    unsigned int base = (unsigned int)ptr;
    392     if ( (base < heap[x][y].heap_base) ||
    393          (base >= (heap[x][y].heap_base + heap[x][y].heap_size)) )
    394     {
    395         giet_exit("ERROR in free() : illegal pointer for released block");
    396     }
     376    giet_pthread_assert( (base >= heap[x][y].heap_base) &&
     377                         (base < (heap[x][y].heap_base + heap[x][y].heap_size)) ,
     378                         "error in free() : illegal pointer for released block" );
    397379 
    398380    // get the lock protecting heap[x][y]
     
    410392    {
    411393        lock_release( &heap[x][y].lock );
    412         giet_exit("\nERROR in free() : released block not allocated ???\n");
     394        giet_pthread_assert( 0 , "error in free() : released block not allocated");
    413395    }
    414396
     
    416398    if ( base % (1 << size_index) )
    417399    {
    418         giet_exit("\nERROR in free() : released block not aligned\n");
     400        lock_release( &heap[x][y].lock );
     401        giet_pthread_assert( 0 , "error in free() : released block not aligned");
    419402    }
    420403
Note: See TracChangeset for help on using the changeset viewer.