Results

I flied!

Einstein was right. Time is relative to the observer. When you're looking down the barrel of a gun, time slows down, your whole life flashes by, heartbreak and scars. Stay with it, and you could live a lifetime in that split second.” - Max Payne

It was then I understood what Max Payne meant when he said the above sentence. It was 1 am, and I was staring at the grass. It seemed like the time was standing still, just like we see in movies. I could hear my heart beating. Thud, thud, thud… I looked to my sides. I saw my friends talking and screaming. But I couldn’t place anything they say. Our pilot was asking me to take a look at the view. I tried, but all I could think of was the green lawn. I felt like its staring at me. Things flashed in front of my eyes. But all I remember now is the sound of my heart beating. It was fast and heavy. I felt its going to explode. I wish for it to be a dream. After all, I was hanging upside down at around the height of a 4 storied building, from a pod with 3 of my other friends. There was a seat in which I was sitting at the beginning, but when we reached the top, the only thing which was holding us were the seat belts. Since we were hanging down, all we could see when we looked straight was the lawn, long down.

We were in the Giant Swing in River Side, Clarke Quay, Singapore. It was the birthday treat of one of my friends and the program was spontaneous. We had a great dinner and some cocktails and were relaxing at the River Side steps. That’s when the idea came to our mind, let’s do something crazy. There was a Reverse Bungee and Giant Swing. Since the bungee tend to turn around a lot and a lot speedier and we had a nice dinner, we settled for the Giant Swing since none of were in a mood to puke on such a nice day. I really regret not having my camera that day. Still I managed to get some images from net which I have posted at the end of this post. It is a pod attached to a swing where 5 people can sit, the only thing is that, its huge, ‘cos when you are held just b4 its released (at the highest point), it’s around the height of a 4-5 storied building.

Suddenly I heard someone screaming my name. “Are you there?” I looked to the side. It was my friend who was piloting the pod. When we reach the highest point, we could stay there for anytime we want and the ‘pilot’ had to press a button under the seat to release the swing. “Shall we press the button?” she was asking. I wanted to get this over with somehow. We all screamed “yeah!

She pressed the button. The world stood still for a moment. Then it turned to move fast, way too faster than anything I have felt before. I felt the weightlessness of a freely falling body. For a split second, I thought I was going to ‘touch down’ soon. I tightened my grip on the frame of the pod. I didn’t want to close my eyes. But I did it for a moment just before reaching the lowest point. I closed my eyes.

When I opened it, I was flying. Flying very fast towards the sky. I started liking it. I wanted to move faster. But the speed reduced and reduced and we reached the topmost point when the pod stood still again for a moment. I could see the whole Singapore in night lights from that point. It was beautiful.

I realized I was silent till then. The only one thing the person who fastened out seat belts told us was we were allowed to scream. But I had forgotten that. Then again the pod started its journey back. We all screamed at the top of our sound. “We are flyyyyyiiiiiiiiiiiiiiiiiiiiiiiing, woooooooooooooooooooooooo oooooowwwwwwww!!!!

We were swinging back and forth. It continued for some more time. But it was the starting swing which took our breath away. What else can I say, by the time we had to get out from it, I was in love ‘adventure’. All of us wanted to get more of it. But then again, we were not rich enough, at least at this point in life. The feeling was awesome. Wind gushing to your face and you moving so fast without any obstructions. I had heard that the original bungee jumping is really an experience and New Zealand is famous for that. If I decided anything when I was flying, it was this. Some day, I will go to New Zealand and do the original bungee where you jump from top of a bridge between 2 mountains to a river. Hope that day will come soon. Till then, I think I have to settle down for the adventures in Singapore.

Reverse Bungee - The towers near it is the giant swing

Another view

Once in a while…

