NVIDIA Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
4
of 4 vote

Single word read and write is atomic on x86 SMP system. So no need for locking the statement a=b. Its atomic by nature. Even if you use spinlock to protect a=b, any thread reading a will either get previous value of a or new value(ie b). And without using any lock for a=b, will also have same effect on any thread reading value of a. So no need to lock a=b statement

- Dinesh December 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

disable all interrutp when this statement get executed in case of uniprocessor.

- sem April 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

As per ARM , you can use swp instruction which will hold/lock the bus and store the value of b in a.
Cant say about x86.

- chinmoy September 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

swp instruction is deprecated for version < ARMv7
on v7 you have to use LDREX (exclusif load) in combination to STREX (exclusif store)

- s sintes February 21, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

if you allow oops, Put the above methods by Dinesh, chinmoy or sem inside a constructor, that will make a=b sweet rather than enabling and disabling interrupts everytime you do an assignement. Further RAII will take care of enabling the interrupts if something goes wrong

- abhityagi85 January 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a and b could be grobal variables and multiple processes could be modifying a or b at any time without using a lock.

In such case

.........

b = 1;

<======== (some process changed b here. Let b = 100)

a = b; (we think a =1, but a = 100 now!)

.....................


Use atomic_set(atomic_t *v, int i);

this atomic family is implemented in assembly lanuage since architecture depended. They are atomical.

- Dirk April 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You must disable all the interrupts if the variable can be referred in ISR, moreover, you maybe need disable preempt, there is other process maybe use the variable.

- caobingbu March 01, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More