0% found this document useful (0 votes)
26 views

Unix

The document provides an introduction to the UNIX operating system. It discusses key points such as: 1) The architecture of UNIX is divided into 4 major components - the kernel, shell, files/processes, and system calls. The kernel performs low-level tasks like memory and device management. 2) Features of UNIX include its simple, modular design; portability across machines; ability to support multiple users and tasks simultaneously; and high level of security. 3) The kernel manages hardware interfaces, file systems, I/O devices, process scheduling, memory, and inter-process communication to allow user programs to run.

Uploaded by

devisriv9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Unix

The document provides an introduction to the UNIX operating system. It discusses key points such as: 1) The architecture of UNIX is divided into 4 major components - the kernel, shell, files/processes, and system calls. The kernel performs low-level tasks like memory and device management. 2) Features of UNIX include its simple, modular design; portability across machines; ability to support multiple users and tasks simultaneously; and high level of security. 3) The kernel manages hardware interfaces, file systems, I/O devices, process scheduling, memory, and inter-process communication to allow user programs to run.

Uploaded by

devisriv9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Chapter 1: Introduction to UNIX UNIX Operating System

CHAPTER 1: INTRODUCTION TO UNIX


Evolution of UNIX- UNIX System Structure- Features of UNIX- Operating
System Services. Architecture of UNIX system, architecture of kernel, features
of Kernel.

 Definition of operating system


Operating System is the system software that manages computer
hardware, software resources, and provides common services for computer
programs.

 Features of operating system


1) Memory management
Memory management module performs allocation and de-allocation of
memory space.
2) Processor management
It helps OS to create and delete processes.
3) Device management
It keeps tracks of all devices.
4) File management
It manages all file related activities such as organization, storage, retrieval,
naming, sharing and protection of files.
5) Security
Security modules protects the data and information of a computer system
against authorized access.
6) Job accounting
Keep track of time and resource used by various jobs and users.
7) Control over system performance
Recording delays between request for a service and response from the system.

 How operating system works?


Operating system is loaded into memory when a computer is booted and remains
active as long as machine is up. After any program has completed execution, the
operating system cleans up the memory and registers and makes them available
for the next program

 Examples of operating system


Microsoft Windows, UNIX, Linux, MacOS etc

 Definition of UNIX
UNIX is a portable, multitasking, multiuser, time sharing operating system(OS).
Chapter 1: Introduction to UNIX UNIX Operating System

 Founder of UNIX
The UNIX was founded by Ken Thompson, Dennis Ritchie and Brain
kerninghan at AT& T Bell Labs research in 1969.

 Founder of LINUX
Linus Benedict Torvalds in 1991.

 Difference between UNIX and LINUX (linux is a unix clone)


UNIX LINUX
It is a multi tasking, multiuser operating It is a free and open source software.
system
Developed by ken Thompson, Dennis Developed by Linus Benedict Torvalds.
Ritchie and Brain Kerninghan
Source code is not available to general Source code is available to general
public. public
Not portable Portable
Solaris, HP UNIX are some versions. Ubuntu, Fedora are some versions.

 Need of UNIX
Network capability:
With other OS, additional software must be purchased for networking but with
UNIX, network capability is the part of the operating system.

 History of UNIX
1960 Bell labs involved in the project with MIT, General Electric and Bell
Laboratories to develop a time sharing system called
MULTICS(Multiplexed Operating and Computing System).
1969 Ken Thompson wrote the first version of the UNIX called
UNICS(Uniplexed Information and Computing System)
1970 Finally UNICS became UNIX.

 Differences between UNIX and DOS


UNIX DOS
UNIX can have GUI DOS Can’t have GUI
UNIX is more secure DOS is not more secure compared to UNIX
UNIX is multitasking DOS is singletasking
UNIX are multiuser DOS is single user
UNIX is case sensitive DOS is not case sensitive
UNIX is used in servers DOS is used in embedded systems

 Differences between UNIX and Windows


UNIX Windows
UNIX is an open source(free Windows is not an open source(paid
Chapter 1: Introduction to UNIX UNIX Operating System

download) one)
UNIX has very high security system Windows has low security system
UNIX is a command based operating Windows is not a command based
system operating system
The file system is arranged in The file system is arranged in parallel
hierarchical manner manner
UNIX is not a user friendly Windows is a user friendly
Free office(such as excel, PowerPoint Pay for MS Office
and others)
Low Hardware cost High Hardware cost
Customizable add features Not customizable

 Architecture of UNIX System/ UNIX System Structure

The Architecture of the UNIX system is divided into 4 major components. They are:

1) The Kernel
2) The Shell
3) Files and Processes
4) System Calls
1. The Kernel
 The Kernel is the heart of the Operating System.
 It interface between Shell and Hardware.
 It performs Low Level Task.
 Eg: Device Management, Memory Management etc.
