Академический Документы
Профессиональный Документы
Культура Документы
S. Srinivasa Rao
Course Information
Course Instructor: Srinivasa Rao Satti Office: Room 413, Building 301. Email: ssrao@cse.snu.ac.kr Phone: 02-8801519 Teaching Assistant: Sunho Lee Email: slee@theory.snu.ac.kr Course Webpage: http://tcs.snu.ac.kr/CP2010.html
Course Description
The course introduces the student to the field of computing through LINUX/UNIX environment and C programming language. It provides general knowledge of UNIX/LINUX operating systems and how to write properly structured C programs.
Course Information
Textbooks: C programming:
C: The Complete Reference, H. Schildt, 4th Edition, McGraw-Hill, 2000. Unix Programming Environment, B. W. Kernighan and R. Pike,
Prentice-Hall Software Series.
UNIX:
Evaluation
Course Contents
Unix/Linux Basics. Utilities and Editors in Unix/Linux. Batch and Shell. Basic Concepts of C programs. C Complier and Linker. Threads and Processes. Control structures in C. Array and C Pointers. String Processing. File Processing. Modularity and Abstraction in C. Memory Management and Dynamic Data Structures in C. C libraries. Object-Oriented Programming.
Lecture Contents
Computer Organization
A computer is a device capable of performing computations and making logical decisions at speeds millions (even billions) of times faster than human beings can . von Neumann's architectures and principles.
Computer Organization
von Neumann's principle: Program is stored in the memory and processed as data.
Hardware: CPU, secondary/tertiary storage (disc, tape, CD etc.), input/output devices (key board, monitor, printer etc.) Software: System software: Operating system, support programs Application software: Word processors, accounting s/w, media players etc.
Operating System
A System Software that makes the use of Computer more convenient by helping users to:
Managing computer data and resources more efficiently. Provide a platform for running application programs. Provide the communication between user and the computer.
Operating Systems
Different Operating Systems have been developed over the years Dependent on hardware architectures Single tasking Multiple tasking. Single machine Distributed, networked computers.
Why UNIX?
Open Source Code. Cooperative Tools and Utilities. Multi-user and Multi-tasking Abilities. Excellent Networking Environment. Portability (Written in C).
Pascal, C, Fortran, COBOL C++, JAVA, Python, .NET languages PROLOG, LISP, JAVASCRIPT, VBSCRIPT, .
Functional Languages:
Script Languages:
BCPL developed by Martin Richards for writing operating systems and compilers Ken Thompson created B language based on BCPL and used it to write UNIX, Bell Laboratories 1970. Dennis Ritchie developed C based on B at Bell Laboratories in the 70s. C was standardized world-wide as a hardware-independent programming language by ANSI (American National Standard Institute) and ISO (International Organization for Standardization) in 1990 (ISO 9899:1990). C++ was developed by Bjarne Stroustrup in the early 80s at Bell Laboratories:
Why C/C++?
Structured and OOP Language. Flexibility (for programmer). Standardized and hardware-independent. Portability. Popularity. (C/C++ is for professionals)
History of UNIX
Multic OS at AT&T Bell Labs on GE 645 Computers in late 60s. 1969, Ken Thompson and his colleagues created a multitasking operating system, including a file system, a command interpreter, and some utilities for the DEC PDP-7 called UNICS (UNiplexed Information and Computing System). 1970, UNICS UNIX (rename). 1973, Kernel was rewritten in C by Thompson and Richie. 1982, AT&T released the first commercial version of UNIX Unix System III. 1983, Unix System V released by AT&T (1985 release 2, 1987 release 3, 1997 release 4).
History of UNIX
The Berkeley Software Distribution (BSD) Start with Thompson sabbatical at UC@Berkeley. Latest version 4.4 BSD. XENIX Started in 80s by Microsoft GNU 1984, Richard Stallman founded the Free Software Foundation and worked on GNU (Gnu is Not Unix) operating systems. Now it contains many tools and utilities available in UNIX. LINUX Started in 1991 by Linux Torvalds, latest kernel Linux 2.6 (2003).
UNIX Standards
Standards define the basic characteristics a UNIX system should have so that applications can be built to work on any system conforming to the standard. The System V Interface Definition (SVID),1983, by AT&T. POSIX (Portable Operating System Interface for Computer Environments ), 1985, IEEE Project 1003 (P1003). The Open Software Foundation (OSF), 1987, by IBM, DEC, and Hewlett-Packard, X/OPEN API. UNIX 98, UNIX03 (IBM and Sun).
UNIX Variants
Various widely used UNIX implementation: LINUX Redhat, Debian, , Ubuntu! BSD Variants: FreeBSD, NetBSD, and OpenBSD Solaris Developed by Sun Microsystems. Version 10 (2005), OpenSolaris (2005). AIX (IBM). HP-UX, UNIXWARE, Tru64 UNIX, IRIX. Which one to choose? Depends on your computing needs: low-end server or highend server.
UNIX Structures
The Onion structure of UNIX
UNIX Structures
The Onion structure of UNIX: Kernel: the part of the operating system that interacts directly with the hardware of a computer, through device drivers that are built into the kernel.
Provides sets of services that can be used by programs. Manage computer memory, to control access to the computer, to maintain the file system, to handle interrupts (signals to terminate execution), to handle errors, to perform input and output services among users.
UNIX Structures
The Onion structure of UNIX: Utilities: user created programs that could be executed by the shell. File System: file is the basic information unit in UNIX, they are organized and grouped in directories. The shell: reads and interprets your commands and execute users programs (tools and utilities). Also called command interpreter.
Starting Unix
Booting (Bootstrapping) : Start Up a Computer
Logging in to the System : Invoke the login Process Initialize the Environment Read the Start-up Files
init process (/sbin/init) invoked at the end) getty program executed per terminal
Starting Unix
Login
Starting Unix
Type the command Type the command and enter. Ctrl-C to cancel a command. e.g: passwd change the user password $ passwd passwd: changing password for corwin Old password: New password: Re-enter new password: $
File Systems
File name: sequence of characters Case sensitive, wildcard character Special characters:
File Systems
File Systems
Directory: files contain information about file or other subdirectories. Hierarchical file structures:
File Systems
Path names: Examples: /home/raf/Email/save /home/dkraut/Work/cs106x/Proj_1/lib/Source/strings.c
Relative Pathnames: Root: / Current: . ; e.g: ./share/prompt.cc Parent: .. ; e.g: ../tmp/img.jpg Home directory: ~ ; e.g: ~/../liz Previous directory: -
File Systems
UNIX File Types:
File Systems
Basic UNIX File/Directories Commands: Listing the contents of as directories: ls ls ~/program/ ; ls ; ls *.c Viewing content of a file: cat prog1.cc Creating a (text) file: (using editor is a better way) cat > prog1.cc Viewing present working directory: pwd
File Systems
Basic UNIX File/Directories Commands: Moving around directories $ cd /home/raf/Email Moving and renaming files/directories $ mv names /home/jmf/Info $ mv names /home/jmf/Info $ mv sec* TermPaper
$ mv notes Music/notes4
File Systems
Basic UNIX File/Directories Commands: Copying files: $ cp seattle seattle.bk $ cp -r Project Project.Backup (directory) Create linking files: $ ln /home/dkraut/project.main project.main Removing file: $ rm notes ; rm * Creating directories: $ mkdir New
File Systems
Basic UNIX File/Directories Commands: Removing directories: $ rm -r Work Viewing file information: $ file * Finding files: $ locate world (find files containing world) $ find -name new_data -print $ find / -name new_data -print > found & (running on the background)
File Systems
Basic UNIX File/Directories Commands: File permissions: r: read, w: write, x: execute 9 characters:
First threes: rights for the owner of the file; Second threes: rights for users in the same group; Third threes: rights for other users.
File Systems
Basic UNIX File/Directories Commands:
Change permission mode: $ chmod 700 quotations $ chmod 754 quotations Change owner of files: $ chown liz contact_info Change the group owner $ chgrp students data_file
File Systems
Basic UNIX File/Directories Commands: Viewing long files: $ pg newyork Print a file: $ lp research.nov Learning about a command man ls More on internal structures and manipulations of UNIX files will be in the part on C programming for UNIX File Processing!