Assignment 1
Camden Johnson
Missouri Baptist - Operating System
Question 1
The Memory Management Unit, or MMU, is part of the computer that helps translate
virtual addresses into physical addresses. When a program runs, it uses virtual
addresses instead of directly using locations in RAM. The MMU figures out where that
information needs to go in physical memory.
This is helpful because each program can have its own virtual memory space. For
example, two programs can use the same virtual address, but the computer can send
them to different places in RAM. This helps keep programs from interfering with each
other.
The MMU is also important when using paging. Virtual memory is divided into pages,
and physical memory is divided into frames. The MMU uses a page table to figure out
which physical frame contains the page that a program needs.
The MMU also helps protect memory. A program should not be able to access another
program's memory or important parts of the operating system. The MMU can check if a
program has permission to read, write, or use a certain part of memory. If it does not
have permission, the computer can block the request.
Question 2
Memory allocation is how the operating system decides where to put programs in
memory. There are several different ways it can do this. Three common methods are
first-fit, best-fit, and worst-fit.
First-fit looks through the available memory and uses the first space that is big enough.
For example, if the available spaces are 10 MB, 30 MB, and 50 MB, and a program
needs 20 MB, first-fit would use the 30 MB space. This method is usually pretty fast
because it stops looking once it finds a space that works.
Best-fit looks for the smallest space that is big enough for the program. If the available
spaces are 10 MB, 25 MB, 30 MB, and 50 MB, and the program needs 20 MB, best-fit
would use the 25 MB space. This can save some space, but it can also leave behind
many small spaces that are difficult to use.
Worst-fit does the opposite of best-fit. It uses the largest available space for the
program. The idea is that the space left over might still be large enough for another
program. However, this can also waste memory.
Each method has advantages and disadvantages. First-fit is simple and fast, best-fit
tries to save space, and worst-fit tries to leave larger spaces available. The best choice
depends on how the computer is using its memory.
Question 3
Paging is a way for the operating system to manage memory. Instead of putting an
entire program into RAM at once, the operating system breaks the program into smaller
sections called pages. The pages can then be loaded into RAM when they are needed.
This allows a computer to run programs that may be larger than its available RAM.
Sometimes all of the memory frames are already being used. If a program needs a
page that is not in memory, the operating system has to remove another page to make
room. This is called page replacement.
Two common page replacement methods are FIFO and LRU. FIFO, or First-In, FirstOut, removes the page that has been in memory the longest. LRU, or Least Recently
Used, removes the page that has not been used for the longest time.
For example, imagine a computer has three memory spaces and a program requests
pages 1, 2, 3, 1, 4, and 5. Pages 1, 2, and 3 fill the three spaces. When page 1 is
requested again, it is already in memory, so nothing needs to change.
When page 4 is requested, there is no empty space. With FIFO, page 1 is removed
because it was the first page added. Page 4 takes its place. When page 5 is requested,
page 2 is now the oldest page, so it is removed and replaced with page 5.
LRU would make the decision based on which page was used least recently. This can
sometimes work better because programs often use information they have recently
used. The downside is that the computer has to keep track of when each page was last
used.