Вы находитесь на странице: 1из 50

UNIX – Operating System

Unit 1

Faculty : Vinay
Email : vinay.m@christuniversity.in

1
INDEX

Evolution of UNIX

UNIX System Structure

Features of Unix

Operating System Services

Unix Kernel

Architecture of Unix

System Concepts

Kernel Data Structures

Introduction to System Calls

Types of System Calls.


Introduction

Computer systems didn't talk to each other in the early


days of computing. Even the various computer system
made by the same company often needed interpreters.

And no interoperability of systems by different vendors.

In addition, operating systems very often performed


only limited tasks, and only on the machines for which
they were written. If a business upgraded to a bigger,
more powerful computer, the old operating system
probably wouldn't work on the new computer, and
often the company's data had to be entered -- again -- into
the new machine.

3
History of Unix

To try to develop a convenient, interactive, useable


computer system that could support many users, a group of
computer scientists from Bell Labs and GE in 1965 joined
an effort underway at MIT on what was called the MULTICS
(Multiplexed Information and Computing Service)
mainframe timesharing system.

“ The Unix operating system found its beginnings in MULTICS. “

In 1969 Bell Laboratories pulled out of the project.

One of Bell Laboratories people involved in the project


was Ken Thompson. He liked the potential MULTICS
had, but felt it was too complex and that the same thing
could be done in simpler way.

4
History of Unix

In 1969 he wrote the first version of Unix, called


UNICS. UNICS stood for Uniplexed Operating and
Computing System.

Although the operating system has changed, the name


stuck and was eventually shortened to UNIX.

Ken Thompson teamed up


with Dennis Ritchie, who
wrote the first C compiler.

In 1973 they rewrote the


Unix kernel in C.

5
History of Unix

The following year a version of Unix known as the Fifth


Edition was first licensed to universities. The Seventh
Edition, released in 1978 served as a dividing point for two
divergent lines of Unix development. These two branches are
known as SVR4 (System V) and BSD (Berkeley Software
Distribution) .

The Linux operating system was developed as a Unix


look alike and has a user command interface that
resembles SVR4.

Many companies developed and marketed their own


versions of UNIX in subsequent years.

6
Variations of UNIX include AIX, a version

of UNIX adapted by IBM to run on RISC-

based workstations

A/UX, a graphical version for the Apple

Macintosh

XENIX OS, developed by Microsoft

Corporation

SunOS, adapted and distributed by Sun

Microsystems, Inc.; Mach, a UNIX-

compatible operating system for the NeXT

computer;

and Linux, developed by Finnish

computer engineer Linus Torvalds with

collaborators worldwide.
7
UNIX Flavors

AIX by IBMBSD/OS (BSDi) by Wind River


CLIX by Intergraph Corp.
Debian GNU/Linux by Software in the Public Interest, Inc.
Tru64 Unix (formerly Digital Unix) by Compaq Computer Corp.
DYNIX/ptx by IBM (formerly by Sequent Computer Systems)
Esix Unix Esix Systems
FreeBSD by FreeBSD Group
GNU Herd by GNU Organization
HAL SPARC64/OS by HAL Computer Systems, Inc.
HP-UX by Hewlett-Packard Company
Irix by Silicon Graphics, Inc. Red Hat Linux by Red Hat Software, Inc.
Linux by several groups several Reliant Unix by Siemens AG
LynxOS by Lynx Real-Time Systems, Inc. SCO Unix by The Santa Cruz Operation Inc.
MacOS X Server by Apple Computer, Inc. Solaris by Sun Microsystems
NetBSD by NetBSD Group SuSE by S.u.S.E., Inc.
OpenBSD by OpenBSD Group UNICOS by Silicon Graphics, Inc.
OpenLinux by Caldera Systems, Inc. UTS by UTS Global, LLC
Openstep by Apple Computer, Inc.
NonStop-UX by Compaq Computer Corporation
8
History of Unix

With Sun Microsystems' first workstation, UNIX was


