Month: March 2021

1. Preliminary Notes
? The question is presented from a Linux point of view using the computer science server
mimi.cs.mcgill.ca, which you can reach remotely using ssh or putty from your laptop
(see lab 1). We suggest you do this assignment directly from mimi.cs.mcgill.ca since these
are the computers the TA will be using.
? Your solution must be built using the modular programming techniques we discussed in the inclass
exercise sessions and the C labs.
? You must write this assignment in the C Programming language.
2. Assignment Question: Building a Virtual Memory for the Kernel
2.1 Overview:
For this assignment, you will need the fully working OS Kernel from Assignment 2. You can either build
on top of your past submission, or use the official solution provided on myCourses. The goal of this
assignment is to add a memory manager to your kernel.
You will add the following new elements to your OS kernel:
1. The OS Boot Sequence to create some necessary OS structures.
2. The Backing Store, initialized in the OS Boot Sequence.
3. The Memory Manager to handle paging and memory allocation for processes.
In addition, you will modify existing modules in you Kernel:
o PCB Modifications (in pcb.c)
§ Addition of the page table
o Page Fault support (primarily implemented in the memory manager, but modifications are
necessary in kernel.c and cpu.c)
§ Find page, swap in, select victim, we will not do a swap out.
§ Generate Page Fault and properly assigns addresses
<标题> o Prepare RAM for paging (in ram.c)

2.2 The OS boot sequence:
The boot sequence occurs as the very first task begun by the OS. In our simulation, this corresponds to
the first thing in your main() function. Basically:
int main() {
int error=0;
boot(); // First : actions performed by boot
error = kernel(); // Second: actions performed by kernel
return error;
}
Notice that the main() function is very simple. The boot()function is a one-time call invoked by
main() at the start to initialize and acquire the resources it needs to run. Place this function in
kernel.c. Create a new function kernel() (in kernel.c) that contains the kernel main function code
from Assignment 2.
In our kernel, boot()will perform only two activities.
1. It assumes that RAM is a global array of 40 char* pointers. This array is not instantiated (not
malloced). It assumes that each 4 cells of the array are a frame (i.e., the RAM can hold a total of
10 frames). At boot time, there are no other programs running except the kernel, so it initializes
every cell of the array to NULL. This indicates that there are no pages of code in RAM.
Important: Note that the structure of the RAM changed from Assignment 2, where it was
<标题> instantiated as an array of 1000 char* pointers.