# FreeRTOS ## Memory Allocation * heap 1. Heap Init ,如果沒有使用過的話 2. xWantSize +=HeapStructSize 和做 alingment * heapSTRUCT_SIZE = ( ( sizeof( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK ); 3. 如果( xWantedSize > 0 ) && (xWantedSize <=xFreeBytesRemaining ) ,繼續 allocate 4. 找到第一個 足夠的 BlockSize 進行使用 5. 如果要使用的 BlockSize > heapMINIMUM_BLOCK_SIZE,則把它進行分割加入 Free List ```clike= 1 pxNewBlockLink = (void *) ( ( (uint8_t *) pxBlock ) + xWantedSize ); pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; pxBlock->xBlockSize = xWantedSize; prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); ``` * heapMINIMUM_BLOCK_SIZE = heapSTRUCT_SIZE *2 * prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); * Heap2 : 按照 Block Size 大小排序加入 Free List (小 =>大) * Heap 4 : 按照 Block Address 高低排序加入 Free List (小 =>大),會在這個時候做 continuous block 的合併 6. retuen allocate address hart: A component that contains a hardware execution context, which includes all the state mandated by the RISC-V ISA: a PC and some registers. core: A component that contains one or more harts that share a single independent instruction fetch unit.
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up