the software that ran on the best low-cost available
hardware. For a given price, you could get much more
performance than was possible before.

For startup companies, UNIX has really priced itself


out of the market. Licensing fees for SVR4 and OSF/1 are
prohibitive for a company that doesn't have very, very
deep pockets.

As soon as Microsoft released Windows NT in the market , the


popularity of Unix decreased little bit. Then with success with
The Windows NT people started shifting from UNIX to
Windows NT.

Later when they came to know the problem with NT they realized
that UNIX was better.
9
The Connection Between Unix and C
At the time the first Unix was written, most operating systems
developers believed that an operating system must be written in
an assembly language so that it could function effectively and gain
access to the hardware. Not only was Unix innovative as an operating
system, it was ground-breaking in that it was written in a language
(C) that was not an assembly language.

The C language itself operates at a level that is just high


enough to be portable to variety of computer hardware. A
great deal of publicly available Unix software is distributed
as C programs that must be complied before use.

Many Unix programs follow C's syntax. Unix system calls are
regarded as C functions.

What this means for Unix system administrators is that an


understanding of C can make Unix easier to understand
10
Unix is a multi-user, multi-tasking operating system. You can have
many users logged into a system simultaneously, each running many
programs.

It’s the kernel’s job to keep each process and user separate and to
regulate access to system hardware, including cpu, memory, disk and
other I/O devices.

11
Why Use UNIX ?

One of the biggest reasons for using Unix is


networking capability. With other operating systems,
additional software must be purchased for networking.
With Unix, networking capability is simply part of the
operating system. Unix is ideal for such things as world
wide e-mail and connecting to the Internet.

Unix was founded on what could be called a "small is


good" philosophy. The idea is that each program is
designed to do one job well. Because Unix was developed by
different people with different needs it has grown to an
operating system that is both flexible and easy to adapt
for specific needs.

12
Why use Unix

Unix was written in a machine independent


language. So Unix and UNIX-like operating systems
can run on a variety of hardware. These systems are
available from many different sources, some of them at no
cost.

Because of this diversity and the ability to utilize the same


"user-interface" on many different systems, Unix is said to
be an open system.

13
An Overview of UNIX Operating system

The UNIX operating system was designed to let


a number of programmers access the computer at the
same time and share its resources

The operating system coordinates the use of the


computer's resources, allowing one person, for
example, to run a spell check program while another
creates a document, lets another edit a document
while another creates graphics, and lets another user
format a document -- all at the same time, with each
user oblivious to the activities of the others.

14
Overview of Unix OS
The operating system controls all of the commands
from all of the keyboards and all of the data being
generated, and permits each user to believe he or she
is the only person working on the computer.

“This real-time sharing of resources make UNIX


one of the most powerful operating systems ever”

Although UNIX was developed by programmers for


programmers, it provides an environment so powerful
and flexible that it is found in businesses, sciences,
academia, and industry. Many
telecommunications switches and transmission
systems also are controlled by administration and
maintenance systems based on UNIX.

15
Overview of Unix OS
While initially designed for medium-sized
minicomputers, the operating system was soon moved to
larger, more powerful mainframe computers.
As personal computers grew in popularity, versions of
UNIX found their way into these boxes, and a number of
companies produce UNIX-based machines for the
scientific and programming communities.

16
The Uniqueness of UNIX

The features that made UNIX a hit from the start are:

Multitasking capability

Multi-user capability

Portability

UNIX programs

Library of application software

17
Uniqueness of UNIX

Multitasking

Many computers do just one thing at a time, as anyone


who uses a PC or laptop can attest. Try logging onto your
company's network while opening your browser while opening
a word processing program. Chances are the processor will
freeze for a few seconds while it sorts out the multiple
instructions.

UNIX, on the other hand, lets a computer do several


things at once, such as printing out one file while the user
edits another file. This is a major feature for users, since
users don't have to wait for one application to end before
starting another one.