There were times when I dreamed about spending my life with someone I really felt like spending my life with. I don’t know when, but somewhere along my life, I realized it’s just another dream. And I thought it will exist only in my dreams or in my imagination, where I meet a true friend, who understand the real me, even better than I know myself, with whom, I could be the real me.
Life started becoming silent. Time seemed to stand still. No matter how hard I searched, I couldn’t find a reason to move on. I had everything I wanted. I couldn’t even find any dreams or hopes about future. Too much silence in my life, and even in the middle of a concert, I felt alone. Life is ironic. You don’t get what you want when you want. There was a million times when I longed for a friend, with whom I could be comfortable by being silent. And when I expected a lot and nothing came along the way, I got accustomed. Hope had no place in my life, not anymore.
And suddenly one day, I noticed my life changing. I didn’t know what the reason was, but things began making more sense. Even the wind or the trees began making sense. I started noticing flowers. I had no idea, what was happening. I simply sensed some change, or I felt life’s getting exciting. I liked walking alone in the rain. I longed to be in solitude, the same loneliness that I hated the most about my life. Even songs started making sense to me. World started becoming more and more colorful for me.
It was her. I met her at the coffee house. First I felt she was too noisy, she was talking all along. I wanted to get rid of her so that I could finish reading my book. But, she came to me and asked, “Beautiful book, can I have a look?” I was a bit surprised. No one asked me anything anymore. The next day I went to the coffee house at the same time to get my book back, she was there. We talked for some time. I went back home. The next day, she wanted some help with her work, and we did it together. I felt good. The next day, I got there early, she was there, and we spent a lot of time together. I sensed that she was able to read my mind or she said the things I wanted to say. She felt it too. By the time I was about to leave, she hugged me and told me she liked me and I am like an angel to her. I hugged her back. I didn’t know what to say. She looked like she was glowing and she was the most beautiful thing that I had ever seen.
I had this feeling that I was at the tip of a mountain, so tall, even taller than the clouds, where I always wanted to be, but the weird part of it, I knew that I was about to fall. No matter how much I tried, I couldn’t get rid of that feeling. I wanted to get more time with her. I took off from my work the next day and I waited there for her. She didn’t come. I was sad, but somehow I expected this would happen. I didn’t know how to contact her. All I knew was her name. I was there at the coffee shop every day, waiting for her. But she never came.
My life had changed forever. I wrote to one of my close friends,
“Dear friend,
You know me long enough to know that I was always too choosy about friends. You used to tell me that someday, I will come across a person, a person who simply walks in to my life from somewhere, who will turn my world around. Yeah, that happened to me. It was good, better than anything I have ever known. But, she just walked away, leaving behind her footprints. No good bye’s, no see ya’s, she simply walked away. Now the only thing left for me is hope, a hope that someday I will get to see her, and if I am lucky, I get to spend some time with her, even If I know for sure that I will never be able to even hear about her. Why are all these things happening to me?”
His reply contained only one sentence, “Life is tough, my friend”.

EE5903 (RTOS) Assignment 1: Implementing M/M/1 queue using POSIX message queue

Since I spent around 2-4 days in completing this assignment, I thought maybe someone might find this useful in the future. Its not just the code for this problem. I had to learn other features like timers, signals, fork, and (ofcourse) Linux message queue. I had used some of them before but this assignment helped me in understanding them deeper. And I definitely enjoyed doing this assignment.

Disclaimer: Venture in to this blog only if you are interested, else it may be boring.

Problem Definition
Use POSIX Message Queues on Linux
• Producer produces serial numbered messages with exponentially distributed inter-arrival time (avg. 1s)
• Consumer processes messages with an exponentially distributed processing time (avg. 0.8s)
• Producer & consumer log system time and message serial numbers
• Run the system for 300s
Process the logs to compute the following
• Message loss percentage
• Average number of messages in queue
• Average latency (including processing time)
Fraction of time with more than 10 messages in queue

Design
I didn’t do any specific design, but I had some idea on how to develop this step by step. I started by testing the message queue in a sequential program. The function producer puts messages to the queue and consumer takes it in specific intervals. Then I integrated random intervals to make the producers output exponentially distributed using random number generators, then I made it 2 separate processes using fork and later I added signals, etc. The output is stored in to a log file and later that is parsed using another program called log_processor.c. I would like to add the entire development story here, but that would take up the entire space. So, if any of you have any suggestions or queries, drop a comment.

