Software 1, Spring 2004

0368215712
Lecture: Tuesday 10:00-13:00, Orebstein 5 (Dach)

Instructor: Dan Halperin
Office hours: Tuesday 15:00-16:00, Schreiber 219

Teaching Assistants: Greta Yorsh and Efi Fogel
All practice-related information can be found at the Practice website

Helpdesk:
Ori Shalev, [email protected], Tuesday, 17:00-19:00
Angela Enosh, [email protected], Wednesday, 19:00-21:00

The course will cover three topics:

  1. the C programming language,
  2. basic system software and the UNIX programming environment,
  3. a brief introduction to C++.

A short bibliography for the course.

The main textbook used in the course: A Book on C—3rd or 4th Edition, by Kelley and Pohl. The book is at its 4th edition, but for all the course’s purposes the 3rd edition is as good. One of the advantages of this book is that its example programs are available on-line: browse the examples or download the dos version.

The final grade will be determined by your assignments grade (25%) and the final exam (75%). To be eligible for a final grade students must submit ALL exercises. Note that the exercises do not necessarily have equal weight in the final assignment grade. The assignments distribution and submission will be coordinated by the TAs (METARGELIM).

During the course you will need an account on the school’s UNIX machines. Most of you probably have an account already. If not check with the help desk on the entrance floor to Schreiber.


Syllabus and Handouts

The chapters below refer to the chapters of “A Book on C”—3rd or 4th Edition. Note that this course outline is tentative. During the semester we also maintain a brief summary of the actual material taught in class.

course overview. requirements.
introduction to “C” (chapter 0)

example programs in C (chapter 1)

a brief history of the UNIX operating system
Beginner’s Unix commands

lexical elements (chapter 2)

writing a C program in UNIX

fundamental data types (chapter 3)

floating point standards and signed numbers; for more details see “Computer Arithmetic” by David Goldberg, Appendix A of “Computer Architecture, a Quantitative Approach” by Hennessy and Patterson, 2nd Edition, Morgan Kaufman.

flow of control (chapter 4)

random number functions from the book “Programming Abstractions in C” by E. Roberts, Addison Wesley,
and a small program that tests some random number functions and sample runs

functions (chapter 5)

runtime environment and the control stack; for more details see “Runtime Environments”-Chapter 7 of “Compilers, Principles, Techniques and Tools” by Aho, Sethi, and Ullman, Addison Wesley.

arrays, pointers, and strings (chapter 6)

structures (chapter 9)

dynamic matrix allocation (from chapter 12) , matrix.tgz—the source code and makefile

preprocessor (chapter 8)

bitwise operators and enumeration types (chapter 7)

self-referential structures, linked lists , binary trees (chapter 10)

stacks (also from chapter 10)

introduction to the unix make untility (type “unix make untility” in google to find more on-line guides/manuals)

input/output, files (chapter 11)

for more information on UNIX I/O, see Advanced Programming in the UNIX Environment / W.R.Stevens, Addison-Wesley.

executing commands from within a C program

environment variables

lint, profiler

timing a C program, using pipes from within a C program

compilation options, making a library, timing C programs

For the class on 18/5/04 please download the following two handouts:
(1) More on make
(2) Introduction to PERL

process control in UNIX, pipes, signals (chapter 12)

about shell scripts and scripting languages

new: secure programming , guest talk by Yedidyah Bar-David on 8/6/04

UNIX utilities (those will be mainly studied in the TIRGUL): sort, find, tar, gzip, uuencode/decode, background, fg, jobs, soft links

a brief introduction to C++

Beginner’s Unix Commands


This page is (very slightly) adapted from
www.cs.appstate.edu/~jtw/cs1440/ux_cmds1.html
. For alternative
beginner’s guides, search google with “Beginner’s Unix Commands”.

There are many Unix commands that you might find
useful, and there are many opinions about what commands you should
make an effort to learn when you start.
This page offers some suggestions for getting started with Unix.

Preliminaries

To begin with, you need to have some notions about the files, directories,
and the Unix file system.
You should know what your home directory is.