18
Uniqueness of UNIX

Multi-Users

The same design that permits multitasking


permits multiple users to use the computer. The
computer can take the commands of a number of
users -- determined by the design of the computer --
to run programs, access files, and print documents at
the same time.

The computer can't tell the printer to print all the


requests at once, but it does prioritize the requests to
keep everything orderly. It also lets several users
access the same document by compartmentalizing
the document so that the changes of one user don't
override the changes of another user.

19
Uniqueness of UNIX

System portability

A major contribution of the UNIX system was its


portability, permitting it to move from one brand of
computer to another with a minimum of code
changes. At a time when different computer lines of
the same vendor didn't talk to each other -- yet alone
machines of multiple vendors -- that meant a great
savings in both hardware and software upgrades.

It also meant that the operating system could be


upgraded without having all the customer's data
inputted again. And new versions of UNIX were
backward compatible with older versions, making it
easier for companies to upgrade in an orderly manner

20
[ 6 Marks ]
Features of UNIX

FEATURES AND BENEFITS OF UNIX

The UNIX operating System is available on machines with


a wide range of computing power, from
microcomputers to mainframes, and on different
manufacturers machines. No other operating system
can make this claim. The popularity and success of UNIX is
due to the following reasons:

PORTABILITY :

The system is written in a high level language making


it easier to read, understand, change and, therefore move to
other machines. The code can be changed and compiled on
a new machine. Customers can choose from a wide
variety of hardware vendors without being ‘locked’ with a
particular vendor.
21
Features of UNIX
Machine Independence :

The system hides the machine architecture from the


user, making it easier to write applications that can run
on micros, minis and mainframes.

Multi User Operations :

UNIX is a multi-user system designed to support a group


of users simultaneously. The system allows for the sharing
of processing power and peripheral resources, while at
the same time providing excellent security features..

Hierarchical File System :

UNIX uses a hierarchical file structure to store


information. This structure has the maximum flexibility in
grouping information in a way that reflects its natural
state. It allows for easy maintenance and efficient
implementations. 22
Features of UNIX
UNIX SHELL :
UNIX has a simple user interface called the shell that
has the power to provide the services that the user wants. It
protects the user from having to know the intricate
hardware details.

PIPES and FILTERS :


UNIX has facilities called pipes and filters which permit
the user to create complex programs from simple programs.

Utilities :
UNIX has over 200 utility programs for various
functions. New utilities can be built effortlessly by combining
existing utilities.

23
Features of UNIX
Background Processing :
UNIX has a facility by which the user can start a process
and then proceed to work on other processes while the
system runs the first process in background and the second
process in the foreground. Background processing helps the
user in effective utilization of time.

Software Development Tools :


UNIX offers an excellent variety of tools for software
development for all phases, from program editing to
maintenance of software..

Maturity :
UNIX is a time-based operating system. It offers a “bug-
free environment” and a “high level reliability”.

The UNIX system supports a wide variety of languages :


C, FORTRON, BASIC, PASCAL, Ada, COBOL, Lisp, Prolog.
24
Some more features :

Input / Output redirection and Pipes

Consistent Peripheral Interface

Communication and Networking

25
UNIX System Structure [ 10 Marks ]

How UNIX is organized


The UNIX system is functionally organized at 3 levels:

1 The kernel,[ core of UNIX System]


which schedules tasks and manages storage.

2 The shell,[ interpreter b/w User and Computer]


which connects and interprets users'
commands, calls programs from memory, and
executes them, and

3 The tools and applications that offer additional


functionality to the operating system.

26
4. Utility Programs

5 User programs can be developed using UNIX utilities,


purchased from software suppliers.

27
[ 10 Marks ]

High level of UNIX


Architecture k ages
a c
tab ase P
Da

Oth
ll
she

er A
User

p
pl n
Kernel
Compilers

so f
sh
User

tw a
ll
Hardware

re's
UN

sh
IX

e
co

ll

ll
she
m
m
an
d

