OS & UNIX of Computer Program

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Operating System

&
UNIX
What is Operating System..??
• The operating system (OS) is the program which starts up when you turn on your
computer and runs underneath all other programs - without it nothing would
happen at all.

• In simple terms, an operating system is a manager. It manages all the available


resources on a computer, from the CPU, to memory, to hard disk accesses.

• Tasks the operating system must perform:


– Control Hardware
– Run Applications
– Manage Data and Files
– Security
What is an Operating System?

 A program that acts as an intermediary between a user of a


computer and the computer hardware
 Operating system goals:
• Execute user programs and make solving user problems
easier
• Make the computer system convenient to use
• Use the computer hardware in an efficient manner

Operating System Concepts – 10th Edition 1.3 Silberschatz, Galvin and Gagne ©2018
OS Model

Operating System Concepts – 10th Edition 1.4 Silberschatz, Galvin and Gagne ©2018
Computer System Structure

 Computer system can be divided into four components:


• Hardware – provides basic computing resources
 CPU, memory, I/O devices
• Operating system
 Controls and coordinates use of hardware among various
applications and users
• Application programs – define the ways in which the system
resources are used to solve the computing problems of the users
 Word processors, compilers, web browsers, database systems,
video games
• Users
 People, machines, other computers

Operating System Concepts – 10th Edition 1.5 Silberschatz, Galvin and Gagne ©2018
Abstract View of Components of Computer

Operating System Concepts – 10th Edition 1.6 Silberschatz, Galvin and Gagne ©2018
Different Operating

System…
Windows
• Mac
• Unix
• Linux
• Android
UNIX

History…
The UNIX operating system was born in the late 1960s. It originally began
as a one man project led by Ken Thompson of Bell Labs, and has since
grown to become the most widely used operating system.

• In the time since UNIX was first developed, it has gone through many
different generations and even mutations.
– Some differ substantially from the original version, like Berkeley Software
Distribution (BSD) or Linux.
– Others, still contain major portions that are based on the original source
code.
Structure of Unix
General Characteristics of UNIX as an
Operating System (OS)
• Multi-user & Multi-tasking - most versions of UNIX are capable of
allowing multiple users to log onto the system, and have each run multiple
tasks. This is standard for most modern OSs.

• Over 30 Years Old - UNIX is over 30 years old and it's popularity and use is
still high. Over these years, many variations have spawned off and many
have died off, but most modern UNIX systems can be traced back to the
original versions. It has endured the test of time. For reference, Windows
at best is half as old (Windows 1.0 was released in the mid 80s, but it was
not stable or very complete until the 3.x family, which was released in the
early 90s).
General Characteristics of UNIX as an
Operating System (OS)
• Large Number of Applications – there are an enormous amount of
applications available for UNIX operating systems. They range from
commercial applications such as CAD, Maya, WordPerfect, to many free
applications.

• Free Applications and Even a Free Operating System - of all of the


applications available under UNIX, many of them are free. The compilers
and interpreters that we use in most of the programming courses at
UMBC can be downloaded free of charge. Most of the development that
we do in programming courses is done under the Linux OS.
General Characteristics of UNIX as an
Operating System (OS)
• Less Resource Intensive - in general, most UNIX installations tend to be
much less demanding on system resources. In many cases, the old family
computer that can barely run Windows is more than sufficient to run the
latest version of Linux.

• Internet Development - Much of the backbone of the Internet is run by


UNIX servers. Many of the more general web servers run UNIX with the
Apache web server - another free application
Flavors of UNIX
• AIX - developed by IBM for use on its mainframe computers
• BSD/OS - developed by Wind River for Intel processors
• HP-UX - developed by Hewlett-Packard for its HP 9000 series of business
servers
• IRIX - developed by SGI for applications that use 3-D visualization and
virtual reality
• QNX - a real time operating system developed by QNX Software
Systems primarily for use in embedded systems
• Solaris - developed by Sun Microsystems for the SPARC platform and the
most widely used proprietary flavor for web servers
• Tru64 - developed by Compaq for the Alpha processor
UNIX Interfaces
Graphical User Interfaces (GUIs)
• When you logon locally, you are presented with graphical environment.

• You start at a graphical login screen. You must enter your username and
password. You also the have the option to choose from a couple session
types. Mainly you have the choice between Gnome and KDE.

• Once you enter in your username and password, you are then presented
with a graphical environment that looks like one of the following...
UNIX Interfaces
Command Line Interface
• You also have access to some UNIX servers as well.
– You can logon from virtually any computer that has internet access
whether it is Windows, Mac, or UNIX itself.
• In this case you are communicating through a local terminal to one of
these remote servers.
– All of the commands actually execute on the remote server.
– It is also possible to open up graphical applications through this
window, but that requires a good bit more setup and software.
Process Management
• Operating system functions executes within user process.

• 2 modes of execution
– User mode
– Kernel mode

• 2 types of processes are available


– System processes (Execute OS code)
– User processes (Execute user program code)

• System call is used to transfer form user mode to system mode.


Process State in UNIX
• User running Execute in use
mode

• Kernel running Execute in kernel


• Ready
mode to run in memory ready to run as soon as the kernel
schedules it

• Asleep in memory unable to execute until event occurs.

• Ready to run, swapped process is ready to run, but the


swapper must swap process into main
memory before kernel can schedule it
to execute.
Process State in UNIX
a process is awaiting an event and has
• Sleeping , swapped
been swapped to secondary storage.

