Suppose there is a global variable & a static global
variable.Both gets memory allocated from the data segment.
Then how does the visiblity of static global varible gets limited to the file alone
(in which it gets declared)
Submitted by: AdministratorStatic variables are local in scope to their module in which
they are defined, but life is throughout the program. Say
for a static variable inside a function cannot be called
from outside the function (because it's not in scope) but is
alive and exists in memory. The next time this function is
entered (within the same program) the same chunk of memory
would be accessed now retaining the variables old value and
no new memory is allocated this time for this variable like
other variables in the function (automatic variables). So
basically the variable persists throughout the program.
Similarly if a static variable is defined in a global space
(say at beginning of file) then this variable will be
accessible only in this file (file scope).
Submitted by: Administrator
they are defined, but life is throughout the program. Say
for a static variable inside a function cannot be called
from outside the function (because it's not in scope) but is
alive and exists in memory. The next time this function is
entered (within the same program) the same chunk of memory
would be accessed now retaining the variables old value and
no new memory is allocated this time for this variable like
other variables in the function (automatic variables). So
basically the variable persists throughout the program.
Similarly if a static variable is defined in a global space
(say at beginning of file) then this variable will be
accessible only in this file (file scope).
Submitted by: Administrator
Read Online VxWorks Job Interview Questions And Answers
Top VxWorks Questions
☺ | What is priority inversion? |
☺ | Explain task spawn in vxworks? |
☺ | Write a code to connect Hardware interrupt to ISR and explain? |
☺ | What is another for creating a task without using taskspawn? |
☺ | Which RTOS supports Non-Preemptive scheduling? Why other scheduling methods are supported by such Oses? |
Top Operating System (OS) Categories
☺ | RTOS Interview Questions. |
☺ | Windows 7 Interview Questions. |
☺ | MAC Operating System Interview Questions. |
☺ | Disk Operating System (DOS) Interview Questions. |
☺ | Shell Scripting Interview Questions. |