Localizing globals and statics to make C programs thread-safe

  • Authors:
  • Adam R. Smith;Prasad A. Kulkarni

  • Affiliations:
  • University of Kansas, Lawrence, KS, USA;University of Kansas, Lawrence, KS, USA

  • Venue:
  • CASES '11 Proceedings of the 14th international conference on Compilers, architectures and synthesis for embedded systems
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

Challenges emerging from the exponential growth in CPU power dissipation and chip hot spots with increasing clock frequencies have forced manufacturers to employ multicore processors as the ubiquitous platform in all computing domains. Embedded mobile devices are increasingly adopting multicore processors to improve program performance and responsiveness at low power levels. However, harnessing these performance and power benefits requires the construction of parallel programs, a task significantly more complex than writing sequential code. Parallel code development is also made more difficult by differences in the use of several programming language constructs. Therefore, it is critical to provide programmers with tools to ease the formidable task of parallelizing existing sequential code or developing new parallel code for multicore processors. In this work we focus on the use of static and global variables that are commonly employed in C/C++ programs, the languages of choice for developing embedded systems applications. Unprotected use of such variables produces functions that are not thread-safe, thereby preventing the program from being parallelized. Manually eliminating global and static variables from existing sequential code is tedious, time-consuming and highly error-prone. While no good solution to this problem currently exists, researchers have proposed partial mitigation techniques that require massive changes to linkers and runtime systems. In this work we study the characteristics and effects of static and global variables in traditional benchmark programs, and propose, construct, and explore a compiler-based, semi-automatic and interactive technique to handle such variables and generate thread-safe code for parallel programs.