1d3be4e91ad3a0578585c80f86699eb1.ppt
- Количество слайдов: 20
UNIX • Unix is an operating system developed at Bell Labs in 1969. • Like all operating systems, unix manages the resources of the computer and provides an interface for users to access system functions. • Unix is a general purpose op. sys. It is used, for example, by Sun to develop java applications. It is not suited to real time applications. • It was designed to provide a superior sw development environment; to be simple, powerful, and compact. • It was originally written in pdp-7 (DEC) assembly language by Ken Thompson so he could run his program “space travel” on the pdp.
UNIX –more history • The uni- part refers to unix being developed for single users originally. • Unix’s history is intertwined with the development of C, also at Bell labs. Thompson developed a language called “B” which was used to help transport Unix to the Pdp-11 in 1971. • Unix became the o. s. of choice for the pdp-11 computer, preferable to DEC’s own o. s. • Dennis Ritchie, also at Bell Labs, refined the “B” language to create C. • Unix was itself rewritten in C in 1973. • Unix was adapted to a 16 bit microcomputer by a small company, Onyx, in 1980. • There are many versions out there: Xenix, Ultrix are a couple.
Key Features 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Portability Portable applications sw Multiuser operation (it can support multiuser mainframe environments) Background processing Hierarchical file system UNIX shell- a command interpreter Pipes- allows several prgrams to be combined so that the output from one becomes input to the next Utilities Text-processing tools Sw development tools maturity
Structure of UNIX • The kernel is the core of the system controlling hardware and performing lowlevel functions. • The shell is the command interpreter (user interface). • Two hundred + utility programs provide functions like file copy, text edit, sw compilation and so on. • User programs logically occupy directory space analogous to the utility programs.
The kernel • The kernel interacts directly with system hardware, implements the file system, manages memory, enforces security, performs I/o. If the system is muti-user, the kernel provides the system timesharing capability. apps utilities shell kernel Hardware & peripherals
The kernel • The kernel also maintains system logs. • Since the kernel interacts directly with the system hw, the kernel is custom written for each processor type that unix runs on. File mgmt Date/time &security I/o svces kernel Process scheduling Ints and Error System Memory handling accounti mgmt ng
Call interface • Utilities and applications call the kernel to provide services. • The call interface is the same for unix no matter what hw it runs on. Call: Request service: Type Details data User program wants service Return: Service complete Status data UNIX kernel provides services
The file system: features • • • Hierarchical Dynamic: file sizes grow as needed Structureless: no internal structure is imposed Security: files can be protected from access by other users File – device independence: files and I/o devices are regarded the same by the o. s. So the same utilities used to process files can be used to process data from the terminal or as it is sent to the printer.
Files& directories • File names can be up to 14 characters. • A directory can be used to organize files. A directory is really just a file with a list of entries (file names) in it as well as information on where to find those files in the system (in a data structure called the inode). • Users typically have their own directories. • Files can have multiple names and multiple links (from different directories) Below, the filenames People and XYZ refer to the same file. • Directory A Directory B – Results 0011 – People 1122 – Data 0123 • Files: file 0123 - XYZ file 0011 file 1122
Hierarchical systems and path names • Typical file systems have many levels / (root) in unix is at the top. • Path names are separated by forward slashes (division sign) with a slash first if the pathname starts at the root directory: /usr/higgins/csci 201/unixnotes • Such a path name is called fully qualified because the complete path from the root to the file is identified. • Partial pathnames can be used, these are relative, indicating a path from the current working directory. If I am in /usr/higgins then the name csci 201/unixnotes identifies the same file. • Unix maintains information on each file: location, size, link count, ownership, security setting, type, creation date, most recent modification, last access.
devices • Typical unix devices are – /dev/lp (line printer) – /dev/dk 0 (disks) – /dev/dk 1 (etc) – /dev/rdk 0 (disk as raw I/o device) – /dev/tty 0 (terminals) – /dev/null • To copy a file to another file location you would type cp fname othername • To copy the same file to the printer you would type cp fname /dev/lp
directories • • • • /bin utilities /dev special files (I/o devices) /etc administration /lib libraries used by the language processors /tmp temporary /usr/bin overflow for /bin /adm/bin adminstration files /usr/games /usr/include files for C /usr/lib archive libraries and textprocessing macros /usr/mail /usr/spool files for printing Usr/src source files
Hierarchy chart: / is the root / bin dev etc usr higgins bin lib tmp
File management utilities • • • • pwd prints name of the current working directory cd change pwd ls list directory contents cat concatenate files mv move/rename file ln create a new link for a file cp copy files mkdir make a dir rm remove a file rmdir du display disk utilization df display tree blocks for mounted systems touch update time of last mod for a file find files
examples $ pwd /usr/higgins/courses/csci 201 $ cd /usr/higgins/courses/csci 311 $ ls /usr/higgins/courses/csci 201 assignments sampletests classlist $cat classlist bob joe sue mary rudolf xenophon show present working directory change to directory specified list directory contents show file contents on terminal
examples- continued • most common use of cat is to show file contents • mv changes a filename $ mv classlist students mv can similarly be used to rename a directory ls- l means list long, and gives more details about files in the directory. ln is used to create additional links (not additional copies) of a file $ ln students classlist cp makes a duplicate file $cp classlist mkdir creates a new directory $ mkdir /usr/higgins/courses/csci 116
examples- continued • rm is used to remove a file $ rm list rm can be used to delete directories and their contents also if you use $ rm –r /usr/higgins/courses rmdir can be used to remove (delete) empty directories.
File storage & Buffered disk access • Whatever block size the system uses the location of the first ten blocks of a file are stored in the inode. If the file is larger than 10 blocks, then the address of an indirect block is stored in the inode as well, which has the addresses of the files subsequent blocks. This technique is applied up to 3 times (triple indirection). The inode stores the location of a triple indirect block which stores the addresses of double indirect blocks, each of which stores the addresses of sngle indirect blocks, which point to file blocks on the disk. • As with most modern operating systems, i/o is buffered in unix: This means that some disk blocks are duplicated in main memory. A read request first checks if the required data is already available. If not, it can be brought into the buffer. When the buffer is full and a read requests new data, some must be swapped out of the buffer. Similarly, write requests write to a buffer until the buffer is full or is flushed.
the unix shell • The shell provides an interface between the user and unix o. s. services. • Some features of this command interpreter are – interactive: the user has a dialog with the computer – background processing: time consuming tasks can be run in the background – i/o redirection: program i/o can be redirected from/to other files, the terminal, the printer, etc. – simple programs can be piped together to perform more complex operations – wild-card matching: a pattern can be used to select files for processing so that a number of files can be processed with a single command – shell scripts: commonly used sequences of shell command can be stred in files and executed. – shell variables can be used to control the shell and other programs