Thursday, April 21, 2022

Friday, November 15, 2013

C++ and dynamic datatype at run-time

Recently I was working on C++ code that had bunch of if-else statements that resembled following. As you can see there is common code however datatype of couple of variables varies based on the condition.
You can see the pattern here! So moved the common code to a function template of the form
So far so good. However in order to invoke the right function I still needed to use if-else block which was an eye-sore
To avoid if-else block, I decided to use a jump-table using map where key would be datatype (string) and value would be function to be invoked.

In addition to UConfigParam type variables, I needed to add support for other variables of the form UStateVar. To achieve this, I simply added more entries to the ProcessFuncMap without changing code for function invocation or piling up if-else code block.

So there you see, using a combination of function templates and a jump table at run time dynamic declaration of variables is achievable.

If there are known design patterns or other techniques that help achieve same in C++ I'd like to hear about them.

Sunday, December 4, 2011

Readings in Distributed Systems

This is a meta-list of readings in Distributed Systems. I'll update them as I come across more papers or lists.

Nicely categorized list by Marton Trencseni of Scalien
http://bytepawn.com/readings-in-distributed-systems/

Quora answer by Alex Feinberg of LinkedIn includes great list of seminal papers in Distributed Systems:
http://www.quora.com/What-are-the-seminal-papers-in-distributed-systems-Why

Another good list by Swami Sivasubramanian of Amazon
http://scalingsystems.com/2011/09/07/reading-list-for-distributed-systems/

List of advanced CS courses (not limited to Distributed Systems)
http://the-paper-trail.org/blog/?page_id=152

Saturday, September 17, 2011

HD Audio in VMware Fusion 4 and VMware Workstation 8

I was part of Interactive/Virtual devices team at VMware and it was a great learning experience.

In my last 18 months at VMware, I worked on designing and implementing virtual HD Audio device and now since releases of VMware Fusion 4 and VMware Workstation 8 have been made public I can talk about it :)

In addition to Windows Vista and above guests, virtual HD Audio device should work out-of-box for Mac OS Lion 10.7 guests on Fusion 4.0 and hence Fusion users will be able to get sound from their Mac OS guests. Linux guests (3.0+) are supported as well. Patch submitted to Linux kernel that enabled support for Linux guests with VMware HD Audio device.

Virtual HD Audio supports upto 7.1 surround sound, 192kHz sampling frequency, 32-bit samples.

I just downloaded the Fusion 4.0.1 GA and was eager to checkout how well the feature works with Windows 7 guest. Here is a screenshot...

From Blogger Pictures



We've had trouble getting good sound quality with surround sound on Linux hosts with VMware Workstation 8 with default settings.

If you want good quality surround sound support on Linux hosts with Workstation then I'd recommend using channel-mapped device string as follows: (We couldn't implement this programmatically because of stability issues with alsa-lib that enumerates devices on Linux).

1) Suspend/Power off the VM.
2) Run `aplay -L` on your Linux host terminal
3) If you are playing 5.1 surround sound from the guest then copy surround51:CARD=vendor-name,DEV=num
For e.g. `surround51:CARD=Live,DEV=0`
4) Open .vmx config file of the VM in a text editor and edit sound.fileName field
For e.g. sound.fileName="surround51:CARD=Live,DEV=0"
sound.autodetect = "FALSE" should be edited too.

5) Resume/Power on the VM

Similarly if you face quality issues with regular stereo sound on Linux host with Workstation 8.0 then you can try the above mentioned suggestion with device string starting with "front".

Monday, October 26, 2009

ALSA sound support for VMware Workstation 7.0 and VMware Player 3.0

I work in the Interactive Devices team at VMware, focusing on the virtualization of sound device. The company will be releasing VMware Workstation 7.0 tomorrow that includes the long overdue ALSA sound support for Linux host operating systems.

The Open Sound System (OSS) API used in earlier versions of workstation didn't support software mixing of sound streams and therefore the infamous "Sound will be disconnected. /dev/dsp is busy" message when powering on a VM. With ALSA support, the VMs and sound applications on host operating system can access the sound card simultaneously.

The technical details for configuring sound device in VMware Workstation 7 are documented here .