2. The Shell
Chapter 1: Introduction to UNIX UNIX Operating System

 The Shell is a collection of UNIX Commands.


 The Shell acts as an interface between the user and the kernel.
 The Shell is a Command Line Interpreter(CLI)–Translates the commands
provided by the user and converts it into a language that is understood by
the Kernel.
 Only one Kernel running on the system, but several shells in action-one for
each user who is logged in.
 Eg: C Shell, Bourne Shell, Korn Shell etc.
3. Files and Processes
 A File is an array of bytes and can contain anything.
 All the data in UNIX is organized into files.
 A Process is a program file under execution.
 Files and Processes belongs to a separate hierarchical structure.
4. System Calls
 UNIX is written in C.
 Thousands of commands in the system uses a handful of functions called
System Calls to communicate with the kernel.

 Features of UNIX
1) Simple design, organization and functioning
The architecture of the UNIX is simple, organized and functional.
2) Portability
The code can be changed and compiled on a new machine.
3) UNIX Shell
The user interface UNIX Shell provides the services that the user wants.
4) Hierarchical file system
UNIX uses a hierarchical file structure to store information.
5) Multi user
UNIX allows more than one user to share the same computer system at the
same time.
6) Multi-tasking
More than one program can be run at a time.
7) Security
UNIX provides high security level( System level security and File level
security)
8) Pipes and Filters
In UNIX, we can create complex programs from simple programs.
9) Utilities
UNIX has over 200 utility programs for various functions.
10) Machine Independence
Chapter 1: Introduction to UNIX UNIX Operating System

The system hides the machine architecture from the user, making it easier to
write applications that can run any computer system.

 Architecture of Kernel

 The system call and library interface represent the border between
user programs and the kernel.
 The File subsystem manages files, allocating file space,
administrating free space, controlling access to files and retrieving
data for users.
 Kernel Interface to Hardware is responsible for handling interrupts
and for communicating with the machine.
 Device drivers are the kernel modules that control the operation of
peripheral devices.
 Block I/O devices are random access storage devices to reset the system.
 Scheduler module allocates CPU to processes.
 Memory management module controls allocation of memory.
 Inter-process communication (IPC) ranges from asynchronous
signaling of events to synchronous transmission of messages between
processes.

 Features of Kernel
1) Concurrency
Many processes run concurrently to improve the performance of the system.
2) Virtual Memory(VM)
Chapter 1: Introduction to UNIX UNIX Operating System

Memory management subsystem implements the virtual memory and users


need not worry about the executable program size and RAM size.
3) Paging
It is a technique to minimize the internal and external fragmentation in the
physical memory.
4) Virtual File System(VFS)
A VFS is a file system used to help the user to hide the different file systems
complexities.
5) Inter process communication
Itranges from asynchronous signaling of events to synchronous transmission
of messages between processes.

 Operating System Services


1) User interface
User interface refers to the software that allows a person to interact with the
computer.
2) Program execution
The system creates a special environment for that program.
3) File system manipulation
File manipulation commands manipulates the file.
4) Input/ Output operation
OS provides the capability to change where standard input comes from or
where output goes using Input/Output concept.
5) Communication
Communication commands makes proper communication between different
computers, networks and remote users.
6) Resource allocation
Resource allocation techniques allocates resources when a program need
them.
7) Error detection
Error detection techniques helps us to detect and correct errors.
8) Accounting
It helps us to maintain account details of users.
9) Security and protection
Only authorised users can access the files and directories.
*****
Process management

Process :- Process can be defined as a program under Execution. Unix runs many programs at the
same time by using Round-robin Scheduling algorithm.

Shell process (sh):-

shell creates a process for executing the catcommand.


The shell process(sh) is a parent process and the cat process is a child process. As long as process is running, it is alive. Aft

Parent and child process:-


In Unix one process can generate another process. The process which generates another process is called Parent process

The parent can have one or more children


Eg:- $ cat fruits | grep orange fruits

The shell creates two child process cat and grep simultaneously.

Process state:-

Process state diagram

The main five-state model of any operating system are:-

New : The process is created.

Running: The process is being executed.

Waiting : The process is waiting for some required resources like input and output devices

Ready : The process is waiting to be allocated to a processor. The process comes to this state immediately after creation.

Terminated: A process terminates (exited) after finishing its execution.

Unix process state ( system process ) :-


In Unix there are 7 Process states same as five-state model
UNIX Process States are :-

1) Created:- Just created but not yet ready to run.

2)

i. Ready (in Memory):- Ready to run as soon as kernel schedules it.

ii. Ready (Swapped):- Ready to run, but needs to be swapped into memory.

3)

i. Asleep (in memory):- The process is blocked and waiting for an event in

memory.

ii. Asleep (swapped):-The process is swapped out and waiting for an event on the disk.

4) Running (kernel):- Executing in kernel mode.

5) Running (user):- Executing in user mode.

6) Zombie:- A zombie process in UNIX is a process that has terminated, but whose parent has not waited
for it. May be a parent process exited without waiting for it to terminate

