1 of 25

Address Translation and Paging

CSC 213 - Operating Systems

Leah Perlmutter | Fall 2023

2 of 25

Announcements

3 of 25

Agenda for Today

  1. Announcements
  2. Q&A
  3. Assignment Discussion: Ngram Generator
  4. New Assignment: Archive Printer
  5. Address Spaces
  6. Address Translation
  7. Wrap Up

4 of 25

Announcements

  • Assignment: Sorted List due Monday 9/11 (Today) at 11:59 pm
  • Lab: Shell due Wednesday 9/13 at 11:59 pm
    • Check course website for instructor and mentor office hours!
    • Post questions on the teams team! (course content channel)
  • Reading: read lab instructions, due Wednesday 9/13 at 2:00 pm (before class)
  • Grading in progress for your Ngram assignment
  • CS Extra: Misinformation Visualization
    • Guest Speaker: Elizabeth Zak '20, University of Iowa
    • 4–5:15pm on Thursday, September 14 in Noyce 3821

5 of 25

Q&A

6 of 25

Sorted List Assignment Q&A

no questions asked

7 of 25

Shell Lab Q&A

What to do if struggling unproductively?

Struggling is normal, but if you are struggling without making progress: ask a mentor, ask on Teams, come to instructor office hours (see website for times).

​

8 of 25

Assignment Discussion:�Ngram Generator

9 of 25

Grid showing 2 ways to solve the ngram assignment, and their storage, printing, and shifting

10 of 25

Illustration of the first solution in the previous slide. It's necessary to shift the values in the array somehow. 2 ways to do it include a for loop and memmove.

11 of 25

Illustration of a circular buffer and "end" index used in the second solution in the table on the previous slide. No shifting its required, but we need to print out characters one at a time.

END

Review of the modulo operation

12 of 25

How does ChatGPT do on this assignment?

13 of 25

How have we used chat gpt?

Ask it why my tests are failing -- it reminded me about trailing \0

Pointed out an inefficiency with looping and suggested memmove

14 of 25

New Assignment:�Archive Printer

15 of 25

5 minute break (:

16 of 25

Address Spaces

17 of 25

Address Spaces: Basics (From Friday)

What are the main pieces of a running program's address space?

Stack - local variables, function calls

Instructions - main, helper functions, library functions

Heap - anything malloc'd

Empty space

18 of 25

Address Spaces: Basics

What is the difference between a virtual and physical address?

Virtual

-- the number printed out when you print a pointer (can be printed)

-- representation of memory but not actual memory

-- each process has its own

Physical

-- physical location on hardware (can't be printed)

-- there is only one and it's shared across all processes

​

Address translation -- need to change virtual address to physical address before we can read or write to that address

​

​

19 of 25

Address Spaces: Motivation

Why do we run processes in their own address spaces?

Isolation and protection (+1) -- each process can only access its own address space

Efficiency -- OS can place things next to each other for more contiguous reads and writes which is more efficient, OS can use all the space in memory while processes believe they have empty space to use

Transparency -- I wanna make you feel like you're the only process in the world -- ease of use for programmers

​

​

20 of 25

Whiteboard:�A Typical Address Space

21 of 25

Example of the whole computer's memory and how it's divided up for different processes. Each process can only access its own memory, except the kernel, which can access all the memory.

Example of how the memory might be divided up for Process B: instructions, heap (growing down), empty space, and stack (growing up)

WHITEBOARD DRAWING (from Friday)

22 of 25

Whiteboard:�Address Translation

23 of 25

The red arrows illustrate one attribute of address translation: different pages of the process's memory might not be stored in order in physical memory

VIRTUAL MEMORY OF PROCESS A

VIRTUAL MEMORY OF PROCESS B

PHYSICAL MEMORY

Process A and Process B both have virtual address spaces from 0 to 1000, but neither of them maps to those addresses on the physical memory

24 of 25

Wrap Up

25 of 25

Announcements

  • Assignment: Sorted List due Monday 9/11 (Today) at 11:59 pm
  • Lab: Shell due Wednesday 9/13 at 11:59 pm
    • Check course website for instructor and mentor office hours!
    • Post questions on the teams team! (course content channel)
  • Reading: read lab instructions, due Wednesday 9/13 at 2:00 pm (before class)
  • Grading in progress for your Ngram assignment
  • CS Extra: Misinformation Visualization
    • Guest Speaker: Elizabeth Zak '20, University of Iowa
    • 4–5:15pm on Thursday, September 14 in Noyce 3821