You need to know some things about passwords, about connecting to the system,
about logging in and logging out.

Sources of Information

Most Unix systems have documentation on-line. You should note these items:

man word
If the on-line manual contains a “page” about word, this
command will display it on your screen.
For example, man man displays information about the
man command.
apropos keyword
The apropos command locates commands by keyword lookup.
When you type the command apropos word you will see a list of one-line
descriptions of entries in the manual that contain word (in their
one-line description).
Follow up by using the man command to display one of the manual pages.If you have lots of time and energy on your hands, you may want to
learn more about Unix on your own.
There are lots of books about using Unix;
you might want to get one and study it.
Books about Unix vary widely
in quality.
Before you buy a book about Unix, you might want to ask your instructor
for recommendations.

 

Some commands to learn about

If you think you need more information, use the man command
(see above), or talk to your instructor.

cd
The command

        cd directory_name 

changes your current (working) directory to the named directory.
The command

        cd

(i.e., with no arguments) changes
your current directory to be your home directory.

logout
Logs you out of the system.
ls
The command

        ls

(with no arguments) lists the
names of files in your current directory.

Adding the options -CF, i.e., typing the command

        ls -CF

lists the names of the files in your current directory,
listing them in multiple columns and appending a ‘*’ to executable files and ‘/’
to directories.

The command

        ls -l

shows a long-form listing
which includes a character indicating whether the file is a directory (‘d’)
or an ordinary file (‘-‘), 9 characters describing the file permissions,
the name of the file’s owner, the file’s size in bytes, when the file
was last modified, and the file’s name.

Any of these forms can have wildcarded file names appended to them;
that is, you can type things like:

        ls -l  file_name
        ls -l  wildcarded_file_name
        ls -CF file_name
        ls -CF wildcarded_file_name

These forms restrict the listing to files whose names match the wildcarding.

There are lots of other things ls can do; consult the manual page
(type the command man ls) for details.

mkdir
The command

        mkdir directory_name

creates a directory with the given name.

passwd
The command passwd (with no arguments) can be used to
change your password.
You will be prompted to enter your old password and to enter a new one twice.
Nothing will be echoed.
If the command doesn’t generate error messages, your password has been changed
to the new one.
pwd
The command pwd (with no arguments) displays the name
of your current directory on the screen. If what you see appears to be an
error message, consult your instructor.
rm
The command

        rm file_name

removes (deletes, erases) the named file.
The argument file_name can be replaced with a wildcarded
file name description; the command will remove all files that match
the wildcarded name.
Use wildcards here with great caution; there is typically
no way to recover a file that you have removed.

A variation on this command is the command

        rm -i file_name

The difference between this form and the first is that when the -i
is there, the rm command will ask you whether to remove a file
before it actually removes it. You can say no (‘n’).

Here are some other commands that you might find useful.
They’re here in alphabetical order.
If you think you need more information, use the man command
(see above), or talk to your instructor.

cat file_name
This command displays the named file on the screen.
Actually that is a special case of what the cat command does.
The command line:

        cat file_1 file_2 ... file_n

Reads the named files (file_1, file_2, …) and combines them into
a single file (concatenates them) which it sends to
“standard output” — the screen.
The command line:

        cat file_1 file_2 ... file_n > destination_file

concatenates the named files and puts the result in the file named
destination_file.

cp
The command

          cp file_1 file_2

copies the content of file_1 to a file named file_2.
After the operation you have two independent copies of the same information.

The command

          cp file_1 file_2 ... directory_name

puts copies of
the files, file_1, file_2, …, in the directory directory_name.
After the copy file_1 and directory_name/file_1
are independent copies of the same information.
Likewise with file_2 and directory_name/file_2, and so on.

date
The date command (with no arguments) prints the current
date and time. The output includes the day of the week too.
For example, if I now type the command, I’ll see this on my screen:

% date
Wed Sep 11 14:50:39 EDT 1996
% 
finger
The command

        finger

(with no arguments) displays some information
about people who are currently logged on.

The command

        finger user_name

displays some information
about the named user.
The command

        finger real_name