process is returning from kernel to user


• Preempted
mode, but the kernel preempts it and
a process switch to schedule another
does
process
process is newly created and not yet
• Created
run.

• Zombie
process no longer exists, but it leaves a
record from its parent process to collect.
Process Scheduling Queues
• Job queue
• Ready queue
• Device queues.
Types of Processes in UNIX
Mainly 3 types
– User process
– Daemon process
– Kernel process

 Daemon process
• Performs the function in a system wide basis. The function can be of any auxiliary
kind but they are vital in controlling the computational environment of the system.
• Example Print spooling, Network Management.
• Once created Daemon process can exist throughout the life time of the Operating
System.
System calls in UNIX
• Fork(): -This system call create new process.

• Exec(): -This system call used after a fork to replace the process memory
space with a new program.

• Wait():-This system call moves a process off the ready queue until the
termination of the child.
Interesting signals in UNIX
 SIGCHLD Child process died or suspended
 SIGFPE Arithmetic fault
 SIGILL Illegal instruction
 SIGINT tty interrupt (Control C) Kill
 SIGKILL process Segmentation fault
 SIGSEGV Invalid System call Exceeds
 SIGSYS CPU limit Exceeds file size
 SIGXCPU limit
 SIGXFSZ
Memory
• Primary memory is a precious resource that frequently cannot
contain all active processes in the system

• The memory management system decides which processes


should reside (at least partially) in main memory

• It monitors the amount of available primary memory and may


periodically write processes to a secondary device called the
swap device to provide more space in primary memory

• At a later time, the kernel reads the data from swap device
back to main memory
UNIX Memory Management Policies

• Swapping
– Easy to implement
– Less system overhead

• Demand Paging
– Greater flexibility
Swapping
• The swap device is a block device in a configurable section of a disk

• Kernel allocates contiguous space on the swap device without


fragmentation

• It maintains free space of the swap device in an in-core table, called


map

• The kernel treats each unit of the swap map as group of disk blocks

• As kernel allocates and frees resources, it updates the map accordingly


Swapping Process Out
• The kernel must gather the page addresses of data at primary memory to
be swapped out

• Kernel copies the physical memory assigned to a process to the allocated


space on the swap device

• The mapping between physical memory and swap device is kept in page
table entry
Demand Paging
• Not all page of process resides in memory Locality

• When a process accesses a page that is not part of its working set, it incurs
a page fault.

• The kernel suspends the execution of the process until it reads the page
into memory and makes it accessible to the process
Data Structure for Demand Paging
• Page table entry

• Disk block descriptors

• Page frame data table

• Swap use table


File Management in UNIX
In UNIX there are three basic types of files:
• Ordinary Files: An ordinary file is a file on the system that contains
data, text, or program instructions. In this tutorial, you look at working
with ordinary files.
• Directories: Directories store both special and ordinary files. For users
familiar with Windows or Mac OS, UNIX directories are equivalent to
folders.
• Special Files: Some special files provide access to hardware such as hard
drives, CD-ROM drives, modems, and Ethernet adapters. Other special
files are similar to aliases or shortcuts and enable you to access a single
file using different names.
File Management in UNIX
File Access Modes:
 Read: Grants the capability to read ie. view the contents of
the file.

 Write:Grants the capability to modify, or remove the content


of the file.

 Execute:User with execute permissions can run a file as a


program.
File Management in UNIX
Directory Access Modes:
 Read: Access to a directory means that the user can
read the contents. The user can look at the filenames
inside the directory.
 Write: Access means that the user can add or delete
files to the contents of the directory.
 Execute: Executing a directory doesn't really make a lot
of sense so think of this as a traverse permission.
A user must have execute access to the bin directory in
order to execute or command.
File Management in UNIX
Starting a Process:
• Foreground Processes:
o By default, every process that you start runs in the foreground. It gets its
input from the keyboard and sends its output to the screen.
• Background Processes:
o A background process runs without being connected to your keyboard.
If the background process requires any keyboard input, it waits.
o The advantage of running a process in the background is that you can run
other commands; you do not have to wait until it completes to start
another!
File Management in UNIX
Stopping Processes:
• Ending a process can be done in several different ways. Often, from a
console-based command, sending a CTRL + C keystroke (the default
interrupt character) will exit the command. This works when process is
running in foreground mode.
• If a process is running in background mode then first you would need to
get its Job ID using ps command and after that you can use kill command
to kill the process.
UNIX Security
• Common Sense Security
• File Permissions
• Login daemons
• Non-login daemons
• Stack Smashing
• Safe Scripts
Benefits of UNIX
Benefits in different ways %
Flexibility 70%
Freedom to choose IT from different vendors 67%
Products from different vendors work together 66%
Access across multi-vendor environments 65%
Protect investment in existing computer systems 61%
Ability to use/share information anywhere in the world 59%
Cost savings 54%
Interoperability/portability across various platforms 54%
Organizational change not constrained by IT system 49%
Cost of ownership 49%
In

Summary…
When the history of the information age is written, the
extraordinary dynamics of the UNIX system marketplace will be
seen as playing an important role. The UNIX system was
developed at just the right time and place to be the critical
enabler for a revolution in information technology. Client/server
architectures, the Internet, object databases, heterogeneous
transaction processing, and Web computing all emerged on the
shoulders of the UNIX system.

You might also like