summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-07 16:50:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-09 15:30:25 +0200
commit6cf45cbeef58697af3349299f3fd717133eae5ed (patch)
tree3a33bf77880608b1513c6c1e6e97405125f98b74
parentsptests/sp37: Account for internal struct align (diff)
downloadrtems-6cf45cbeef58697af3349299f3fd717133eae5ed.tar.bz2
score: Fix workspace size estimate for TLS
-rw-r--r--cpukit/score/include/rtems/score/heap.h5
-rw-r--r--cpukit/score/src/heap.c3
-rw-r--r--cpukit/score/src/wkspace.c13
3 files changed, 17 insertions, 4 deletions
diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h
index 1ca840d4a0..0120a2bb14 100644
--- a/cpukit/score/include/rtems/score/heap.h
+++ b/cpukit/score/include/rtems/score/heap.h
@@ -449,6 +449,11 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_up(
}
}
+RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min_block_size( uintptr_t page_size )
+{
+ return _Heap_Align_up( sizeof( Heap_Block ), page_size );
+}
+
/**
* @brief Returns the worst case overhead to manage a memory area.
*/
diff --git a/cpukit/score/src/heap.c b/cpukit/score/src/heap.c
index 949e963070..1550c4ce1c 100644
--- a/cpukit/score/src/heap.c
+++ b/cpukit/score/src/heap.c
@@ -228,7 +228,8 @@ uintptr_t _Heap_Initialize(
return 0;
}
}
- min_block_size = _Heap_Align_up( sizeof( Heap_Block ), page_size );
+
+ min_block_size = _Heap_Min_block_size( page_size );
area_ok = _Heap_Get_first_and_last_block(
heap_area_begin,
diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c
index 071c178758..20e2563287 100644
--- a/cpukit/score/src/wkspace.c
+++ b/cpukit/score/src/wkspace.c
@@ -67,11 +67,18 @@ void _Workspace_Handler_initialization(
size_t i;
if ( tls_size > 0 ) {
- uintptr_t tls_alignment = (uintptr_t) _TLS_Alignment;
- uintptr_t tls_alloc = _TLS_Get_allocation_size( tls_size, tls_alignment );
+ uintptr_t tls_align = _TLS_Heap_align_up( (uintptr_t) _TLS_Alignment );
+ uintptr_t tls_alloc = _TLS_Get_allocation_size( tls_size, tls_align );
+
+ /*
+ * Memory allocated with an alignment constraint is allocated from the end
+ * of a free block. The last allocation may need one free block of minimum
+ * size.
+ */
+ remaining += _Heap_Min_block_size( page_size );
remaining += _Get_maximum_thread_count()
- * _Heap_Size_with_overhead( page_size, tls_alloc, tls_alignment );
+ * _Heap_Size_with_overhead( page_size, tls_alloc, tls_align );
}
for (i = 0; i < area_count; ++i) {