Archive for November, 2007

My ongoing battle with LaTeX

Sunday, November 11th, 2007

I’ve started using LaTeX to prepare assignments and other documents, and so far it’s working out pretty well. Formatting math is easily done, especially since I’m coming from OpenOffice, which uses a simplified version of the same markup. Importing and formatting code files with the listings package is great too. My big issue has been with positioning of figures.

It’s easy enough to add a figure to a document, and give it a caption, or reference it from elsewhere in the text. Getting it to flow into the text where you want it to is another story altogether. LaTeX likes to keep pages balanced, so as long as there’s text to be output, it doesn’t want to take up too much space on a page with figures. LaTeX likes to re-flow your document automatically to make sure it remains visually pleasing when you make changes to it. The problem is that with most assignments what’s needed is not so much a visually pleasing document as a document that will be easy for a TA or professor to mark. In order to achieve this, you generally want, say, the text and figures for question 6 to all appear, in order, before any of the text for question 7.

I’ve found a couple of the things that will make LaTeX float figures to later pages are settings for the limit as to how many figures it will allow on one page and how much text it will push to the next page to make room for figures. These commands will change those limits:

\renewcommand{\textfraction}{x%}
\setcounter{totalnumber}{x}

The first one sets the minimum fraction of text that will be displayed on any page, and the second sets the maximum number of figures to appear on any page. These two settings, in combination with the ! and h positioning flags to the figure environment, get close to letting you force the positioning of figures.

I’m still looking for something better though…

Stack pointers are busy little things

Wednesday, November 7th, 2007

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.

In the beginning…

Tuesday, November 6th, 2007

… a lot of things happened! Then, after being poked and prodded by a number of people, I’ve decided to start getting some of those things up on the web. I’ve had this domain hanging around for a number of years now, so I figured I’d start a blog here.

So, on to the first news item! As some of you may know, I’m the Strategy and Telemetry team leader for the University of Toronto Blue Sky Solar Racing Team. The team has finally returned from the 2007 World Solar Challenge, having placed 5th in the adventure class, with the best time for any team from Canada. Since I was unfortunately unable to attend the race myself, I haven’t seen any of the recorded data yet, but I understand that the car performed quite well. Hopefully there will be enough clean data from the race to properly update the automated strategy system with a profile for the 2007 car, as it is currently tuned for the previous design and therefore was not much use during the race.

There are a few photos from the race over at the team’s site, and I hope to get some more up soon. It’s often been joked that the team is actually a photography club, given the number of members who are also avid photographers, so it may be a while before we can sort though the mountain of shots that were taken during the race.