<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                在學習內存堆之前,我們先看看內存堆的的組織結構,它包括了內存數據結構與某些重要的全局變量,具體見代碼清單 5-9。 ``` 1 struct mem 2 { 3 /** index (-> ram[next]) of the next struct */ 4 mem_size_t next; (1) 5 /** index (-> ram[prev]) of the previous struct */ 6 mem_size_t prev; (2) 7 /** 1: this area is used; 0: this area is unused */ 8 u8_t used; (3) 9 #if MEM_OVERFLOW_CHECK 10 /** this keeps track of the user allocation size for guard checks */ 11 mem_size_t user_size; 12 #endif 13 }; 14 15 #define MIN_SIZE 12 (4) 16 17 LWIP_DECLARE_MEMORY_ALIGNED(ram_heap, MEM_SIZE_ALIGNED+(2U*SIZEOF_STRUCT_MEM)); (5) 18 19 #define LWIP_RAM_HEAP_POINTER ram_heap (6) 20 21 22 /** pointer to the heap (ram_heap): 23 for alignment, ram is now a pointer instead of an array */ 24 static u8_t *ram; (7) 25 26 /** the last entry, always unused! */ 27 static struct mem *ram_end; (8) 28 29 #if !NO_SYS 30 static sys_mutex_t mem_mutex; (9) 31 #endif 32 33 static struct mem * LWIP_MEM_LFREE_VOLATILE lfree; (10) ``` * (1)(2):可能很多人都會認為next與prev是一個指針,分別指向下一個內存塊與上一個內存塊,但是其實這兩個字段表示的是目的地址的偏移量,基地址是整個內存堆的起始地址。 * (3):used字段用于標記該內存是否已經被使用。 * (4):申請的內存最小為12字節,因為一個內存塊最起碼需要保持mem結構體的信息,以便于對內存塊進行操作,而該結構體在對齊后的內存大小就是12字節。 * (5):內存堆的大小是由這個宏定義的,該語句在編譯器處理之后就是u8_t ram_heap[(((MEM_SIZE_ALIGNED + (2U * SIZEOF_STRUCT_MEM)) + MEM_ALIGNMENT - 1U))];,其中MEM_SIZE_ALIGNED宏是內存堆大小MEM_SIZE經過內存對齊后的大小;而SIZEOF_STRUCT_MEM則是結構體mem經過內存對其后的大小,MEM_ALIGNMENT則是CPU按多少字節對其的宏定義,一般為4。 * (6):ram_heap[]就是內核的內存堆空間,LWIP_RAM_HEAP_POINTER這個宏定義相對于重新命名ram_heap。 * (7):ram是一個全局指針變量,指向內存堆對齊后的起始地址,因為真正的內存堆起始地址不一定是按照CPU的對齊方式對齊的,而此處就要確保內存堆的起始地址是對齊的。 * (8):mem類型指針,指向內存堆中最后一個內存塊。 * (9):互斥量,用戶保護內存堆的互斥量,暫時未用。 * (10):mem類型指針,指向內存堆中低地址的空閑內存塊,簡單來說就是空閑內存塊鏈表指針。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看