SNU-ARC / 2024_spring_sysprog_Lab3

7 stars 0 forks source link

malloc으로 몇 바이트까지 할당가능한 것인지 질문드립니다 #13

Open Jukim2 opened 5 months ago

Jukim2 commented 5 months ago

처음에 3210241024 = 33,554,432개를 ds_allocate에 넘겨서 ds_heap_end - ds_heap_start = 33,554,432이 되게 값을 주는 것으로 알고있습니다.

memmgr로 넘어와서, 양 sentinel을 빼게 되면 heap_start와 heap_end사이에는 총 33,554,432 - 32 * 2 = 33,554,368바이트가 존재하게됩니다.

그러면 header와 footer를 뻈을 때 33554368 - 8 * 2 = 33,554,352바이트까지 할당이 가능할 것 같은데 레퍼런스 프로그램에서 그렇게되지않아 잘못 생각한 부분이 있는지 궁금하여 질문드립니다.

kwonsw055 commented 5 months ago

1) heap_startheap_end는 32 byte aligned 된 주소여야 한다는 점 2) dataseg에서 ds_sbrk 호출 시 ds_heap_brkds_heap_end와 같을 수 없다는 점 등으로 인해 실제 가능한 malloc 크기는 줄어들 수 있습니다.