where real_name
is part of some user’s real name, should show some information
about that user.

The command

        finger user@internet_address

asks the system
at internet_address for finger information on user.
What happens depends on the system at internet_address;
that system might send the information, might send some other message
(perhaps a refusal), might “refuse the connection”, or just might
not respond (generating a long delay followed by a “connection
timed out” message.

lpr printer file_name
Sends the file to the specified printer.
more file_name
less file_name
These two commands are “pagers”. A “pager” is a program
that displays a file on your screen a screen-full at a time.
More is the older program, and there are many versions
of it. Currrent versions are usually capable of scrolling both forward and backward
in the file and of doing searches.
Less is more only more-so ;-).
There are lots of versions of less around.
Typically, less has more features than more.If you type a lower case ‘h’ to either of these programs, you should
see a “help screen”.
mv
The command

        mv file_1 file_2

moves file_1 to a file named file_2.
After the operation file_1 is gone and file_2
contains the information.
The effect is that file_1 is renamed as file_2.

The command

        mv file_1 file_2 ... directory_name

moves the files, file_1, file_2, …, to the directory directory_name.
After the move, files file_1, file_2, … appear in the named
directory rather than where they were.

rmdir
The command line

        rmdir directory_name

will remove the named directory if the directory is empty.
If there are files in the named directory, the command will tell you that
the directory isn’t empty and will not remove the directory.

who
The who command, without an argument, lists the login name, terminal
name, and login time for each current UNIX user.With two arguments, as in who am I who tells
who you are logged in as.

Software 1, Class Summary
Below you’ll find a brief description of what was taught in class.
“ABC” stands for the main textbook of the course:
“A Book on C”—3rd or 4th Edition, by Kelley and Pohl.
This page is meant to help people who missed class to get an idea of
the topics taught. It should not however be taken as a complete
description of the course material.

<! There’s also a page of >
<! a HREF=”http://www.math.tau.ac.il/~sariel/TA/99a/soft99a/tirgul.html”>
<! TIRGUL summary>
<! /a>
<! P>

 2.3.2004
course overview; requirements
introduction to “C”
example programs in C (chapter 1, up to getchar)

 9.3.2004
example programs in C (chapter 1, cont’d)
basic commands in UNIX
lexical elements (chapter 2)
fundamental number types (chapter 3)

 16.3.2004
fundamental number types (chapter 3, cont’d)
a little about computer arithmetic: representing signed integers,
floating point numbers; for more details see “Computer Arithmetic” by David
Goldberg, Appendix A of “Computer Architecture, a Quantitative
Approach” by Hennessy and Patterson, 2nd Edition, Morgan Kaufman.
flow of control (chapter 4)

 23.3.2004
functions, (chapter 5)
partial compilation (cc -o)
runtime environment and the control stack; for more details see
“Runtime Environments”-Chapter 7 of “Compilers, Principles,
Techniques and Tools” by Aho, Sethi, and Ullman, Addison Wesley.

 30.3.2004
arrays, pointers and strings (chapter 6, up till multi-dimensional arrays)

Software 1, Short Bibliography
C:

The main textbook used in the course:

 A Book on C —3rd or 4th Edition / Kelley and Pohl
Addison-Wesley
 Excellent, terse, by the C language designers:
The C Programming Language / Kerninghan and Ritchie
2nd Edition, Prentic Hall

UNIX:

 For UNIX programming (I/O, processes, pipes, etc):
<! old address before the author died:>
<! HREF=”http://www.kohala.com/~rstevens/apue.html”>

Advanced Programming in the UNIX Environment

/ W.R.Stevens.Addison-Wesley.

You can download the example programs in this book from the book’s website
 For UNIX utilities, Shells:
UNIX for Programmers and Users, A Complete Guide / Glass and Ables.
Prentice Hall, 2nd edition, 1999.
 More recent
UNIX: The Textbook / Sarwar-Koretsky-Sarwar
Addison-Wesley, 2001.

C++:

 The C++ Programming Language , 3rd Edition / Stroustrup
Addison-Wesley

Yair Oz - Webcreator

Contact