The Operating System Saga

This is a story of an individual who took one of the most dreaded course at NCSU in the Spring of 2013. This apparently insane course is called Operating Systems. The highly project oriented course at the end of which you would want to take a world tour to make up for everything you missed during the semester. It all starts in a classroom filled with 120 students, prof and TAs who have this I-know-it-all-you-guys-are-dumb look. The first sentence said by the prof “This is a tough course, hope you will have fun”. I guess her idea of fun was taking student’s minds and boiling them in a frying pan at precisely 320F with a pinch of salt. But oh well, after all the battering and ramming the 80 of us who remained rose from the ashes like a phoenix, chiseled and moulded to face any challenge thrown at us. Although, some of us who lost our minds had to vent out, by hysterically laughing through a weekend.

Spoiler Alert – This course was actually as tough as advertised. (unless you were bloody brilliant to start with)

Boasting Alert – I got an A+ in this course :P

tldr; → skip to the last paragraph.

PA0 – The initial Jerk

The Programming Assignments were abbreviated as PA followed by increasing numbers, complementing their difficulty. PA0 was the first one, it was a waking call, it was the calm before the storm.

PA0 was where we first tried our hands on XINU ( Xinu Is Not Unix). XINU was a small OS developed for academic purposes at Purdue university. Why Xinu? Why not Unix or Windows with lot of documentation and possible online help? Probably because our prof thought they would too easy or she wanted to show how “hell” looks like or she was just plain mean. Who knows?

Anyway, PA0 included us looking into some files of XINU and trying to understand how XINU worked. We had to modify Process Control Block (PCB) entries and print some of them to see how PCBs were affected during process execution. We had to print process stacks and draw its structure. One thing that took a day to solve was printing local variables of a stack. It should have been a simple task right? Just print the values below where EBP points. But it was harder than that because we did not think of one sweet little detail called Compiler Optimization. If that is not turned off, the whole OS is complied with optimizations and the local variables if unused are never printed.

PA1 – The Steam

PA1 had C programming along with XINU programming. Why? Because apparently just XINU programming was not hard enough on our already battered soul.

PA1 included developing schedulers for XINU with two policies and a multithreaded C application. For XINU we developed two schedulers 1) Exponential Scheduler and 2) Linux-like scheduler. Exponential scheduler included implementing some mathematical functions and randomizing values to decide which process should be next executed based on its priority and how close it is to this mathematical expression’s value.

Linux-like scheduler involved calculating quantum values for every process based on its priority and scheduling the process based on its value. It also involved quantum carry-over for blocked process to ensure fairness.

For the C application we had to search a string in a large text file using different number of threads that varied from 0 to 100. To calculate time during such an operation and plot a graph. This was good assignment as I had a lot of fun coding and also, I learnt that increasing the number of threads does not necessarily decrease the execution time. It does until a certain number of threads, after which the overhead of managing the thread will become more difficult than the benefit of parallel execution

PA2 – The Heat

This was first assignment I did a complete night out with 24hrs no sleep. It was totally worth all the effort. For PA2 I had to develop a synchronization framework for XINU that was similar to Readers-Writers lock and take care of all the complications that arise from it like Priority Inversion.

This involved a lot of testing, failing, denying, recouping and finally succeeding just to fall in the vicious loop again. In this assignment we had to develop data structures to store the locking mechanisms and only allowed processes to execute or access data if it adhered to the locking policy.

The worst part of this assignment was testing, “re-building, restaging, regressing” the code. We did not know what test cases the TAs were going to check and it might exactly be the one you did not test.

Survey Paper Assignment – Because PAs were not stressful enough

Everybody in the class had to write a small survey paper on some special topic that broadly included multi-core, cloud computing, virtual machines and big data. Me, being the expert of complicating things combined two of the above topics and chose the topic “Live Virtual Machine Migration in Clouds”. I had to enlist 12 papers from specific conferences and read them. Once I understood the subject clearly I had to write a paper that included methods and procedures from all the papers. This was something I liked a lot because it just came to me. I very easily got the knack of what was expected and what needs to be done to get it done. I started doing it pretty late, almost just 3 days before it was due and I was still able to give a good paper that was scored high. Most of all, I was happy that I wrote a paper after all those years of dad( an academician) urging me to write a paper and getting into research.

Extra Credit – Class presentation of your Survey Paper – Because just finishing the course was too mainstream.

Having a complicated topic for survey paper paid off. I was chosen to present my paper in front of the class for extra credit. Although at that time I was apprehensive as to whether accepting to present was a good decision or not. But now I know it was the best decision, because while I had to prepare my topic for presentation I understood the topic better. I had to be ready for any situation, especially one with an onslaught of questions from my fellow classmates.

Overall, the presentation went well and I was asked only four questions and only for one of which I had to give a diplomatic answer, you know,  the usual “I’ll look it up and let you know”.

PA3 – The Final Take off

3 being the largest number given to all the PA was definitely the toughest. It was massive and the one that required a lot of brainstorming anda tiny bit of swearing. In PA3 we had to implement “Demand Paging” for XINU. Yes, you read that right, we had to implement paging for XINU that usually runs like a monolithic architecture system with only the limited memory available.

This assignment involved a lot of thinking, corner case handling and proper “writing in functions instead of long monolithic code” It was a lot of fun, we had to keep track of a lot of things and we had to understand a lot of things and take care of a lot things. This project made me realize to some extent the power of human interaction and the ways ideas form. Just by brainstorming we were able to develop, design and ideas just kept coming the more we discussed. We all wrote our own separate code but every problem was brainstormed and immediately after brainstorming we would have a solution everybody could implement. It was simply amazing.

In this project I had to allow processes to access virtual addresses, emulate a backing store, develop two policies for page replacement, write ISR (Interrupt Service Routine) and allow memory allocation in virtual space.

Serious Note:

I highly recommend everybody take this course or a similar tough course during their graduate study. I recommend this course even if you are not interested in Systems because tough courses like this change your thinking, they give you immense learning opportunities and help you learn how to solve problems effectively. They teach you how each and every change you make will cause a huge domino effect that will affect everything you did. And lastly it helps bond with friends facing the same hardships, you can sit together and collectively abuse the prof and TAs. Remember, I had to do all the above assignments along with two other courses and exams that were nowhere straightforward. The best part was that the first sentence said by the prof was true, it definitely was a fun course.

About Narayana Ravikumar

Hi, I am Narayana Ravikumar from North Carolina State University. I love web and system programming. I am currently finishing my masters at NCSU. Check out my 'about me' page here.

01. July 2013 by Narayana Ravikumar
Categories: Diary, Programming | Tags: , , , , , | 11 comments

Comments (11)

  1. hello boss, I will be joining MS-CN course, I wanted to ask under which teacher u took OS??, like I was also lookin to take in the next sem..,

  2. Hi,
    I am coming to NCSU in Fall 2013, for MS in CS (non-thesis). I have enrolled for OS (under Vincent Freeh), Database Concepts and Software Engineering. I read your post and found it really interesting.
    I wanted to ask, is it a bad decision to take these subjects together in the first semester itself? Will it be too much to handle?

  3. i should say you did a commendable job to scare the incoming batch :P

  4. Hey Narayana. Awesome account. could really feel what you guys would have gone through.

Leave a Reply

Required fields are marked *