I encountered some inconsistencies while enumerating sound devices using ALSA. So if your system has multiple sound cards and your sound card isn't listed in the VM Settings UI then follow the instructions under "Using an ALSA Sound Device that Does Not Appear in Virtual Machine Settings".

Workstation for Linux also includes the ability to change the sound API used on-the-fly. For instance, if your physical machine has multiple sound cards, where one sound card is dedicated for VoIP and other for music applications, then you can direct sound output to desired device/interface by navigating in the UI to VM --> Settings --> Sound Card --> Specify host sound card --> Save.

In order to maintain backward compatibility if for any reason ALSA cannot be used then automatic fallback to OSS is provided.

For comments/feedback I can be reached at bbhavsar at vmware dot com

Monday, July 13, 2009

Coldplay

I've been hooked to Coldplay lately. They are performing live tomorrow in Mountain View but sadly I won't be able to attend it. As always late in booking tickets for such events...
Anyways "In my place" and "Clocks" from the previous album "Rush of Blood to the Head" are my favorite Coldplay songs.
Recently I stumbled upon music video of "Warning Sign" and really liked it. Apparently this one is made by a student who won award for best music video :)

Thursday, December 11, 2008

China Trip experience

Currently I'm at the Shanghai airport heading to Bombay thinking what to do. So I thought lets write about my experience at China :)

I was in complete awe when I went from the Shanghai airport to my sister's home. Very good multiple lane roads with directions in English and Mandarin. Skyscrapers and huge apartment buildings and bridges with neon lights everywhere.
I spent in all 3 days in Shanghai. It was very easy to get around as my sister took me to all places with a chauffeur driven car :) Covered places including the Yuyan garden, Jade Buddha Temple, Longhua Pagoda etc. Most impressive was the recently inaugurated Shanghai World Financial Center. It has a
shape of a bottle opener. I think currently its *one of the tallest towers* in the World (yes taller than Petronas in Malaysia). Visitors can go all the way to the top level where flooring is made of glass tiles! So you can actually see the bottom and I can tell you it was very scary to step on it :)

Next I went to Beijing for 2 days by myself. On the first day I visited the Forbidden City, Tianamen Square and strolled around in the neighbouring areas. My life was made easy by the Lonely Planet Beijing City Guide that I was carrying with myself from the US. I could see the influence of Olympics as I could still see signs of Beijing 2008 at most places. Also Olympics contributed towards many infrastructure developments in the city. They added around 5 additional subway lines from the earlier 2! It was very easy to get around using subway. I could see lot of buses plying but it would be hard to figure which bus to take, where to get off etc. Taxis are relatively inexpensive starting from 11 Yuan.(1 USD == 7 Yuan approx)

I stayed at an international youth hostel which was pretty cheap for around 60 Yuan for 1 night. I met groups of backpackers there. It was just amazing to hear about the plans they had. Some heading to Africa from Beijing, some going to Moscow taking the Trans-Siberian train which will take them 15 days!

Next day early morning we headed to visit the Great Wall. We took the 10k trek on the Wall starting from Jingshanling which is 120 km from Beijing. Trek was hard, really hard as the Wall has steep inclines. Moreover it was made difficult by the first snowfall of the winters on that day. But the experience was just breathtaking!

About the food, I could see that Chinese are big on pork. Inspite of being non-vegetarian it wasn't easy to find food with just chicken/sea-food. Also even at the upscale restaurants the waiters won't understand English much, so its hard to customize your dish like replace pork with chicken, no mushroom etc. I relied on the McDonalds/KFC for my meals. If you are a vegetarian visiting, hmmm.... I noticed that the decibel levels at the restaurants are relatively high. Initially I thought there is some fight going on in the restaurant but that was the case at most places.

I would highly recommend visiting China, Shanghai in particular just to have a look at the pace at which the city/country has progressed. We keep reading about articles suggesting the shift of power from West to the countries in Asia specifically to China and I won't be surprised that in next 25 years China emerges as the new superpower. Also the talk about transforming Mumbai to Shanghai, I would be glad if that does happen :)

Tuesday, September 16, 2008

Golden Rules of Career Success