Code
msg_q.c
log_processor.c

Note: I am not able to post code in blog page (so many formatting errors) and I am looking for various options to upload in some site and give the link here. Please let me know if anyone have any suggestions. Also, if anyone want to have a look at the code, please leave a comment.

Individual Code Snippets
  • Random numbers
  • Fork
fork() is something I always had difficulty in understanding. The idea of same code running in parallel was a bit difficult for me to understand. The key point to remember here is, once the call fork is made, there are 2 instances of the program running and both will run the same code. So, in order to make them both do different things, we have to know which is parent and which is child and that's where the chpid comes in. If the chpid has a value greater than 0, we are in parent process. If it is 0, we are in child. And if it is less than 0, fork failed. simple, right? We can use an if(chpid > 0) condition and call different functions. Also, both are different processes and child or parent doesn't share any memory/variables, the advantage is, you can use for both, disadvantage, have to be careful when you use the variables.

  • Signals
  • Timers
One important point to remember here is, the function usleep() takes an input in microseconds and in some machines, it will not work for second resolution (for values more than 1000000). It may or may not work for values more than 1 second. Its always better to use values less than 100000 for usleep() and anything above that, split it to 2 and use sleep() and usleep(). The program below, I wrote to test whether it works in my machine. I found it was working, but in the final code, I used both usleep() and sleep().
LOG FILES
I am not putting the entire log files here. Just a small part.

1
302593147
1
2
303410285
0
3
304745777
0
4
305170614
0

Report
Here is the main part of the report I submitted. No fancy stuff, just the facts.

Output of log_processor.out file

Message lost percentage : 0.660066 %
Average Latency : 3.26471 seconds
Average number of messages in queue : 3.06954
Percentage of time with more than 10 msgs in q : 0.331126 %

Explanation

1. Since the producer sends the messages in a blocked state - it waits for the queue to be free, if its full - and also the queue size is almost infinite as compared to the number of messages we send, there is very less chance of a message being lost. However, since we run the simulation for a certain time, at the end of time, there may be some messages which are being processed at the consumer. That is the reason why we see a very small value for the percentage of message loss. If we run the test for a certain number of input messages, there won't be any message loss since the queue won't get full and also since we don't drop a message if the queue is full (blocking call).

2. Average latency is calculated by calculating the individual latencies and taking the average of them.

The implementation is an example of an M/M/1 queuing system.
In theory, the average latency of a message in a system is,
W = 1 / (service rate - arrival rate)
or
W = Waiting Time in Queue + Service Time
W = W.Q + S.T
W = (arrival rate) / (service rate) (service rate - arrival rate) + Service Time (0.8)

Arrival rate = 1/1 = 1 msg/sec
Service rate = 1/0.8 = 1.25 msg/sec

Avg Latency (from theory) = 4sec
Avg Latency (from implementation) = 3.264sec

Since the values are derived by statistical modeling of the system, a small variance will be present. Also, when the test is run for 600 seconds, the values are:

Message lost percentage : 0.34904 %
Average Latency : 4.85368 seconds
Average number of messages in queue : 4.58829
Percentage of time with more than 10 msgs in q : 14.1608 %

The test only will give a value which is approximately the theoretical value.

3. Average number of messages in the queue is calculated by calculating the average of the number of messages in the queue during instants after the producer puts a message in the queue and before consumer takes a message from queue.

Theoretical calculation:
Average number of customers in the system is,
L = arrival rate / (service rate - arrival rate)
L (from theory) = 4
L (from implementation) = 3.06954 ~ 3

In the test with 600sec, the value is around 4.

4. Fraction of time with more than 10 msgs in queue is calculated by finding the number of samples which had a message number greater than 10 and dividing it with the number of samples taken.
Percentage of time with more than 10 msgs in q : 0.331126 %

Details of Test machine
Linux Flavor : Fedora Core 7
Kernel : Ver. 2.6.21-1.3194.fc7
Compiler : gcc Ver. 4.1.2 20070502 (Red Hat 4.1.2-12)
VMware : VMware Server Ver. 2.0.0 Build 116503

