From 5ae327bcf7998573c437fafbc0c298c252c7eec1 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 7 Sep 2007 19:39:25 +0000 Subject: 2007-09-07 Joel Sherrill * score/src/heap.c: Style. * score/src/heapwalk.c: Add more information to prints. * score/src/pheapwalk.c: Do not lock allocator mutex if dispatching is disabled. --- cpukit/ChangeLog | 7 +++++++ cpukit/score/src/heap.c | 12 ++++++------ cpukit/score/src/heapwalk.c | 8 +++++--- cpukit/score/src/pheapwalk.c | 15 +++++++++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) (limited to 'cpukit') diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index f67ffece3c..bf9ae7ad19 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,10 @@ +2007-09-07 Joel Sherrill + + * score/src/heap.c: Style. + * score/src/heapwalk.c: Add more information to prints. + * score/src/pheapwalk.c: Do not lock allocator mutex if dispatching + is disabled. + 2007-09-06 Joel Sherrill * libcsupport/Makefile.am, libcsupport/src/printk.c: diff --git a/cpukit/score/src/heap.c b/cpukit/score/src/heap.c index ccfb405fb7..5273678d1a 100644 --- a/cpukit/score/src/heap.c +++ b/cpukit/score/src/heap.c @@ -117,14 +117,14 @@ uint32_t _Heap_Initialize( uint32_t page_size ) { - Heap_Block *the_block; - uint32_t the_size; - _H_uptr_t start; - _H_uptr_t aligned_start; - uint32_t overhead; + Heap_Block *the_block; + uint32_t the_size; + _H_uptr_t start; + _H_uptr_t aligned_start; + uint32_t overhead; Heap_Statistics *const stats = &the_heap->stats; - if(page_size == 0) + if (page_size == 0) page_size = CPU_ALIGNMENT; else _Heap_Align_up( &page_size, CPU_ALIGNMENT ); diff --git a/cpukit/score/src/heapwalk.c b/cpukit/score/src/heapwalk.c index db8555cd87..0167bbba53 100644 --- a/cpukit/score/src/heapwalk.c +++ b/cpukit/score/src/heapwalk.c @@ -99,7 +99,7 @@ boolean _Heap_Walk( error = 1; } - while ( the_block < end ) { + while ( the_block != end ) { uint32_t const the_size = _Heap_Block_size(the_block); Heap_Block *const next_block = _Heap_Block_at(the_block, the_size); boolean prev_used = _Heap_Is_prev_used(the_block); @@ -165,12 +165,14 @@ boolean _Heap_Walk( } if (the_block != end) { - printk("PASS: %d !last block address isn't equal to 'final'\n", source); + printk("PASS: %d !last block address isn't equal to 'final' %p %p\n", + source, the_block, end); error = 1; } if (_Heap_Block_size(the_block) != the_heap->page_size) { - printk("PASS: %d !last block's size isn't page_size\n", source); + printk("PASS: %d !last block's size isn't page_size (%d != %d)\n", source, + _Heap_Block_size(the_block), the_heap->page_size); error = 1; } diff --git a/cpukit/score/src/pheapwalk.c b/cpukit/score/src/pheapwalk.c index 963be088c3..e20cf124d7 100644 --- a/cpukit/score/src/pheapwalk.c +++ b/cpukit/score/src/pheapwalk.c @@ -24,8 +24,19 @@ boolean _Protected_heap_Walk( { boolean status; - _RTEMS_Lock_allocator(); + /* + * If we are called from within a dispatching critical section, + * then it is forbidden to lock a mutex. But since we are inside + * a critical section, it should be safe to walk it unlocked. + * + * NOTE: Dispatching is also disabled during initialization. + */ + if ( !_Thread_Dispatch_disable_level ) { + _RTEMS_Lock_allocator(); + status = _Heap_Walk( the_heap, source, do_dump ); + _RTEMS_Unlock_allocator(); + } else { status = _Heap_Walk( the_heap, source, do_dump ); - _RTEMS_Unlock_allocator(); + } return status; } -- cgit v1.2.3