UNIX

35
UNIX By Nick Gomez, Chris Rees, Brian Hernandez, Hector Rodriguez, Chris Sosa, and Joshua Burbridge

description

UNIX. By Nick Gomez, Chris Rees, Brian Hernandez, Hector Rodriguez, Chris Sosa, and Joshua Burbridge. What Is UNIX?. An operating system originally created in 1969 Provided many ground-breaking features Completely self supporting Originally designed in assembly code - PowerPoint PPT Presentation

Transcript of UNIX

Page 1: UNIX

UNIXBy

Nick Gomez, Chris Rees, Brian Hernandez, Hector Rodriguez,

Chris Sosa, and Joshua Burbridge

Page 2: UNIX

What Is UNIX? An operating system originally created in 1969 Provided many ground-breaking features Completely self supporting Originally designed in assembly code Rewritten in C in 1973 The foundation of modern day Linux and BSD operating systems

Page 3: UNIX

Why UNIX?

UNIX incorporated many special features that were either new or uncommon to operating systems of the time. UNIX revolutionized operating system design,

and many of it’s principles are used in modern operating systems, such as Windows, OS X, and Linux.

Page 4: UNIX

Features Hierarchical File System Compatible File, Device, and Inter-Process I/O Asynchronous Processes System Command Language Supports Multiple Users

Page 5: UNIX

The File System

Let’s see why the UNIX file system was so unique for its day!

Page 6: UNIX

Three Types of Files1. Ordinary Files

Binary (executable) files Plain text files Symbolic links

Page 7: UNIX

Three Types of Files2. Directories

Provides mapping between file names and files Allows paths (e.g. /home/uname/Desktop) The base directory called root (e.g. / ) . and .. indicate current and parent directory respectively: /usr/local/.. same

as /usr

Page 8: UNIX

Three Types of FilesImportant Note

Files do not exist inside directories. Rather, directories store file names and pointers to the information that describes the file.

Page 9: UNIX

Three Types of Files3. Special Files

Represents a particular device Read from and write to like normal files Unlike normal files, it interacts with associated devices Stored in the /dev directory

Page 10: UNIX

Why Special Files? Provides little distinction between files and devices Programs expecting files to read/write to can also accept devices without

needing to differentiate the two Devices are subject to the same protection mechanics that files have

Page 11: UNIX

Removable File System

Another unique feature of the UNIX file system is removable file systems. Using the system command mount, you can attach removable volumes to a leaf in the file structure. There is virtually no distinction between the removable volume

and the permanent file system.

Page 12: UNIX

ProtectionAnother innovation of UNIX was access control on files.

Files created with owner name 6 bits for read/write/execute permissions for owner and others 7th bit can allow other users to temporarily become owner of the file

Page 13: UNIX

Super-User Regular users have limited access on a machine in some form or another Super-user is the highest privileged user on the machine, able to perform

any action Usual constraints on the machine do not apply to super-user Should only allow one person access

Page 14: UNIX

Implementation Of File System Directories contain file names and pointers Pointer is called an i-number (index number) of the file I-number references the information of the file in the system table

Page 15: UNIX

File Information Owner name Protection bits Physical address of location on disk Size Time of modification Number of links to file Directory bit Special file bit “Large” or “small” bit

Page 16: UNIX

Efficiency of File System File system provides satisfactory performance 7621 line test program

Total time of 35.9 seconds, 212 lines per second

Time taken for each element:

63.5% Assembler execution

20.0% Disk wait time

16.6% System overhead

Page 17: UNIX

I/O Calls Eliminate differences between different devices open(name, flag) and Create No user-visible automatic locks on files, unnecessary and insufficient Sufficient internal interlocks Files are sequential read(filep, buffer, count), write(filep, buffer, count) seek(filep, base, offset)

Page 18: UNIX

Special Files Unique feature of UNIX Integral to I/O devices Acts as ordinary file Read/Write requests activate device File and device I/O treated similar as possible

Same syntax and meaning

Same protection

Page 19: UNIX

Processes and Images Image – execution environment

Core Image

Register Values

Open Files

Curr. Directory

Curr. state

Page 20: UNIX

Processes Execution of image Image resides in core pID = fork(label)

Splits into two processes

Contain original image

Parent/child processes

Parent Process Control returns from fork

Child Process Control passed to label

Page 21: UNIX

Pipes filep = pipe()

Returns file descriptor

Creates interprocess channel

Passed from parent to child through fork Read/Write

Read waits, data transferred

Setup by common ancestor of processes

Page 22: UNIX

Execution of Programs execute(file, arg1, arg2, …, arg-n)

arg1 usually same as file

Read in/execute Creates process

Code in process replaced

Only returns on error “jump” instead of subroutine

Page 23: UNIX

Process Synchronization processid = wait()

Suspend execution

Wait for child process

Error if no children Can contain status from further descendants

Page 24: UNIX

Termination exit(status)

Terminates process

Destroys image

Closes open files

“Obliterates”

Returns to parent or higher

Page 25: UNIX

The Shell Aids in communication with UNIX Command line interpreter

Command + args

Delimit to strings, search for command Execute

Return to Shell

If command not found: /bin/ and execute

Page 26: UNIX

Standard I/O Open file

Descriptor 1 – typewriter, write to 1

Descriptor 0 – Read from 0

Can use “>” and “<“ “>” print/out to file after

“<“ read/in from file after

ls > there

ed < script

Interpreted directly by the Shell

Page 27: UNIX

Filters Commands can direct to each other

Use |

ls | pr -2| opr

Simplifies commands to the Shell Makes commands look less “clumsy” Filter – copies standard input to standard output with processing Character transliteration, sorting of input, encryption/decryption

Page 28: UNIX

Command Separators: Multitasking Provided by the Shell Commands separated by ;

ls ; ed

Commands followed by & do not wait for termination as source > output &

Use parenthesis for order of operations (date ; ls) > x &

Page 29: UNIX

Shell as Command: Command Files Shell is a command

Can be called recursively

File contains following lines:as source

mv a.out testprog

testprog

Command sh < filename Can also substitute parameters

Page 30: UNIX

Implementation of the Shell Shell mostly waits for user input New-line character causes read to return Read broken down into form capable of execute fork() called Child process attempts to execute with arguments

Parent waits for child to die

Command is finished. Shell waits for next command

Main loop of Shell never terminates Except at EOF

Page 31: UNIX

Initialization Instances of Shell that user sees are child processes UNIX creates process of init on startup

1 for keyboard, 0 for printer file descriptions

Creates Shell when user logs in

When Shell executes, init waits

Page 32: UNIX

Other Programs as Shell User’s entry in password file can contain name of program Programs can be executed at login

Can immediately begin working

User’s can be prevented from invoking programs Limit users to ONLY single program

Ex: Chess

Log in as player, only play game

Page 33: UNIX

Traps Programs stuck in loop can be terminated Interrupt signal

“delete” character

Cease execution, do not produce core image file

Quit signal Force core image to be created

Shell ignores quits Prevent user from being logged out by quit

Page 34: UNIX

Perspective UNIX was not created to meet any needs Creators dissatisfied

Created more “hospitable” environment for PDP-7

Written to easily write, test, run programs System was able to maintain itself Easily modified to fit new ideas/technology

Page 35: UNIX

Influences Success of UNIX comes from exploitation of specific ideas Examples include

Fork operation from Berkely

I/O System calls from Multics

Shell name and function from Multics