NVIDIA Interview Question for Software Engineer / Developers






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

The usual four examples of volatile objects are:

1. an object that is a memory-mapped I/O port
2. an object that is shared between multiple concurrent processes
3. an object that is modified by an asynchronous signal handler
4. an automatic storage duration object declared in a function that calls setjmp and whose value is changed between the call to setjmp and a corresponding call to longjmp

uw714doc.sco.com/en/SDK_cprog/_When_to_Use_volatile.html

- T.J. February 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

indicates that the variable can be modify from somewhere else and thus compiler will not apply any optimizations (if any could be applied ) to it

Usually the case while using threads....

Similar to transient keyword in Java

Correct me if im wrong

- camSun April 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Ya, he was expecting a working example.

- Abhi April 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

ususlly Volatile is used in shared memory, memory mapped hardware operation ,were we dont want compiler not to modify volatile variable

- malli June 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

ususlly Volatile is used in shared memory, memory mapped hardware operation ,were we dont want compiler not to modify volatile variable

- malli June 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

using volatile you ensure that every time value will be fetched by memory directly.
There is only one reason to use volatile when you want to interact with hardware

- Anonymous December 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Also its not the same as transient in Java

- camSun April 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

ya true.. volatile and transient are different keywords in java

- priya July 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

a working example can be as follows: suppose the attached printer to ur computer is memory mapped. So the controller takes some bytes in RAM to get and requests from/to the CPU. One of the valuable variables in printer controller is : control register . But coz of memory mapping it gets (say) stored at some memory location. So if we dont declare this control variable in our driver code then optimized compilers at run time will store it in local cache of CPU which leads to chaos. consider the case when CPU for some application want to command the printer for printing. so first it has to check the status of printer (busy/idle). But coz control variable is in cache , may be that printer just before 1 instruction back to app. instruction updated the control variable in RAM indicating busy signal which was not updated in cache . So CPU unknowingly kick off the spooled file to printer and the chaos happens. Tell me if i am wrong somewhere.

- mrn June 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

suppose we take woking ex of measurement of temperature for perticuler scientific experimt then every sec temp may change and it should be noted and stored so here making
temp volatile will not make it load and store everytime..

- priya July 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Clock variables which contains number of tics, usually mapped to HW reg
extern const volatile unsigned long int clock64

- StoicMonkey August 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A lot of examples for volatile are very constructed, because most modern compilers won't optimize the code anymore in ways that you really need volatile with very few exceptions.

One real-world example I did find is a threadsafe implementation of the Singleton pattern. MSDN has an article on implementing threadsafe Singleton in C# using volatile to use double-checked locking the right way.

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

better example is Real time clock in which u need the actual value from the memory location rather than from ur cache.

- yadav July 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

RAM. use as memory. That is volatile in nature.

- Anonymous September 02, 2012 | 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