FANDOM


About the CourseEdit

CS3231 aims to give students an indepth look into the construction and theory behind operating systems. Students are lectured on a range of operating system techniques and given a variety of operating system functions to code during assignments. It is a great course for anyone wishing to understand the layer between applications and hardware and will definitely improve your C coding.

Introduction to Operating Systems Edit

Operating systems are fundamentally a layer of abstraction that fits between applications and hardware.

Operating systems attempt to provide:


  • Programmers with a standardised interface and set of instructions to run their code on top of, allowing applications to be machine independent. A layer of abstraction
  • Users with a level of multitasking, where tasks are interleaved to maximise system utilisation and the impression of simultaneous execution.
  • A system that manages the allocation systems resources to processes.
  • Easy inter-process communication and ease the creation of processes.


Course TopicsEdit

Things you need to know for the assignments Edit

Final Exam Edit

100 Sample Questions and Answers

Explanation of DumbVM Edit

DumbVM is the cheesy hack virtual memory subsystem in OS/161, supplied as an example up until the virtual memory assignment, where you fix it.

It works sort of like base/limit registers, by allocating each segment as a contiguous hunk of memory and storing the base addresse and number of pages in the process's struct addrspace. Each struct addrspace contains the virtual base address, physical base address, and number of pages, for two segements. It also contains the physical stack pointer (the size of the stack doesn't seem to be needed for some reason. The virtual top of the stack is always the top of kuseg).

getppages() and alloc_kpages() work by ram_stealmem(), a really disgusting and lowlevel function that as far as I can tell, cuts the required amount of ram from the beginning of memory (address 0), and then pretends that it never existed by changing the end of the memory block to be address 0. Memory allocated using ram_stealmem() is unrecoverable.

free_kpages() does nothing, DumbVM doesn't free memory at all.

as_create() and as_destroy() just kmalloc() the struct and zero it, and kfree() it, respectively.

as_activate() wipes the TLB by invalidating every entry

as_define_region() assigns the base and size of a region in virtual memory, by doing some alignment and size checks on the given size and virtual address. It doesn't appear to touch physical memory at all.

as_define_stack() just assigns the given stackpointer to USERSTACK which is the top of the kuseg.

as_copy() copies an address space by creating a new struct addrspace, copying over all of the fields, calling as_prepare_load() to allocate the new memory, and then just uses memmove() on the old and new pointers to copy over the memory contents.

as_prepare_load() allocates memory for each segment (using getpppages(), which uses ram_stealmem()) in a struct addrspace in preparation for the loading of a binary image. as_complete_load() does nothing.

vm_fault() Edit

But the main action goes down in vm_fault(). The DumbVM vm_fault() only handles VM_FAULT_READ and VM_FAULT_WRITE and basically panics otherwise (look at the switch statement on line 78). It then has a whole bunch of asserts that sanity check the current address space. At line 114, the contents of the current address space are copied into local variables.

The if statement at line 121 checks to see which segment (1, 2 or stack) the fault address is in. The physical address paddr is worked out from the base address of that segment.

Then, the for loop on line 138 searches the whole TLB for an invalid entry, and writes the fault address and the just-worked-out physical address into it. Many questions arise: what if there isn't an invalid address in the TLB? Surely that has a performance worse than that bubble sort? Isn't that what this TLB_Random function is for?

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.