Changeset aab4664d in rtems


Ignore:
Timestamp:
Oct 22, 2003, 4:53:55 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
a51735c
Parents:
08c09e24
Message:

2003-10-22 Joel Sherrill <joel@…>

PR 511/filesystem

  • src/malloc.c: Add deferred free and protect against C Program Heap operations while in a dispatch disable critical section or ISR.
Location:
cpukit/libcsupport
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/ChangeLog

    r08c09e24 raab4664d  
     12003-10-22      Joel Sherrill <joel@OARcorp.com>
     2
     3        PR 511/filesystem
     4        * src/malloc.c: Add deferred free and protect against C Program Heap
     5        operations while in a dispatch disable critical section or ISR.
     6
    172003-10-02      Phil Torre <ptorre@zetron.com>
    28
  • cpukit/libcsupport/src/malloc.c

    r08c09e24 raab4664d  
    3434#include <unistd.h>    /* sbrk(2) */
    3535
     36#include <chain.h>
     37
     38Chain_Control RTEMS_Malloc_GC_list;
     39
    3640rtems_id RTEMS_Malloc_Heap;
    3741size_t RTEMS_Malloc_Sbrk_amount;
     
    7276
    7377  /*
     78   *  Initialize the garbage collection list to start with nothing on it.
     79   */
     80  Chain_Initialize_empty(&RTEMS_Malloc_GC_list);
     81
     82  /*
    7483   * If the starting address is 0 then we are to attempt to
    7584   * get length worth of memory using sbrk. Make sure we
     
    151160  rtems_unsigned32   sbrk_amount;
    152161  rtems_status_code  status;
     162  Chain_Node        *to_be_freed;
    153163
    154164  MSBUMP(malloc_calls, 1);
     
    156166  if ( !size )
    157167    return (void *) 0;
     168
     169  /*
     170   *  Do not attempt to allocate memory if in a critical section or ISR.
     171   */
     172
     173  if (_Thread_Dispatch_disable_level > 0)
     174    return (void *) 0;
     175 
     176  if (_ISR_Nest_level > 0)
     177    return (void *) 0;
     178 
     179  /*
     180   *  If some free's have been deferred, then do them now.
     181   */
     182  while ((to_be_freed = Chain_Get(&RTEMS_Malloc_GC_list)) != NULL)
     183    free(to_be_freed);
    158184
    159185  /*
     
    268294  MSBUMP(realloc_calls, 1);
    269295
     296  /*
     297   *  Do not attempt to allocate memory if in a critical section or ISR.
     298   */
     299
     300  if (_Thread_Dispatch_disable_level > 0)
     301    return (void *) 0;
     302 
     303  if (_ISR_Nest_level > 0)
     304    return (void *) 0;
     305 
     306  /*
     307   * Continue with calloc().
     308   */
    270309  if ( !ptr )
    271310    return malloc( size );
     
    314353    return;
    315354
     355  /*
     356   *  Do not attempt to free memory if in a critical section or ISR.
     357   */
     358
     359  if ((_Thread_Dispatch_disable_level > 0) || (_ISR_Nest_level > 0)) {
     360    Chain_Append(&RTEMS_Malloc_GC_list, (Chain_Node *)ptr);
     361    return;
     362  }
     363 
    316364#ifdef MALLOC_STATS
    317365  {
Note: See TracChangeset for help on using the changeset viewer.