Memory Management Summer 2016 Cornell University Today Overview - - PowerPoint PPT Presentation

memory management
SMART_READER_LITE
LIVE PREVIEW

Memory Management Summer 2016 Cornell University Today Overview - - PowerPoint PPT Presentation

CS 4410 Operating Systems Memory Management Summer 2016 Cornell University Today Overview of memory The role of operating systems in memory management. 2 Program Process For a program to become process, and be executed on CPU,


slide-1
SLIDE 1

CS 4410 Operating Systems

Memory Management

Summer 2016 Cornell University

slide-2
SLIDE 2

Today

  • Overview of memory
  • The role of operating systems in memory

management.

2

slide-3
SLIDE 3

Program → Process

For a program to become process, and be executed on CPU, it should first be loaded from the hard disk into memory.

3

slide-4
SLIDE 4

Execution cycle of an instruction

  • CPU fetches the next instruction from memory.
  • Operants of the instruction are loaded from memory

and stored into registers.

  • Store the output of the instruction into a register.
  • Copy the result into memory.

4

slide-5
SLIDE 5

Storage Hierarchy

5

slide-6
SLIDE 6

Memory

  • A large array of words.
  • Word = 4 or 8 bytes.
  • One address for every word.
  • Content:

– Instructions – Data

6

slide-7
SLIDE 7

Memory Management

  • The operating system dictates how the

memory is shared among processes.

  • Basic concerns:

– Allocation – Protection – Relocation

7

slide-8
SLIDE 8

Allocation strategy

  • Should processes have contiguous space of

physical addresses in memory?

  • Is memory partitioned into fixed- or variable-

sized segments?

– If variable-sized segments, which allocation algorithm is used?

  • First fit: allocate first hole that is big enough.
  • Best fit: allocate the smallest hole that is big enough.
  • Worst fit: allocate the largest hole.
slide-9
SLIDE 9

9

Fragmentation

  • External fragmentation
  • First-fit, Best fit
  • There is enough total memory space to satisfy a request

but the available spaces are small and not contiguous.

  • Internal fragmentation
  • Break the physical memory into fixed-sized blocks and

allocate memory in units based on block size.

  • The allocated memory is slightly larger than the

requested memory.

slide-10
SLIDE 10

Physical VS virtual address

  • Each time a process is loaded into memory may
  • ccupy different space of physical addresses.

– It may not be contiguous.

  • But the program code uses fixed virtual

addresses.

– Example: JMP 0x56789AB1 (jump to a particular program point) – The program is written as if it will run with an infinite contiguous memory space.

10

slide-11
SLIDE 11

Address translation

  • The CPU understands virtual addresses.
  • The memory unit understands physical

addresses.

  • The OS and specialized hardware are

responsible for translating virtual addressed into physical addresses.

  • The translation mechanism gives protection.

11

slide-12
SLIDE 12

Segmented Memory

  • Allocation and protection scheme.
  • Each process is contained in a single

contiguous section in memory.

12

OS process process process

25600 30004 42094 88000 30004 12090

base bound

slide-13
SLIDE 13

Segmented Memory

  • The OS is responsible to load the Base and

Bound registers.

13

CPU < + memory Bound Base trap: addressing error logical address no yes physical address

slide-14
SLIDE 14

Today

  • Overview of memory
  • The role of operating systems in memory

management.

14

slide-15
SLIDE 15

Coming up…

  • Next lecture: Paging
  • HW3 released today
  • Deadlock exercises can be solved
  • Due on Monday.
  • Short concise answers!

15