ls
s

oo
e tt
rn
I nte
28
Any Command cannot be executed unless it obtains the clearance
of the Shell .

The Shell , when analyzing the command and its associated


arguments often modifies and simplifies its input before It
forwards it to another agency which Actually executes the
command.

This agency is called the KERNEL .

UNIX permits the use of complex command structures that can’t


be understood by the kernel, the shell has to take on the role of
interpreter to translate them into forms that the kernel can
understand.

The shell , is actually the interface between the user and the
kernel that effectively insulates the user from knowledge of
kernel functions.
29
Kernel
 Core of the Unix system
 Interacts directly with the hardware
 Insulates other parts of UNIX from hardware
 Performs all low level functions
 Parts of the kernel deals with I/O devices , called device drivers
 All programs and applications interact with the kernel

30
[ 10 Marks ]
UNIX Architecture / kernel

The KERNEL

The kernel is the heart of he system – a collection of programs


mostly written in C that directly communicate with hardware.
There is only one kernel for any system. It’s that part of the UNIX
system that is loaded into memory when the system is booted.

Kernel does not directly deal with the user. Instead it starts a separate
program called shell , which actually interacts with the user and
interprets the command

It directly interacts with hardware , parts of the kernel must


be customized to each system’s hardware features.

31
Functions Performed by Kernel
Memory management

Process scheduling

File Management and security

Interrupt handling and error reporting

Input / Output services

Date and Time services

System Accounting

32
[ 10 Marks ]
UNIX Architecture / kernel

Functions Performed by Kernel


 Managing the machines memory and allocating it to each
process

 Scheduling the work done by the CPU so that the work of


each user is carried as efficiently as is possible.

 Organizing the transfer of data from one part of the machine


to another.

 Accepting instructions from the shell and carrying them


out.

 Enforcing the access permissions that are in force on the file


system .

33
34
KERNEL LEVEL

File subsystem : this takes care of where to store , how to retrieve, and the
related job with files (data)

Process subsystem : this comprises of IPC, scheduler and Memory


management

IPC stands for Interprocess Communication between the processes .

The techniques used in UNIX for this IPC are pipes, messages, shared
memory and semaphores.

Scheduler is responsible for scheduling the processes.

Memory Management is about where to place a program in memory,


allows programs of bigger than the memory size to be executed.

35
36
The SHELL

 Interface for the user to access services from the kernel

 Is the command interpreter of UNIX

 Provides powerful programming capabilities

The Shell is a utility program that comes with the UNIX system.
However, it plays a very important role. It acts as the command
interpreter for the kernel and is the interface between the user and
the kernel.

37
[ 5 Marks ]

Shell features and Benifits


Interactive Processing :
Communication between the users and the system takes the form of an interactive
dialogue with the shell.

Background Processing :
Time-consuming, non-interactive tasks can proceed while the user continues with other
processing. Therefore, the system can perform many different tasks at the same time
on behalf of a single-user.

Input/Output Redirection :
Programs designed to interact with user can easily be instructed to take their input from
another source, such as a file, and send their output to another destination, such as
printer.

38
Pipes:
Programs that perform simple functions can easily be connected to perform more
complex functions , minimizing the need to develop new programs.

Shell Scripts :
A frequently used sequence of shell commands can be stored in a file. The name
of the file can later be used to execute the stored sequence with a single command.

Shell Variables :
The user can control the behavior of the shell, as well as other programs and
utilities, by storing data in variables.

Programming Language Constructs :


The shell includes features that allow it to be used as a programming language.
These features can be used to build shell scripts that perform complex operations.
39
Using the Shell

User interaction with the shell takes the form of a dialogue. First the
shell asks the user for input, then the user types a command, and
finally the shell causes the command to be carried out.

When shell is ready for command input, the shell displays a prompt
on the terminal screen, usually a dollar sign ( $ ).

The shell itself does not carry out most of the commands that are
typed to it. Instead , the shell examines each command and starts
the appropriate UNIX utility program that carries out the requested action.

