Real- time software /fall 98
The exercise is completed only if:
-
demonstrated to be working
-
a paper copy with cover sheet and listing is returned to the teacher (lab
4 and projects)
Copying is strictly forbidden (see course rules).
The exercises written with red letters
are not mandatory to all (only to grades 4- 5).
First we take some basic technologies as:
-
UNIX man- pages
-
compiling and linking a program using several separate source files
-
make- files
-
libraries, header files
-
procedure calling conventions
-
stack frame during program execution
(1) Reading and understanding UNIX man-pages:
Write a c- program which reads a name of a UNIX- system
environment variable ( as "PATH" or "PS1".....) and outputs the value of
this variable.
Use the man page "getenv(3)" ( UNIX
command line " man 3 getenv" )
If for example Your UNIX- command
prompt is ">" and You give the input "PS1" to Your program the output is
">".
(2) Compiling/header files/linking/separate modules
Write a c- program which reads a count of numbers, then integer numbers,
finds the biggest of these and outputs the result. Seeking of the biggest
must be in a separate module (a different source file). Use a header file.
Libraries
Read the manual page of the ar- command.
Put the subprogram object file of the exercise (2) to your own library
and test again.
Study also dynamic libraries ( ld -b ...,
dld.sl) make a simple documentation of Your experiment
(3) Make- files
(a) Read the manual page of make- command.
(b) Do a makefile for the exercise (2). You have a makefile in which
You use library and other without library.
(c) Study Linux make- files. You can get the complete
material of Linux configuration from the file
or from Your own computer. Make an experiment of Your own with the following
features:
-
make an as simple example program set as possible
for experiment
-
include- command in make- file
-
make -C dir
-
use ".c.o:" style rule
-
linking sets of objects to an object and then
these objects to an executable
(4) Modify a simple IPC- example from course material
(6.1.1).
Use GNU debugger gdb to test a program
-
Compile "gcc -g -static file.c -o file_exe"
-
Start debugger "gdb file_exe"
-
Example commands (see manual for further details):
-
help
-
help brekpoints
-
break subroutine_XXXX
-
data YYYYY
-
run
-
step
-
step
-
...........
-
disassemble subroutine_XXXX
-
bt
......