Allocate zero-initialized memory

Allocate zero-initialized memory - get a page fault. •...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
4. Allocate zero-initialized memory. It is used to allocate space for bss, stack and sbrk() When allocating memory using sbrk or map with the MMAP_ANON flag, all the VM pages in this mapping will map to a single page in RAM that has zeroes and that is read only. When a page is modified the OS creates a copy of the page (copy on write) and retries the modifying instruction This allows fast allocation. No RAM is initialized to O’s until the page is modified This also saves RAM. only modified pages use
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4. Allocate zero-initialized memory. This is implemented by making the entries in the same page table point to a page with 0s and making the pages read only. An instruction that tries to modify the page will
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: get a page fault. • The page fault allocates another physical page with 0’s and updates the page table to point to it. • The instruction is retried and the program continues as it never happened. 4. Allocate zero-initialized memory. . Physical Memory Parent’s Virtual Memory 0’s page A 0’s page B 0’s page C 0’s After allocating zero initialized memory with sbrk or mmap, all pages point to a single page with zeroes 4. Allocate zero-initialized memory. . Physical Memory Parent’s Virtual Memory 0’s page A 0’s page B X page C 0’s When a page is modified, the page creates a copy of the page and the modification is done in the copy. page B X...
View Full Document

This note was uploaded on 01/30/2012 for the course CS 354 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 4

Allocate zero-initialized memory - get a page fault. •...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online