score: Fix workspace size estimate for TLS

This commit is contained in:
Sebastian Huber
2014-04-07 16:50:13 +02:00
parent 2d5424d2d0
commit 6cf45cbeef
3 changed files with 17 additions and 4 deletions

View File

@@ -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.
*/

View File

@@ -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,

View File

@@ -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) {