The standard UNIX system comes with over two hundred utility programs.
(one of these utilities is sh - the shell itself)

40
Using the UNIX Shell

User
Login Interacts
with Utility

Shell ask
for a Shell ask
command for next
command

User
Types User
Command Types
Control D

Shell
Executes
utility to Logout
carry out
command
41
[2 or 6 Marks ]

[ There are 7 types shells are


available ]
Sh ( Bourne shell)  Written by S.R. Bourne
 It is the granddaddy of Unix Shells. This is still Widely used Today.
 As a scripting language, this shell provides all the necessary
constructs to create structured programs.
 Permits you to open or duplicate arbitrary file descriptors.
 Fastest UNIX command processor available.
* Lack of command line editing features and Job Control

42
[ 6 Marks ]

Csh ( C-Shell )  written by Bill Joy ( University Of


California )

 C-Shell supports a full range of structured programming constructs.


 C-Shell weak in supporting I/O redirection.
 As name it self says supports , C (language ) like syntax.
* Does not permits you to open / duplicate arbitrary file descriptors.
* Less suitable for complex Shell Programming due to its implementation

Characteristics.

Ksh ( Korn-Shell )  written by David (AT & T Lab )

 Combines both Bourne Shell and C-Shell. It includes job control,


aliasing and an improved command history and editing facilities
introduced by C-Shell, along with stronger syntactical language of the
Bourne Shell.

43
bash ( -Shell )  part of Free Software Foundations (FSF)
excellent suite of Unix tools. It matches the Korn shell feature.
Which is owned by AT & T, bash is freely available. It also
maintains a high degree of compatibility with the Bourne shell
and can run that shell’s script without any modifications

Tcsh  replacement for C-Shell

Pdksh  it is a compatible public-domain implementation of the korn shell.

Zsh  written by  paul Falstad.


zsh is another richly featured, freely available Bourne/Korn based
shell.

44
System call
UNIX system and application programs call on the kernel to perform services for them.

The mechanism used to request kernel services is called a system call.

Each system call instructs the kernel to perform one particular service on behalf of the
program making the call.

For example , each time an application program wants to read a line of user input from
a terminal , the program calls the kernel, which obtains the requested data and passes
it on to the program.

System calls are the interface between UNIX-based applications programs and the
UNIX kernel. These calls are the only way that application programs and the kernel
interact directly in a UNIX based system.

45
Anatomy of a System Call

User Program
( Requests Services )
Call Return
Request services Service complete
- Type - Status
- Details - Data
- Data
UNIX System Kernel
(Provides Services)

46
The UNIX kernel supports over sixty different system calls. These calls are identical
on every UNIX system. No matter what hardware differences exists down below or
whether the system is an IBM PC or a mainframe , the system calls are the same.

Thus the system calls form a standard interface for the UNIX system.

47
Some System call

System calls for low level file I/O


creat(name, permissions)
open(name, mode)
close(fd)
unlink(fd)
read(fd, buffer, n_to_read)
write(fd, buffer, n_to_write)
lseek(fd, offest, whence)
System Calls for process control
fork()
wait()
execl(), execlp(), execv(), execvp()
exit()
signal(sig, handler)
kill(sig, pid)
System Calls for IPC
pipe(fildes)
dup(fd)

48
File Structure
• Hierarchical Structure

• Consistent treatment of data files

• Ability to create and delete files

• Dynamic growth of files

• Protection of file data

• Treatment of peripheral devices as files

49
The File system consist of all types of files and resembles an
inverted tree structure

The directories can have sub directories resulting in a large


hierarchical structure

A hierarchical file structure provides higher system performance,


sheltering private data from unauthorized users and enhancing
security against unintentional damage .

UNIX treats Input / Output devices as files . UNIX stores all files
as stream of bytes.

Space is allocated dynamically according to the size of the file


which changes in the
number of bytes.

50

Вам также может понравиться