I’m currently working with Angela Demke-Brown and Karen Reid on an extension to the sys161 operating system simulator to allow visualization of the current memory usage in the simulated system. The intent is to help students in a 3rd year operating systems course with their understanding of virtual memory. The visualizer now displays the used and unused pages, colour-coded according to the type of allocation. The next step is to somehow visualize the contents of pages used for kernel stacks.
The current idea is to get the simulator to report whenever the stack pointer register changes value, and infer what happened from that. Given that there is only one processor, the updated stack must be the one for the currently running thread (or an exception handler, but I’ll get to that later). I know which thread this is because a modification to the os161 kernel starter code causes the simulator to report whenever there is a context switch. Given this, and a dump of the symbol table for the running kernel, it should be possible to get the information I need.
So, I coded up a simple test that just sent a message from the simulator with the new value of the stack pointer every time it changed. I figured it would be updated often, but I had no idea how often – the resulting system sends so many messages to the visualizer program that it can’t keep up. I’ve determined that most of these messages aren’t really interesting, being the result of the timer interrupt. I’m hoping that I can find a way to exclude these, and that the remaining messages will be more manageable. If not, I’ll have to work out a way to turn this feature off when it isn’t needed.