Software Developer

Only available on StudyMode
  • Topic: C, Unix, C++
  • Pages : 7 (1589 words )
  • Download(s) : 107
  • Published : November 29, 2012
Open Document
Text Preview
R N S INSTITUTE OF TECHNOLOGY
CHANNASANDRA, BANGALORE - 61

UNIX SYSTEM PROGRAMMING
NOTES FOR 6TH SEMESTER INFORMATION SCIENCE SUBJECT CODE: 06CS62 PREPARED BY

RAJKUMAR
Assistant Professor Department of Information Science

DIVYA K
1RN09IS016 6th Semester Information Science and Engineering 1rn09is016@gmail.com

Text Books: 1 Terrence Chan: Unix System Programming Using C++, Prentice Hall India, 1999. 2 W. Richard Stevens, Stephen A. Rago: Advanced Programming in the UNIX Environment, 2nd Edition, Pearson Education / PHI, 2005 Notes have been circulated on self risk nobody can be held responsible if anything is wrong or is improper information or insufficient information provided in it.

Contents: UNIT 1, UNIT 2, UNIT 3, UNIT 4, UNIT 5, UNIT 6, UNIT 7

RNSIT

UNIX SYSTEM PROGRAMMING NOTES

UNIT 1 INTRODUCTION
UNIX AND ANSI STANDARDS
UNIX is a computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McElroy and Joe Ossanna. Today UNIX systems are split into various branches, developed over time by AT&T as well as various commercial vendors and non-profit organizations.

The ANSI C Standard
In 1989, American National Standard Institute (ANSI) proposed C programming language standard X3.159-1989 to standardise the language constructs and libraries. This is termed as ANSI C standard. This attempt to unify the implementation of the C language supported on all computer system. The major differences between ANSI C and K&R C [Kernighan and Ritchie] are as follows:  Function prototyping  Support of the const and volatile data type qualifiers.  Support wide characters and internationalization.  Permit function pointers to be used without dereferencing. Function prototyping ANSI C adopts C++ function prototype technique where function definition and declaration include function names, arguments’ data types, and return value data types. This enables ANSI C compilers to check for function calls in user programs that pass invalid number of arguments or incompatible arguments’ data type. These fix a major weakness of K&R C compilers: invalid function calls in user programs often pass compilation but cause programs to crash when they are executed. Eg: unsigned long foo(char * fmt, double data) { /*body of foo*/ } unsigned long foo(char * fmt, double data); eg: int printf(const char* fmt,...........);

External declaration of this function foo is

specify variable number of arguments Support of the const and volatile data type qualifiers.  The const keyword declares that some data cannot be changed. Eg: int printf(const char* fmt,...........); Declares a fmt argument that is of a const char * data type, meaning that the function printf cannot modify data in any character array that is passed as an actual argument value to fmt. Volatile keyword specifies that the values of some variables may change asynchronously, giving an hint to the compiler’s optimization algorithm not to remove any “redundant” statements that involve “volatile” objects. char get_io() { volatile char* io_port = 0x7777; char ch = *io_port; /*read first byte of data*/ ch = *io_port; /*read second byte of data*/ }



eg:

If io_port variable is not declared to be volatile when the program is compiled, the compiler may eliminate second ch = *io_port statement, as it is considered redundant with respect to the previous statement. Prepared By: RAJKUMAR [Asst. Prof.] & DIVYA K [1RN09IS016] Page 1

RNSIT


UNIX SYSTEM PROGRAMMING NOTES

The const and volatile data type qualifiers are also supported in C++.

Support wide characters and internationalisation   ANSI C supports internationalisation by allowing C-program to use wide characters. Wide characters use more than one byte of storage per character. ANSI C defines the setlocale function, which allows users to specify the format of date, monetary and real number representations. For...
tracking img