Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Operating System (OS) Interviews:BSDBulnexCompiler Linker LoaderDisk Operating System (DOS)MAC Operating SystemNative iOS EngineerOperating System (OS)OS Data StructuresOS General ConceptsOS Memory ManagementOS MultithreadingOS Process ManagementOS X Mountain LionRTOSShell ScriptingSolarisSolaris AdminSolaris CommandsSymbianUnix CommandsUNIX Operating SystemUnix Socket ProgrammingUnix/Linux programmingVxWorksWindowsWindows 7Windows AdministratorWindows CEWindows Programming
Copyright © 2018. All Rights Reserved
VxWorks Interview Question:
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
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.