Tuesday, December 18, 2007

Google Interview Questions Part 4

Here are some other questions and solutions

Q: N threads .. n resources .. what protocol do you use to ensure no deadlocks occur?
A1: Avoiding Deadlocks with Lock Leveling, each thread would have different level, thread with high level would be able to lock thread with lower level but not contrary.
A2: Avoid acquiring more then one lock at a time.
A3: Acquire the lock always in the same order. A4: Shrink synchronized blocks.

Q: You are given a the source to a application which is crashing when run. After running it 10 times in a debugger, you find it never crashes in the same place. The application is single threaded, and uses only the C standard library. What programming errors could be causing this crash? How would you test each one?
A1: It might be using time, or perhaps random numbers. Or it does nasty things with memory. Or it could be running under windows.
A2: There might be multiple recursions in the code which are causing a stack overflow, cause "Out Of Memory" exception
A3: A probable cause would be an uninitialized pointer/variable being used

1 comment:

viagra online said...

Excellent interview, almost everybody uses Google, it is good to know some information about the company.

Links

 
RSS Feeds Submission Directory