7) Pre-empted:- is a process returning from kernel mode to user model, since it in preempted by kernel,
to schedule another process.
Unix process creation:-

★ Parent is the
orginal process.

★ new process is called child.

★ child cantain same code, same data of its parent.

★ the parent can either wait for child to complete , or continue executing in parallel with the
child.

★ child is created by system call fork( ).


★ fork( ) returns 0 ( zero ) in child process.
★ fork( ) returns PID of new child in parent process.

★ fork( ) system call is not successful, it returns -1.

★ Resource sharing: a process needs certain resource like CPU time, Memory, I/O devices etc.

★ exec( ) system call is used after fork( ), to start another different program.

★ ps command is used display a listing of currently active processes in the system.

jobs in foreground and background :-


The unix supports both multi user as well as multi processsing.
There are 3 types of processses.

1. inter-active (foreground)process:-

All the processses creted by the user using the shell and atached to the terminals are called fore
ground process.

-> when user pass a command to shell ,the shell passes ,rebuilds and sends it to the kernal for execution.

-> duiring the execution of one process the user should wait for the kernal until compilatiton of that
process.

-> no further command can run during execution of older one.

2. non-interactive(background)process:-
The process which can without using the terminal are know as background process.

-> background process take input from a file ,process them without holding up the terminal and write
output on other file.

-> these commands are ends with '&' sign .

i.e. $sort -o std.sort std.sort&

-> for ex:- sorting and searching of files/content from long files.

limitatitons:-

-> background process don't report their successful or unsuccessful executiton .

-> pid is used to find execution state .

-> too many background processes can effect system effeciency .

-> nohup (no hang up) which avoids deadlocking of ome background process during unusual logouts.

runaway process :- when background process (using & at the end) and logout without closing
or killing the process .such a processs is called runaway process.

#chnanging process priority with nice command


Nice command :- It is used to change or set the priority of a process

syntax: $nice -value cat filename

 The default priority of a process in unix is 20

 the value range from 0 to 39, in linux -9 to 20 .where 0 is high and 39 is lower value.

the default value of reduction is 10.


the priority of a process can be increased only by adminstrator using double minus(--). eg:- $nice --15 cat last.txt

The priority of a process can be made lower using the nice command.

for example: if a process is already running and using a lot of cpu time; then it can be reniced.

I.e. $nice cat last. txt

$nice -10 cat last. txt

$nice --15 cat last. txt

Daemon Processes:-
Daemon processes are processes that are constantly running without using associated terminal or login shell, and keeps w

The characteristic features of daemon processes are as follows:

★ They start running as soon as the system is initialized.


★ The lifetime of the daemons is as long as the system is running.
★ The daemons cannot be killed prematurely.

★ init process is one of the first programs loaded, after bootstrapping.

★ The scheduler process is used to manage and schedule other processes.

★ Process vhand, which stands for virtual memory handler, is loaded into the system to swap the active
processes between memory and disk, when they are waiting for CPU time.
★ Process bdflush is responsible for disk I/O.

Process Termination:-
There are situations when the user has to terminate a process prematurely. Several reasonS are
possible for process termination such as:

★ The terminal hangs.

★ user logs off .

★ Program execution has gone into endless loop.

★ Error and fault conditions.

★ Time limit exceeded.

★ Memory unavailable

★ I/O failure.

★ Data misuse.

★ system performance slow due to too many background processes running.

★ Operating system intervention (for example to resolve, a deadlock).When a UNIX process is


terminated normally, it

★ Close all files .

★ save usage status.

★ Makes init process the parent of live children.

★ Changes run state to zombie.

Communication commands:-
1) kill command:

Termination of a process forcibly is called killing.

 Background process can be terminated by using kill


command
 A foreground process is terminated using del key or
break key .
 PID is used to select the process.
Syntax:- $ kill PID .

★ More than one process can be killed using a single kill


command.

★A special variable $! ( That holds PID of last background


process) used to kill last background process.

★A special variable $$ ( That holds PID of current shell) used to


kill current shell.

★ $kill 0 : to terminate all process of a user.


★ $kill -9 0 : to terminate all process of a user including the login
shell.

2) mesg command:- is used to change the write permission of a user.

Syntax:- $ mesg y #grant the write permission.


$ mesg n #denise the write permission.

$ mesg #current write status.

 If user doesn't want to be disturbed, he can deny the write


permission.

 But super can send message irrespective of permission.

3) write command:- allows two way communication between two users


who are currently logged in and have given write permission.

Syntax:- $write username

 The user A can send messages to user B who is logged in.


 Then user B get message with a beep sound, then B replies.
 But both the users must be logged in.

4) finger command:- is similar to who command, it shows current


loggin details and shows asterisk symbol for those who have
permission to accept messages.

Syntax:- $ finger

5) wall command:- wall stands for write all. Wall command is used only
by the super user to send messages to all users on the system.
 It is also known as broadcasting a message to all
users , irrespective of there permissions.

Syntax:- $ wall

★★★★★

You might also like