Operating System代写:COMP3361 Logical Memory

根据提供的OS框架代码,补充完成logical memory部分的代码。


In this assignment, you will implement a logical memory initializer for SOS. The logical memory initializer will initialize the logical address space of a process, and set up the page directory/tables for the process.


The background material for this assignment is in Chapter 5 of “Understanding a Simple Operating
System.” You must read it (and the previous chapters) before attempting this assignment.

Assignment Objective

The file lmemman.c has one incomplete function with TODO blocks. Finish these blocks to complete the assignment.

bool init_logical_memory(PCB *p, uint32_t code_size);

This function initializes a process’ logical address space. This involves allocating frames for the process code, stacks, page directory and page tables, and then setting them up. The PCB is passed in the argument p, and the number of bytes in the process’ code and data is in the argument code_size. The function should return TRUE if all goes well; otherwise FALSE. Any frames allocated in the function must be freed if FALSE is returned.

User programs

The same user programs as in SOS2 are available in this assignment.


Download the ASG4.zip file from the assignment page. Extract the folder. In SOS3, use ./create to create the SOS.dsk file (just like you did for SOS0, SOS1 and SOS2). Create a new machine called SOS3 in VirtualBox, and use the SOS.vmdk file for the hard drive. Once SOS boots, you can run one of the three available programs. For example, to run p2.c, type

%run 1300 2

However, for now you will see the message run: Not enough memory. This is because init_logical_memory simply returns FALSE. But once you finish the assignment, you should see the program executing (you will see a series of Bs being printed).


Submit in Canvas the modified lmemman.c file, and a README file containing any information you feel the GTA should know before grading your program. Comment your program well (include your name).


90 points total : 50 points are allocated for correct setup of the page directory/tables, 10 points for allocating the correct number of frames, 20 points for correct setup of the process PCB’s mem struct, and 10 points for correct return behavior. The assignment will be graded within the SOS development environment. It is your responsibility to ensure that the submitted code runs in that environment (irrespective of where you wrote or tested your code). Failure to do so will result in full penalty.

The late policy is available in the course syllabus. You must work alone on this assignment.