Qualcomm Interview Question for Software Engineer / Developers






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

AFAIK, in regards to storage, there is no difference between variables declared as volatile and non volatile variables. So the variable may be on stack,heap or in the data section of executable, depending on how it gets defined. The volatile qualifier just tells the compiler that this variable may change in ways that are not apparent to you (for example by another thread of execution etc). The compiler then disables some optimizations(like caching the variable in a register).

- Jasmeet bagga April 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes rite!
Volatile is type qualifier not a storage class specifier.

- divyaC April 23, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if it is static volatile ?? where the variable can be stored??

- Narayana Rao May 06, 2015 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Objects declared as volatile are not used in certain optimizations because their values can change at any time. The system always reads the current value of a volatile object at the point it is requested, even if a previous instruction asked for a value from the same object. Also, the value of the object is written immediately on assignment.

When optimizing, the compiler must maintain ordering among references to volatile objects as well as references to other global objects. In particular,

A write to a volatile object (volatile write) has Release semantics; a reference to a global or static object that occurs before a write to a volatile object in the instruction sequence will occur before that volatile write in the compiled binary.

A read of a volatile object (volatile read) has Acquire semantics; a reference to a global or static object that occurs after a read of volatile memory in the instruction sequence will occur after that volatile read in the compiled binary.

This allows volatile objects to be used for memory locks and releases in multithreaded applications.

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

abt Volatile keyword and Optimizing Compiler..

How volatile key word works exactly ?
You said it exactly correctly above. It prevents the compiler
from holding the variable's value in a register. it forces the
compiler to generate a fetch of the value from memory every time
the variable is referenced, and if the value is modified while
in a register, it is immediately stored to memory.

> Will the volatile variable be stored in Cache ????
Not just as a result of the volatile keyword, no.

> How it is getting the updated value every time ????
By generating code to re-fetch the variable *every* time.

> Will it be possible to access Memory by bypassing the
Cache ???
Not by using the volatile keyword

- motu July 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Guys..the first answer is about the volatile variable in Java..there is some differences between volatile keyword in C & Java..

- Temp October 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
main()
{ printf("Enter the Function");
}

- Anonymous February 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

wrong answer

- Anonymous April 16, 2010 | Flag


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