TL;DR: In this article, the authors propose a graphical data flow programming environment whereby the local and global variables correspond to a control on a panel. And the user can view the global variable updating on the panel during execution of a VI.
Abstract: Global and local variable implementations in a graphical data flow programming environment whereby the local and global variables correspond to a control on a panel. A global variable is created by placing a global variable icon in a block diagram and creating an associated control in a global variable panel. The user the defines the data type of the global variable and assigns a name to the global variable. Therefore, global variables have a greatly reduced storage and execution overhead as compared with prior designs. Since a global variable is associated with a control in a panel, the user can view the global variable updating on the panel during execution of a VI. This greatly facilitates debugging. A local variable capability is also provided which enables a user to more effectively create block diagram programs and model processes in a graphical programming environment. A local variable is associated with a control on the front panel of a VI. A local variable is peculiar to the panel corresponding to the VI where the local is created, whereas a global variable is global to all VIs. Further, a local variable is created in a functional VI, whereas a global variable is not created in a functional VI. The data storage of a local variable is one of the controls on a VI's front panel. Writing to a local variable has the same result as passing data to the control terminal, except that the user can write to it even though it is a control. Also, the user can have any number of local variable references to a given front panel control, with some in write mode, and others in read mode. A local variable reference thus allows the user to use a front panel control as both an input and an output. One benefit of this local variable capability is that a user is allowed to use local variables in respective subVIs, i.e. subroutines, which are not affected by other VIs or other block diagrams.
TL;DR: This paper presents a source-to-source refactoring tool to automatically detect and localize global variables in a program, and implements a compiler based transformation to find the best location to redefine each global variable as a local.
Abstract: A global variable in C/C++ is one that
is declared outside a function, and whose scope extends the lifetime of the
entire program. Global variables cause problems for program dependability,
maintainability, extensibility, verification, and thread-safety. However,
global variables can also make coding more convenient and improve program
performance. We have found the use of global variables to remain unabated and
extensive in real-world software. In this paper we present a source-to-source
refactoring tool to automatically detect and localize global variables in a
program. We implement a compiler based transformation to find the best location
to redefine each global variable as a local. For each global, our algorithm
initializes the corresponding new local variable, passes it as an argument to
necessary functions, and updates the source lines that used the global to now
instead use the corresponding local or argument. We also characterize the use
of global variables in standard benchmark programs. We study the effect of our
transformation on static program properties, such as change in the number of
function arguments and program state visibility. Additionally, we quantify
dynamic program features, including memory and runtime performance, before and
after our localizing transformation.
TL;DR: The LW-SC (Lightweight-SC) language is presented, featuring nested functions (i.e., functions defined inside other functions) and designed and implemented to provide “lightweight” nested functions by aggressively reducing the costs of creating and maintaining nested functions.
Abstract: The SC language system was developed to provide a transformation-based language extension scheme for SC languages (extended/plain C languages with an S-expression-based syntax). Using this system, many flexible extensions to the C language can be implemented by means of transformation rules over S-expressions at low cost, mainly because of the preexisting Common Lisp capabilities for manipulating S-expressions. This paper presents the LW-SC (Lightweight-SC) language as an important application of this system, featuring nested functions (i.e., functions defined inside other functions). A function can manipulate its caller's local variables (or local variables of its indirect callers) by indirectly calling a nested function of its callers. Thus, many high-level services with “stack walk” can be easily and elegantly implemented by using LW-SC as an intermediate language. Moreover, such services can be implemented efficiently because we designed and implemented LW-SC to provide “lightweight” nested functions by aggressively reducing the costs of creating and maintaining nested functions. The GNU C compiler also provides nested functions as an extension to C, but our sophisticated translator to standard C is more portable and efficient for occasional “stack walk.”
TL;DR: In this paper, the declaration of a variable of a new storage class from within a function creates a shared variable and a local variable, which is visible only from within the function in which it is defined.
Abstract: The declaration of a variable of a new storage class from within a function creates a shared variable and a local variable. The shared variable may be a hidden (private) global variable and the local variable may be a hidden (private) local variable. The shared variable has a modified global scope and is callable only from within a function. The local variable is visible only from within the function in which it is defined. References to the variable from within a function result in the value of the shared variable being returned. The value of the shared variable is the value most recently assigned to the variable by an active caller of the function. Upon entering a function referencing the variable, the value of the shared variable is given to the local variable. When the function returns, the value of the local variable is assigned back to the shared variable.
TL;DR: In this article, symbolic object code of a totality of functions to be executed in the data processing system is provided and those functions of the totality, called interfering functions, are identified, which access an identical global variable.
Abstract: In order to avoid data inconsistency between accesses of different functions of an application to a global variable in a data processing system, a) symbolic object code of a totality of functions to be executed in the data processing system is provided and those functions of the totality, called interfering functions, are identified, which access an identical global variable; b) at least one of the interfering functions is selected; c) a step of the initialization of an auxiliary variable using the value of the global variable into the object code of each function selected in step b) or of a function calling a selected function prior to its call is inserted; and d) a symbol of the global variable in the object code of the selected function is replaced by a reference to a memory space of the auxiliary variable.