I'd come across Golden Rules of Career Success by Richard Moron during Infy days.
I had taken a printout and put up at my desk in Infosys. I did the same during my 1st week at VMware as well :)
With the recent financial turmoil happening in Wall Street those rules seem to make much more sense.

Esp "Job security does not exist. Always have an answer to the question, “What would I do if I lost my job tomorrow?""

Thursday, July 31, 2008

Interactive VMW Wikichart

I know that the VMW stock isn't doing great these days but I thought this was cool....

Monday, July 21, 2008

Sparks: Speech by Chetan Bhagat

Though I haven't read his books, the speech is very inspiring.

read more | digg story

Monday, February 25, 2008

Insecure routing redirects YouTube to Pakistan

A black hole route to implement Pakistan's ban on YouTube got out into the Internet's routing system, which can't effectively protect itself against this type of mistake—or attack.

read more | digg story

Thursday, February 21, 2008

Pictures of Last Night's Lunar Eclipse

The Earth passed between the sun and a full moon last night, sending our interstellar sidekick into rusty shadow and Wired Science readers to their cameras.
Pictures Link



read more | digg story

Tuesday, February 12, 2008

Addicted to a song!!

Usually my day starts by turning on the laptop and starting some music. This continues in the car as I drive to work. Well I'm not boasting but my Acura has one of the best sound systems!! Its a pleasure to drive listening to my fav music.
I haven't charged my iPod so been listening to FM lately (94.9 FM in Bay Area). Yesterday while driving back I heard this song and really loved it. I tried hard not to forget the main line of the lyrics so that I can go home find it on Youtube. But I come back home and a friend calls up. I speak to him and after the call I somehow forget/jumble up the lyrics :( I try hard remembering but some other song shows up in the search. Eventually I recollect the lyrics and find it on Youtube. yay!!
I listened to this song in repeat mode almost the entire day today at work!! Well this is not the first time that I've got hooked onto a song. I'm sure I'm not the only one :)
So here is the song "Hey There Delilah" by Plain White T's

Thursday, January 31, 2008

Microkernels: Tanenbaum-Torvalds debate

Very interesting article by Andrew Tanenbaum (Remember the OS book we studied from :) )
Excerpt: "Over the years there have been endless postings on forums such as Slashdot about how microkernels are slow, how microkernels are hard to program, how they aren't in use commercially, and a lot of other nonsense. Virtually all of these postings have come from people who don't have a clue what a microkernel is or what one can do. I think it would raise the level of discussion if people making such postings would first try a microkernel-based operating system and then make postings like "I tried an OS based on a microkernel and I observed X, Y, and Z first hand."

read more | digg story

Saturday, January 26, 2008

America's 25 Fastest-Growing Tech Companies

It has been a rough 12 months for the stock market, including technology stocks. The S&P 500 is off 2.1% over the past 12 months (dividends excluded) and the Nasdaq 100 Tech Index is off 8.7%. But you could have done well owning these really hot technology companies.

read more | digg story

Thursday, January 24, 2008

Taxpayers could get checks under economic stimulus plan

American taxpayers would get checks of several hundred dollars from the government under a plan to stimulate the economy, sources said Thursday.

read more | digg story

100 Best Companies to work for 2008

100 Best Companies to work for 2008

digg story

1 Rogue French trader costs bank $10.2 billion

French bank Societe Generale has announced losses of 6.9bn euros ($10.2bn, £5.2bn), blamed on a fraud by its trader and the credit crunch.

read more | digg story

Tuesday, January 22, 2008

The 53 places to go in 2008

Collection of exotic places to visit in 2008. Nice guide for people who like traveling and discovering new places...
I was discussing with a friend places that I would like to visit in the US mainly Boston and Washington DC... Its a pity that I didn't visit them when I was on the east coast :(
Also I had a look pictures of Hawaii sent by a friend and it looked beautiful.. Outside mainland US, Hawaii and Alaska are top on the list :) Lets see how soon I get a chance to see them....

Places I've visited....




digg story

Tech's all-time top 25 flops

For all the amazing advances that the computing industry has brought us over the years, some of its most pivotal moments are memorable for all the wrong reasons. Not every idea can be a winner, and not even Microsoft can avoid every misstep. Infoworld Article

read more | digg story