Address Translation and Paging
CSC 213 - Operating Systems
Leah Perlmutter | Fall 2023
Announcements
Agenda for Today
Announcements
Q&A
Sorted List Assignment Q&A
no questions asked
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).
Assignment Discussion:�Ngram Generator
Grid showing 2 ways to solve the ngram assignment, and their storage, printing, and shifting
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.
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
How does ChatGPT do on this assignment?
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
New Assignment:�Archive Printer
5 minute break (:
Address Spaces
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
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
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
Whiteboard:�A Typical Address Space
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)
Whiteboard:�Address Translation
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
Wrap Up
Announcements