Posts Tagged interview
If you are power linux/mac user you should have noticed at least once that top shows more than 100% CPU for a process. I also have seen this multiple times but always wondered how it can be. Here is an example of how my top looked when I started my java and was doing some number crunching.
Recently I did a bit of research and got to the bottom of this. So here is the reason for it. A process is said to be using 100% CPU if it uses a processor to the limit that processor goes ie it completely uses that CPU without giving any idle/free time for that CPU. Now consider the situation that we have a multi core CPU. What if the process has more than one thread ? Well if so there is a chance that the threads can be split between two cores. So if 100% is one CPU running at maximum power, then what is one CPU at maximum power and other using 10% of its computing power? Its 100% + 10% = 110%. That’s how the magical more than 100% CPU value comes in.
This is not my code alone. It was the group effort of Vivek Ram, Cijo George, Sandeep Unni and mine during our epic preparation for Yahoo!. I am just putting it open for others who would be looking for this information. Read the rest of this entry »
Here is a compilation of how the preference of operators are Left to Right grouping or Right to Left grouping in C. Read the rest of this entry »