Processor : Intel Core 2 T7200 @ 2.00GHz each
RAM : 2.00 GB
Make : Alienware Area-51, m9750

References
http://www.ecst.csuchico.edu/~beej/guide/ipc/mq.html

Back to College Days: Trip to Melaka, Malaysia

I was going nuts trying to crack my wireless protocols assignment when that mail popped up in my maibox. “Trip to Melaka, Organized by NUS”, anyone interested? I believe in a principle which goes like, “Never say No to friends”. That’s how it all began.
Day: February 28, 2009, Saturday
Time: 0630

No no, its not the time when I woke up to study, but it was the time we gathered in front of the sports hall (our gathering point) to start our trip. I had no idea what to expect or what exactly is this trip about and what is there is Melaka. For me, it’s all about spending time with my friends and taking a break from my hectic schedule. So I didn’t have any expectation about my first international trip except that I knew there will be one more county’s stamp in my passport. But it turned out to be one of the most memorable days in my life and I went through a lot of feelings I thought was lost forever - the feelings and colors of college days - it felt like being back in my undergrad days.

Just like a dream!

A beautiful Chinese Letter carved in a rock in a temple. I have no idea what this means!

Old drawings in the wall of a temple

Our lunch and dinner was fabulous.
There are 2 things I like for a meal.
1. A delicious meal, as usual
2. A good company to start digging in to the task
And this was one of those rare occasions when I had both. For both lunch and dinner, there were around 7-9 dishes, with chicken, crab, prawns, fish, shark, vegetables (I didn’t concentrate in this area much), and dessert. Also, I think they were authentic Malay dishes, but since all of us were Indians, we had not much choice to get clear idea about the names of the dishes. Even if there were some means to get to know the names of the dishes, I seriously doubt we would have done that, ‘cos we were all very busy ‘fighting’ across the table that there was no time to talk.

A busy Melakan Street.
Since the city is kind of an old city, the streets are narrow. The buildings were painted really colorfully and you don’t get the feeling of a city.

In front of the Church of Christ

Who we are? (Click on the photo to read)
From Right
My House Owner : Aniket (My Housemate and a very dear friend)
My Financer : Ashwin (Friends for past 9 years)
Would be Dr. : Karthik (A new guy I met on the trip day, doing PhD in NUS)
Possible Roommate : Sampath (A possible future roommate)
Shashi Sir : Robin (A great friend who is my current roommate)
From Singapore : Girish (He is from Singapore itself)
Classified : Classified (;))
The Trouble Maker : Srijith (Karakku company)
Me : Me (You put your definition in the comment section)

A busy day in the Museum

Stairs to the courtyard or heaven?

F.R.I.E.N.D.S

Melakan Street: A view from the Top

An Ancient church in Melaka
This church - I think the name is St. Francis Chruch - is located on top of a small hill from where you get a really gorgeous view. It really was fun and soothing being there, enjoying the wind, and the songs of the native singers and there were several artists doing live drawing/paintings.

The Native Singers

A View from the Church

Tea Time: A Coffee shop in Melaka

Yeah, The Trouble Makers
No intro needed I guess. We went around looking for a coffee shop and had some fun and got lost from the group. We had to roam around for a while to find the group. Since it was another country, our mobiles didn’t work, we went back to the place where we started and the group was gone. Our choices were to go back to Singapore on our own - The Red Bus - or to go to the police station and ask for help. Before choosing from the above options, we asked some of the pedestrians for their mobile and called one of our friends and somehow got back to bus. And we heard some ‘sweet’ words from the ‘nice’ people who were waiting for us. The poor tour guide went around looking for us and came back exhausted to report he couldn’t find us, and we were there. Since he was a very good person, he didn’t tell us anything.


The End: The GSS group from NUS
I would like to thank all of my friends and whoever else who made that trip possible, because of whom I had one of the most memorable days in my life.
More Photos @ http://picasaweb.google.com/gssmalacca/TripToMelakaMalaysiaFromGSSNUSByManuIgnatius?#

ps: There are a lot more things I would love to write about this trip, but I am too sleepy now. Also, this was supposed to be a cultural trip.