UNIX

Post on 24-Feb-2016

14 views 0 download

Tags:

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

UNIXBy

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 Rewritten in C in 1973 The foundation of modern day Linux and BSD operating systems

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.

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

The File System

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

Three Types of Files1. Ordinary Files

Binary (executable) files Plain text files Symbolic links

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

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.

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

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

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.

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

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

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

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

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

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)

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

Processes and Images Image – execution environment

Core Image

Register Values

Open Files

Curr. Directory

Curr. state

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

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

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

Process Synchronization processid = wait()

Suspend execution

Wait for child process

Error if no children Can contain status from further descendants

Termination exit(status)

Terminates process

Destroys image

Closes open files

“Obliterates”

Returns to parent or higher

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

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

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

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 &

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

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

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

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

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

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

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