Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary Embedded System Interviews Questions

Rating
-
Sold
-
Pages
32
Uploaded on
13-08-2022
Written in
2021/2022

Embedded System Interviews Questions that will help you pass the exam easier

Institution
Course

Content preview

Embedded System Interview Questions


Const & Volatile


Const and Volatile are not opposite of each other!

Const - A variable whose value can not be changed, that is a
constant. A programmer can not change the value of a variable
declared as constant later in program. If it is not initialized at
deceleration, it can not be assigned/initialized later.

An integer constant can be defined as:

const int myConst = 10;
int const myConst = 10;

Both the declaration have the same meaning. But in case of
pointers, things are different.

const int *myPtr = (int *)0xFFFFFF04; /* 1 */
int const *myPtr = (int *)0xFFFFFF05; /* 2 */
int* const myPtr = (int *)0xFFFFFF06; /* 3 */

Declaration 1 & 2 are the same and indicates the myPtr is an
ordinary integer pointer and the integer pointed by it can not
be modified. As a programmer, I can modify myPtr as:

int anInt = 10;

,myPtr = &anInt;

But I can not do:

*myPtr = anInt;

However, the deceleration 3 defines a pointer myPtr that can
not be modified but the value pointer by it can be modified.



Const, actually volatile also, variables are useful in real-time C
programs. A const variable may never be initialized. An use
case of this can be a the address of memory mapped I/O which
is read only.

Volatile - Linux for you and Netrino articles have clearly
explainedvolatile keyword. So, I will just be summarizing it
here.

When a programmer declares a variable volatile, (s)he informs
the compiler that the variable at any time during the life of
program can change its value, so be careful while optimizing
the code. In reference to the example of memory mapped I/O, I
would define a pointer holding the address as a const variable
but the value pointed by as volatile.

volatile int* const memIO = 0xFFFFFF05;

Some more declerations.

int volatile alcohol;

,volatile int alcohol; /* are the same - alcohol is volatile */

Now the pointer and volatile.

volatile int *myPtr; /* ordinary integer pointer to
volatile integer data*/
int* volatile myPtr; /* volatile integer pointer to
usual integer data*/
volatile int* volatile myPtr; /* volatile integer pointer to
volatile integer data*/



Now do NOT confuse in an interview.

Usage of volatile variable (as pointer in Netrino article)

 Memory-mapped peripheral registers

 Global variables modified by an interrupt service routine

 Global variables accessed by multiple tasks within a multi-
threaded application

What does volatile long * const timer = 0x0000ABCD mean?

, C Questions
As a C programmer you would like to give some thought to
following C question.

1. Can structures be passed to the functions by value?

2. Why cannot arrays be passed by values to functions?

3. What are advantages and disadvantages of using macro
and inline functions?

4. What happens when recursion functions are declared
inline?

5. What is scope of static variables?

6. What is the output of printf("\nab\bcd\ref"); C
statement?

7. #define cat(x,y) x##y concatenates x to y. But
cat(cat(1,2),3) does not expand but gives preprocessor
warning. Why?

8. Is it possible to define a constant volatile variable?

9. Is it possible to define a volatile pointer?

Written for

Institution
Course

Document information

Uploaded on
August 13, 2022
Number of pages
32
Written in
2021/2022
Type
SUMMARY

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
beshoget2014

Also available in package deal

Get to know the seller

Seller avatar
beshoget2014 Many companies all over the world
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
48
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions