Introduction

Total Page:16

File Type:pdf, Size:1020Kb

Introduction HISTORY, BASIC SYNTAX Introduction 1 2 What is C? Why C? C is a general-purpose programming It’s still popular and widely used language initially developed by Dennis – Available on almost all platforms Ritchie between 1969 and 1973 at – Lots of libraries for different tasks AT&T Bell Labs Provides a relatively low-level (or mid-level) access to the It is an imperative procedural language operating system and hardware intended for system software – System-level programming, embedded systems – Strong ties with UNIX operating system – Can lead to better performance It has influenced many other programming languages – C++, C#, ObjC, Java, JavaScript, Go, csh, ... 3 4 Standards Look and feel First standard by ANSI in 1989, known as “ANSI C” or C89 /* Computing the factorial of an specified (by the user) number */ #include <stdio.h> – Still the best choice when portability is important! int fact(int n); int main(void){ – ISO adopted the same standard in 1990 (C90) int current; printf("Enter some POSITIVE integer (non-positive to finish): "); Next revision in 1999, C99 scanf("%d", &current); – New datatypes, complex numbers, variable length arrays,... while (current > 0) { printf("Factorial of %d is %d\n", current, fact(current)); – Not fully backwards compatible with C90 printf("Enter a POSITIVE integer (non-positive to finish): "); scanf("%d", &current); Current standard is C11 } return 0; – Improved Unicode support, atomic operations, multi-threading, } bounds-checked functions, ... /* This function returns the factorial of the specified integer (n) */ int fact(int n) { ... 5 6 Basic syntax Formatting Code is case sensitive /* example function */ Free format Statements terminate with ; float foo(int bar) { int i, c = 0; – Whitespace, newlines, layout etc. do not matter … {} enclose blocks float x; x = 0.1; There are two ways to comment: /* example function */ for (i = 0; i < bar; i++) { to the computer ! float foo(int bar) { x += i*3.14 + c; int i, c=0; c = i + 2; /* Single or float x; } /* same example function? */ Multiple lines */ return x; float x = 0.1; } foo(/*float f,*/int bar) { int i,c=0; float x; for (i=0; i<bar; i++) { // Single line (C99) x=0.1;for (/*i=10 x += i*3.14 + c; ; i<2*bar*/ i= c = i + 2; 0;i<bar;i++){x+=i*3.1/*1.2+ } */4+c;c=i+2;}return x;} return x; } 7 8 Basic data types Basic datatypes in C are: char character DATATYPES, VARIABLES, ASSIGNMENT AND OPERATORS int integer number long long integer number float floating point number double double precision float Integers can be signed (default) or unsigned C has also pointer types There is also a special type void 9 10 Variables Variable assignment Variable data types are static // variable declaration Assign a value to a variable: // examples of assignment int i; count = 10; Declare variables before float f, g; variable = value; i = j = 0; double total = 1.9; using them Both should have the same k = i*j + 1; // valid names – data type // assign at declaration C90 requires that the int i3, myINT, I_o; int i = 4; declarations are before any float o3Gf_ry9; – Implicit conversion between other statements // invalid names compatible types // typecast from int to float int 33, 9a, i-o; int i; Valid variable names in C: float o3.Gf; – Explicit conversion (typecast) float f; . Upper and lower case // data type matters syntax: i = 5 * 21; char c; f = (float) i; letters, underline and float f; (type) var numbers are allowed // watch out for operator order f = 1.234; (float) i/5 != (float) (i/5) c = f; // ERROR! // wrong data type 11 12 Arithmetics Compound assignment Operators: addition C has a short-hand notation + // example of compound assignment – subtraction for combined arithmetic int count = 10; count += 5; // now count is 15 * multiplication operation and assignment count /= 3; // and now count is 5 / division Given an operator <op> and // Adding one to count % modulus values a and b, the syntax is count++; a<op>=b and the result is // This is also valid! Operator precedence a=a<op>b ++count; 1) % * / For special cases a+=1 and 2) + - a-=1 there are special Parentheses can be used to group operations () and change operators ++ and -- evaluation order 13 14 Arithmetics and assignment examples Other operators Logical operators Bit-wise operators // addition, substraction // grouping with ()s i = 5 + 2; b = a * (1.3 + (25%3)); i = 5 – 2; && AND >> shift right i += 1; // i = i + 1 // watch out for precedence! || OR << shift left f -= 3.4; f = 1 + q / (1 - q); > larger than & AND i++; // i = i + 1 f = (1 + q) / (1 - q); < less than | OR i--; >= larger or equal ^ XOR // also function calls use () <= less or equal ~ complement // multiplication, division f = r * sin(theta); i = 5 * 2; f = (r + p)*sin(theta); == equal i = 5 / 2; // integer division != unequal f *= 3.0 / 4.2; ! negation // modulus m = 25 % 3; 15 16 Basic I/O printf prints formatted text to the screen Format of printf call is printf(<template> {, <variables>}) BASIC I/O where <template> arbitrary string with optional placeholders for data from variables <variables> (optional) list of variables or values 17 18 Basic I/O Basic I/O example Special characters that can be used in the template string: #include <stdio.h> int main(int argc, char *argv[]) { \n newline \t horizontal tab printf("The answer is %d.\n", 42); \" double quote \\ literal backslash printf("Pi equals to %.2f", 3.14159265); printf(" ...at least to the %dnd decimal.\n", 2); return 0; Placeholders are marked with % followed by formatting and } type information //output: – For now, we will just use the following formattings: // The answer is 42. %d integer value // Pi equals to 3.14 ...at least to the 2nd decimal. %f float value %s string 19 20 Summary Short history and different standards Basic syntax Variables and their type, assignment of values Arithmetic operations Basic IO (printf) 21 POINTERS, ARRAYS AND FUNCTIONS Getting started 22 23 Pointers Pointers On the hardware level a variable is actually a reference to Pointer variables are defined by adding * into the a memory location definition, for example a pointer named ptr of type int The contents of the memory block determine the value is defined as int *ptr; of a variable The address of a variable can be obtained using & – The size of the memory block depends on the type of the operator variable int a; Memory addresses can be stored (and manipulated) Memory using pointers Address Pointer variables can be considered as variables that hold the address of a element with given datatype (int, int *p = &a; char, ...) 24 25 Arrays Array examples // int array of size 10 Static arrays can be introduced using []: int array[10]; // Set value of third element to 1 array[2] = 1; char str[20]; Array of 20 characters // Print the value double values[10]; Array of 10 doubles printf(“a[2]=%d\n”, array[2]); // type of array is equivalent to // type (int*) Elements of array can be accessed using the same [] int *ptr; operator. The value inside brackets is interpreted as an array[0] = 3; ptr = array; offset from the beginning of the array printf(“*ptr=%d\n”, *ptr); – Indices always start from 0 – Last element of an array A of size n is A[n-1] 26 27 Functions Functions are the only subroutine type in C – But functions do not have to return anything Function definitions are of form FUNCTIONS type func-name(param-list) { /* body of function */ } Here type is the return type of the function – void means that function does not return anything 28 29 main function Function example Every C program has the main function with definition This function returns the sum of two integer arguments: #include <stdio.h> int main(int argc, char *argv[]) int add(int a, int b) { { return a + b; /* body of function */ } } int main(void) { Command line arguments are passed to the program int val; using argc and argv val = add(3, 6); main should always return integer printf(“Sum is %d\n”, val); return 0; – zero means success, non-zero values are errors } 30 31 Variable scoping Arguments Variable scoping in C is void funcB(float a) { All arguments are passed as void funcB(int a) { local unless defined int counter; values a += 10; ... } otherwise } Not accessible from funcA – Copy of the value is passed to – Variables declared in int funcA(void) { the function int funcA(void) { the function definition float value_1, value2; – Functions can not change the int var = 0; funcB(value_1); funcB(var); are only visible inside ... value of a variable in the // var is still 0! the function body } calling scope ... – Variables of calling } Not accessible from funcB Pointers can be used to pass a scope are not visible reference to a variable as an inside function body argument! 32 33 C preprocessor The line #include <stdio.h> in the previous example is a preprocessor directive – It directs the preprocessor to literally read in the file PREPROCESSOR stdio.h before the source is passed to the compiler – stdio.h has several definitions related to standard input and output, including the definition of the printf function 34 35 Preprocessor macros and #define #define can be used to define “objects” or macros It has the form of #define identifier replacement-list new-line COMPILING AND LINKING, MATH ROUTINES After the definition, all instances of identifier are replaced with replacement-list // Example #define ONE 1 printf(“Value is %d\n”, ONE); // Result: Value is 1 36 37 Transition from source code to program Let's try it out! Compiling: Write the classic first program in C: #include <stdio.h> – Transforming the C source void main() { #include <stdio.h> int i,j=0; int main(int argc, char *argv[]) { code to machine language float f=1.0; for (i=0; i<8; i++) { foo.c j += i; printf(”Hello, World!\n”); Linker: f *= j+i; } return 0; – Combines object files } generated by the compiler preprocessor Compile your code: into a single executable compiler compiler gcc, cc, ..
Recommended publications
  • C Programming Language Review
    C Programming Language Review Embedded Systems 1 C: A High-Level Language Gives symbolic names to values – don’t need to know which register or memory location Provides abstraction of underlying hardware – operations do not depend on instruction set – example: can write “a = b * c”, even if CPU doesn’t have a multiply instruction Provides expressiveness – use meaningful symbols that convey meaning – simple expressions for common control patterns (if-then-else) Enhances code readability Safeguards against bugs – can enforce rules or conditions at compile-time or run-time Embedded Systems 2 A C Code “Project” • You will use an “Integrated Development Environment” (IDE) to develop, compile, load, and debug your code. • Your entire code package is called a project. Often you create several files to spilt the functionality: – Several C files – Several include (.h) files – Maybe some assembly language (.a30) files – Maybe some assembly language include (.inc) files • A lab, like “Lab7”, will be your project. You may have three .c, three .h, one .a30, and one .inc files. • More will be discussed in a later set of notes. Embedded Systems 3 Compiling a C Program C Source and Entire mechanism is usually called Header Files the “compiler” Preprocessor – macro substitution C Preprocessor – conditional compilation – “source-level” transformations • output is still C Compiler Source Code Compiler Analysis – generates object file Symbol Table Target Code • machine instructions Synthesis Linker – combine object files Library (including libraries) Linker into executable image Object Files Executable Image Embedded Systems 4 Compiler Source Code Analysis – “front end” – parses programs to identify its pieces • variables, expressions, statements, functions, etc.
    [Show full text]
  • Section “Common Predefined Macros” in the C Preprocessor
    The C Preprocessor For gcc version 12.0.0 (pre-release) (GCC) Richard M. Stallman, Zachary Weinberg Copyright c 1987-2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation. A copy of the license is included in the section entitled \GNU Free Documentation License". This manual contains no Invariant Sections. The Front-Cover Texts are (a) (see below), and the Back-Cover Texts are (b) (see below). (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Table of Contents 1 Overview :::::::::::::::::::::::::::::::::::::::: 1 1.1 Character sets:::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.2 Initial processing ::::::::::::::::::::::::::::::::::::::::::::::: 2 1.3 Tokenization ::::::::::::::::::::::::::::::::::::::::::::::::::: 4 1.4 The preprocessing language :::::::::::::::::::::::::::::::::::: 6 2 Header Files::::::::::::::::::::::::::::::::::::: 7 2.1 Include Syntax ::::::::::::::::::::::::::::::::::::::::::::::::: 7 2.2 Include Operation :::::::::::::::::::::::::::::::::::::::::::::: 8 2.3 Search Path :::::::::::::::::::::::::::::::::::::::::::::::::::: 9 2.4 Once-Only Headers::::::::::::::::::::::::::::::::::::::::::::: 9 2.5 Alternatives to Wrapper #ifndef ::::::::::::::::::::::::::::::
    [Show full text]
  • SIPB's IAP Programming in C
    SIPB’s IAP Programming in C C was developed at AT&T Bell Labs between 1971 and 1973, by Dennis Ritchie. It was derived from an experimental language called B, which itself was a stripped-down version of BCPL. All of these are derivatives of the ALGOL family of languages, dating from the 1950s. This work was done on a PDP-11, a machine with a 16 bit address bus. While a PDP-11 should be able to address up to 64K of memory, these machines only had 24K. The C compiler was written in C, and was able to compile itself on these machines, running under the nascent Unix operating system. #include <stdio.h> main() The classic { printf("hello, world\n"); } /* * %% - a percent sign * %s - a string * %d - 32-bit integer, base 10 * %lld - 64-bit integer, base 10 * %x - 32-bit integer, base 16 * %llx - 64-bit integer, base 16 * %f, %e, %g - double precision * floating point number */ /* * the following should produce: A word on printf() * * printf() test: * string: 'string test' * number: 22 * float: 18.19 */ printf("printf() test:\n" " string: '%s'\n" " number: %d\n" " float: %g\n", "string test", 22, 18.19); Language Structure char i_8; There are five different /* -128 to 127 */ kinds of integer: unsigned char ui_8; /* 0 to 255 */ - char short i_16; - short /* -32768 to 32767 */ unsigned short ui_16; - int /* 0 to 65536 */ int i_32; - long /* -2147483648 to 2147483647 */ unsigned int ui_32; - long long /* 0 to 4294967295U */ long i_arch; unsigned ui_arch; Each of these can be /* architecture either: * dependent */ long long i64; - signed (the default)
    [Show full text]
  • Tinyos Programming Philip Levis and David Gay Frontmatter More Information
    Cambridge University Press 978-0-521-89606-1 - TinyOS Programming Philip Levis and David Gay Frontmatter More information TinyOS Programming Do you need to know how to write systems, services, and applications using the TinyOS operating system? Learn how to write nesC code and efficient applications with this indispensable guide to TinyOS programming. Detailed examples show you how to write TinyOS code in full, from basic applications right up to new low-level systems and high-performance applications. Two leading figures in the development of TinyOS also explain the reasons behind many of the design decisions made and explain for the first time how nesC relates to and differs from other C dialects. Handy features such as a library of software design patterns, programming hints and tips, end-of-chapter exercises, and an appendix summarizing the basic application-level TinyOS APIs make this the ultimate guide to TinyOS for embedded systems programmers, developers, designers, and graduate students. Philip Levis is Assistant Professor of Computer Science and Electrical Engineering at Stanford University. A Fellow of the Microsoft Research Faculty, he is also Chair of the TinyOS Core Working Group and a Member of the TinyOS Network Protocol (net2), Simulation (sim), and Documentation (doc) Working Groups. David Gay joined Intel Research in Berkeley in 2001, where he has been a designer and the principal implementer of the nesC language, the C dialect used to implement the TinyOS sensor network operating system, and its applications. He has a diploma in Computer Science from the Swiss Federal Institute of Technology in Lausanne and a Ph.D.
    [Show full text]
  • A Type-Checking Preprocessor for Cilk 2, a Multithreaded C Language
    A Typechecking Prepro cessor for Cilk a Multithreaded C Language by Rob ert C Miller Submitted to the Department of Electrical Engineering and Computer Science in partial fulllment of the requirements for the degrees of Bachelor of Science in Computer Science and Engineering and Master of Engineering in Electrical Engineering and Computer Science at the Massachusetts Institute of Technology May Copyright Massachusetts Institute of Technology All rights reserved Author ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::: Department of Electrical Engineering and Computer Science May Certied by ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: Charles E Leiserson Thesis Sup ervisor Accepted by ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: F R Morgenthaler Chairman Department Committee on Graduate Theses A Typechecking Prepro cessor for Cilk a Multithreaded C Language by Rob ert C Miller Submitted to the Department of Electrical Engineering and Computer Science on May in partial fulllment of the requirements for the degrees of Bachelor of Science in Computer Science and Engineering and Master of Engineering in Electrical Engineering and Computer Science Abstract This thesis describ es the typechecking optimizing translator that translates Cilk a C ex tension language for multithreaded parallel programming into C The CilktoC translator is based on CtoC a to ol I developed that parses type checks analyzes and regenerates a C program With a translator based on CtoC
    [Show full text]
  • Nesc 1.2 Language Reference Manual
    nesC 1.2 Language Reference Manual David Gay, Philip Levis, David Culler, Eric Brewer August 2005 1 Introduction nesC is an extension to C [3] designed to embody the structuring concepts and execution model of TinyOS [2]. TinyOS is an event-driven operating system designed for sensor network nodes that have very limited resources (e.g., 8K bytes of program memory, 512 bytes of RAM). TinyOS has been reimplemented in nesC. This manual describes v1.2 of nesC, changes from v1.0 and v1.1 are summarised in Section 2. The basic concepts behind nesC are: • Separation of construction and composition: programs are built out of components, which are assembled (“wired”) to form whole programs. Components define two scopes, one for their specification (containing the names of their interfaces) and one for their implementation. Components have internal concurrency in the form of tasks. Threads of control may pass into a component through its interfaces. These threads are rooted either in a task or a hardware interrupt. • Specification of component behaviour in terms of set of interfaces. Interfaces may be provided or used by the component. The provided interfaces are intended to represent the functionality that the component provides to its user, the used interfaces represent the functionality the component needs to perform its job. • Interfaces are bidirectional: they specify a set of functions to be implemented by the inter- face’s provider (commands) and a set to be implemented by the interface’s user (events). This allows a single interface to represent a complex interaction between components (e.g., registration of interest in some event, followed by a callback when that event happens).
    [Show full text]
  • C Programming
    C PROGRAMMING 6996 Columbia Gateway Drive Suite 100 Columbia, MD 21046 Tel: 443-692-6600 http://www.umbctraining.com C PROGRAMMING Course # TCPRG3000 Rev. 10/14/2016 ©2016 UMBC Training Centers 1 C PROGRAMMING This Page Intentionally Left Blank ©2016 UMBC Training Centers 2 C PROGRAMMING Course Objectives ● At the conclusion of this course, students will be able to: ⏵ Write non-trivial C programs. ⏵ Use data types appropriate to specific programming problems. ⏵ Utilize the modular features of the C languages. ⏵ Demonstrate efficiency and readability. ⏵ Use the various control flow constructs. ⏵ Create and traverse arrays. ⏵ Utilize pointers to efficiently solve problems. ⏵ Create and use structures to implement new data types. ⏵ Use functions from the C runtime library. ©2016 UMBC Training Centers 3 C PROGRAMMING This Page Intentionally Left Blank ©2016 UMBC Training Centers 4 C PROGRAMMING Table of Contents Chapter 1: Getting Started..............................................................................................9 What is C?..................................................................................................................10 Sample Program.........................................................................................................11 Components of a C Program......................................................................................13 Data Types.................................................................................................................14 Variables.....................................................................................................................16
    [Show full text]
  • Tinyos Programming
    TinyOS Programming Philip Levis and David Gay July 16, 2009 ii Acknolwedgements We’d like to thank several people for their contributions to this book. First is Mike Horton, of Crossbow, Inc., who first proposed writing it. Second is Pablo Guerrero, who gave detailed comments and corrections. Third is Joe Polastre of Moteiv, who gave valable feedback on how to better introduce generic components. Fourth, we’d like to thank Phil’s father, who although he doesn’t program, read the entire thing! Fifth, John Regehr, Ben Greenstein and David Culler provided valuable feedback on this expanded edition. Last but not least, we would like to thank the TinyOS community and its developers. Many of the concepts in this book – power locks, tree routing, and interface type checking – are the work and ideas of others, which we merely present. Chapter 10 of this book is based on: Software design patterns for TinyOS, in ACM Transactions on Embedded Computing Systems (TECS), Volume 6, Issue 4 (September 2007), c ACM, 2007. http://doi.acm.org/10.1145/1274858.1274860 Contents I TinyOS and nesC 1 1 Introduction 3 1.1 Networked, Embedded Sensors . 3 1.1.1 Anatomy of a Sensor Node (Mote) . 4 1.2 TinyOS . 5 1.2.1 What TinyOS provides . 5 1.3 Example Application . 6 1.4 Compiling and Installing Applications . 7 1.5 The rest of this book . 7 2 Names and Program Structure 9 2.1 Hello World! . 9 2.2 Essential Differences: Components, Interfaces and Wiring . 12 2.3 Wiring and Callbacks . 13 2.4 Summary .
    [Show full text]
  • Systems Supplement for COP 3601
    Systems Guide for COP 3601: Introduction to Systems Software Charles N. Winton Department of Computer and Information Sciences University of North Florida 2010 Chapter 1 A Basic Guide for the Unix Operating System 1. 1 Using the Unix On-line Manual Pages Facility The following are some of the Unix commands for which you may display manual pages: cal cat cd chmod cp cut date echo egrep ex fgrep file find gcc gdb grep kill less ln locate ls mail make man mesg mkdir mv nohup nl passwd pr ps pwd rm rmdir set sleep sort stty tail tee time touch tr tty uname umask unset vim wall wc which who whoami write For example, to display the manual pages for the command "cp" enter man cp Note that you may also enter man man to find out more about the "man" command. In addition there may be commands unique to the local environment with manual pages; e.g., man turnin accesses a manual page for a project submission utility named Aturnin@ that has been added to the system. If you enter a command from the Unix prompt that requires an argument, the system will recognize that the command is incomplete and respond with an error message. For example, if the command "cp" had been entered at the Unix prompt the system would respond with the information such as shown below: cp: missing file arguments Try `cp --help' for more information. The "cp" command is a copy command. If the arguments which tell the command which file to copy and where to locate the copied file are missing, then the usage error message is generated.
    [Show full text]
  • Research Statement
    Research Statement Paul Gazzillo Fall 2017 1 Introduction My goal is to make it easier to create safe and secure programs. As computing technology becomes further integrated with our daily lives, we are subjected to increasingly severe security and privacy risks. The recent Equifax breach put 143 million people at risk, and it was due to a vulnerability that lived in source code for nearly a decade [8]. Minor concurrency errors by developers using the Ethereum cryptocurrency cost users millions of dollars in the Parity Wallet attacks [18]. Internet- enabled devices have made cars, medical devices, and even guns susceptible to potentially life- threatening takeovers by remote hackers [9, 10]. Security guru Bruce Schneier puts it eloquently: \As everything turns into a computer, computer security becomes everything security" [20]. How can we protect software systems from these risks? Auditing software manually is expensive and must to be repeated for new versions. Antivirus software and intrusion detection systems do not stop as-yet-unknown vulnerabilities. A complete solution requires developing far more secure software from the start. To do so, developers need automated software tools for security analysis, bug finding, verification, and more. Automating these tasks makes development of secure software easier, cheaper, and less error-prone. Moreover, automated tools can be applied to legacy software built without a focus on security. My research solves problems in security, systems, and software engineering with techniques from programming languages and compilers. I have co-developed an analysis that automates finding side channels [2]. This enables automated security auditing for leaks of secret data such as passwords and encryption keys.
    [Show full text]
  • Nesc Overview (And Summary of Changes)
    NesC Overview (and Summary of Changes) Eric Brewer, David Gay, Phil Levis, and Rob von Behren June 17, 2002 Version 0.6 Overview The NesC language has two goals: first, to be a pragmatic low-level language for programming the motes, and second to be the intermediate language for future higher-level languages. Here we will only deal with the first goal. As a programming language, this first version of NesC has a few modest goals: • Get rid of the awful macros for frame variables, commands and events. • Eliminate wiring error through type checking. • Simplify wiring by grouping logically related “wires” into interfaces. • Increase modularity through the separation of interfaces and modules. • Clean up the code base through better use of types and more compile time checking. • Better performance by enabling whole program optimization. Other positive side effects: • Reduced the number of files per module. • Reduced compilation time (and removed a lot of shaky perl code) • Reduced code size by 25% • Better looking code • Easier to debug code Files In general, we have moved from three files per module to one plus some interfaces. The main file, the .td file, defines a component, which is either a configuration or a module. Both configura- tions and modules have a specification of the required and provided interfaces. A configuration also lists the components used and the internal wiring. A module provides code that implements the provided interfaces (and may use the required interfaces). We keep these two separate in the belief that it makes it easier to understand the wiring and to have multiple implementations of a submodule (that use the same wiring).
    [Show full text]
  • Nait: a Source Analysis and Instrumentation Framework for Nesc
    nAIT: A Source Analysis and Instrumentation Framework for nesC Andrew R. Dalton Department of Mathematics and Computer Science, Western Carolina University Cullowhee, North Carolina, 28723 USA and Jason O. Hallstrom School of Computing, Clemson University Clemson, South Carolina, 29634 USA Abstract Automated software engineering methods support the construction, maintenance, and analysis of both new and legacy systems. Their application is commonplace in desktop- and enterprise-class systems due to the productivity and reliability bene- fits they afford. The contribution of this article is to present an applied foundation for extending the use of such methods to the flourishing domain of wireless sensor networks. The objective is to enable developers to construct tools that aid in under- standing both the static and dynamic properties of reactive, event-based systems. We present a static analysis and instrumentation toolkit for the nesC language, the defacto standard for sensor network development. We highlight the novel aspects of the toolkit, analyze its performance, and provide representative case-studies that illustrate its use. Key words: Wireless sensor networks, nesC, static analysis, instrumentation 1 Introduction For desktop- and enterprise-class system developers, automated software en- gineering methods have become important elements of the standard devel- Email addresses: [email protected] (Andrew R. Dalton), [email protected] (Jason O. Hallstrom). Preprint submitted to Elsevier 12 December 2008 opment arsenal. Automation tools increase developer productivity, improve the reliability of new systems, and safeguard the reliability of legacy systems undergoing maintenance and evolution. The focus of this article is restricted to automated analysis and instrumentation methods. Even limited to this subset, however, automation benefits span a disparate range of tasks.
    [Show full text]