Rescuing the Tiny OS in C#
About four years ago (in the middle of the last fifteen years of writing software for money) I graduated from college. I took a round-about way through school at OIT - my four-year degree took eleven years (I actually had to make deals with four different deans to allow me to keep my credits from expiring) but it turned out OK.
Some where in the middle of going to school at night we were asked in an Operating Systems class to write a "Virtual CPU and OS." More of an interpreter, we were given a description of the OS, some op-codes and an ASM-like machine language. We were to write the OS, and feed test programs into the system. It was a fun exercise and a good way to teach folks how virtual memory and memory mapping works, threads vs. processes, etc. I was the only student who chose to write it in managed code. Quite the coup for 2002.
I turned in the project and threw it up on GotDotNet (this link will be dead in July of 2007), but of course, GDN will be gone soon. Just so it wouldn't be lost, it's now available here in C#. It's actually kind of fun, I think, as I put in some "jokes" - funny to me at least. For example, the OS pages it's virtual memory to XML files when it runs out of "physical" memory. It behaves like a real little OS. It'll thrash with low memory, and get fragmented if a lot is going on.
A tiny virtual CPU and OS written entirely in C#. The TinyOS simulates the scheduling, memory management (including paging and virtual memory) and other operations of theoretical Operating System. You’ll see many Framework classes and techniques in use including Regular Expressions, XML Serialization, generated Strongly Typed Collections, XML Comments and a generated Help file. You won’t get much useful work out of the TinyOS itself, but the techniques you’ll learn can be applied to real life.
Since this little ditty, others who really know what they are doing have written more serious OS's in C# that are worth looking at.
I presented on my little CPU/OS at TechEd Malaysia 2002, and the PPT slides are available as well. I also did it again in VB.NET if you like with a little trouble.
I looked at this code in 2005 and was shocked and offended with myself - well, not really, but it was enlightening to say the least.
Download Tiny OS in C#
Download Tiny OS in VB.NET
Go find some code that you wrote at LEAST FIVE years ago and tell me how it looks today...