Module 1
Module 1
INTRODUCTION TO
OPERATING
SYSTEM
OUTLINE
What is an Operating System?
Mainframe Systems
Multiprocessor Systems
OS Components
OS Services
System calls
System programs
OS Structures
Virtual Machines.
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.
COMPONENTS OF A COMPUTER
SYSTEM
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
FOUR COMPONENTS OF A COMPUTER
SYSTEM
VIEWS OF OS
User View:
❖ Single user PC- ease of use, performance
❖ Mainframe or Minicomputer and Workstation- resource utilization
❖ Embedded computers- run without user intervention
System View:
OS is a resource allocator
⚫ Manages all resources
⚫ Decides between conflicting requests for efficient and fair resource use
OS is a control program
⚫ Controls execution of programs to prevent errors and improper use of the
computer
Operating System Goals
⚫ Make the computer system convenient to use.
⚫ efficient operation of the computer system.
⚫ Execute user programs and make solving user problems
easier.
⚫ Use the computer hardware in an efficient manner
MAINFRAME SYSTEMS
Evolved from simple batch systems(computer runs one -and only
one-application) to time-shared systems( allow for user interaction
with the computer system).
1. Simple Batch Systems
Introduced to improve the utilization of computer systems.
Reduce setup time by batching similar jobs
Automatic job sequencing – automatically transfers control from one
job to another.
Resident monitor
⚫ initial control in monitor
⚫ control transfers to job
⚫ when job completes control transfers back to monitor
⚫ Advantage: monitor automates the execution of multiple jobs thus
much time is saved by avoiding manual operations.
⚫ Disadvantage: CPU is often idle
MEMORY LAYOUT FOR A SIMPLE BATCH SYSTEM
2. Multiprogrammed batch systems
Even with the automatic job processing by a monitor, the
processor is still often idle.
single user cannot keep either the CPU or the I/0 devices busy at
all times
Solution: multiprogramming or multitasking(runs multiple
programs concurrently).
Advantage: Efficient utilization of processor
Problem: To run multiple programs concurrently, some form of
scheduling is needed to obtain better performance.
Does not provide for user interaction with the computer
MULTIPROGRAMMED BATCH SYSTEMS
Several jobs are kept in main memory at the same time, and the
CPU is multiplexed among them- job pool.
3. Time Sharing Systems
CPU executes multiple jobs by switching among them, and
switches occur so frequently that the users can interact with each
program while it is running.
provides direct communication between the user and the system
allows many users to share the computer simultaneously
provide a mechanism for concurrent execution
Disadvantages: more complex than multiprogrammed operating
systems
difficult and expensive to build
system must have memory management and protection
COMPUTER-SYSTEM ARCHITECTURE
1. Process Management
2. Main Memory Management
3. File Management
4. I/O System Management
5. Secondary Management
6. Networking
7. Protection System
8. Command-Interpreter System
PROCESS MANAGEMENT
A process is a program in execution. Program is a passive
entity, process is an active entity.
Process needs resources to accomplish its task
⚫ CPU, memory, I/O, files
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying
location of next instruction to execute
⚫ Process executes instructions sequentially, one at a time,
until completion
Multi-threaded process has one program counter per thread
PROCESS MANAGEMENT ACTIVITIES
Creating and deleting both user and system processes
Suspending and resuming processes
Providing mechanisms for process synchronization
Providing mechanisms for process communication
Providing mechanisms for deadlock handling
MEMORY MANAGEMENT
All data in memory before and after processing
Memory management determines what is in memory when
⚫ Optimizing CPU utilization and computer response to users
Memory management activities
⚫ Keeping track of which parts of memory are currently being
used and by whom
⚫ Deciding which processes and data to move into and out of
memory
⚫ Allocating and deallocating memory space as needed
STORAGE MANAGEMENT
File-System management
⚫ Files usually organized into directories
⚫ Access control on most systems to determine who can
access what
⚫ OS activities include
Creating and deleting files and directories
Primitives to manipulate files and dirs
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media
MASS-STORAGE MANAGEMENT
Usually disks used to store data that does not fit in main
memory or data that must be kept for a “long” period of time.
OS activities
⚫ Free-space management
⚫ Storage allocation
⚫ Disk scheduling
Storage devices includes optical storage, magnetic tape,
magnetic disk
⚫ Varies between WORM (write-once, read-many-times)
and RW (read-write)
I/O SUBSYSTEM
I/O subsystem responsible for
⚫ Memory management of I/O including buffering, caching
and spooling (the overlapping of output of one job with
input of other jobs)
⚫ General device-driver interface
⚫ Drivers for specific hardware devices
PROTECTION AND SECURITY
Protection – any mechanism for controlling access of processes
or users to resources defined by the OS
Security – defense of the system against internal and external
attacks
⚫ including denial-of-service, worms, viruses, identity theft
Systems generally first distinguish among users, to determine
who can do what
⚫ User identities (user IDs, security IDs) include name and
associated number, one per user
⚫ Group identifier (group ID) allows set of users to be defined
and controls managed, then also associated with each
process, file
⚫ Privilege escalation allows user to change to effective ID
with more rights
COMMAND-INTERPRETER SYSTEM
One of the most important systems programs for an operating
system
interface between the user and the OS.
Some operating systems include the command interpreter in the
kernel.
Other operating systems, such as MS-DOS and UNIX, treat the
command interpreter as a special program that is running when a
job is initiated, or when a user first logs on.
The program that reads and interprets control statements is called
variously:
⚫ command-line interpreter
⚫ shell (in UNIX)
Its function is to get and execute the next command statement.
Many commands are given to the operating system by control
statements which deal with:
⚫ process creation and management
⚫ I/O handling
⚫ secondary-storage management
⚫ main-memory management
⚫ file-system access
⚫ Protection and networking
USER INTERFACE
CLI allows direct command entry
Sometimes implemented in kernel, sometimes by systems
program
Primarily fetches a command from user and executes it
Sometimes commands built-in, sometimes just names of
programs
User Operating System Interface – GUI
User-friendly desktop interface
Usually mouse, keyboard, and monitor
OPERATING SYSTEM SERVICES
Provides functions that are helpful to the user:
1. User interface - Almost all operating systems have a user interface
(UI)
Varies between Command-Line (CLI), Graphics User Interface
(GUI), Batch
2. Program execution - The system must be able to load a program
into memory and to run that program, end execution
3. I/O operations - involve a file or an I/O device.
4. File-system manipulation - programs need to read and write files
and directories, create and delete them, search them, list file
Information, permission management.
OPERATING SYSTEM SERVICES (CONT.)
5. Communications – Processes may exchange information
Communications may be via shared memory or through message
passing
6. Error detection
May occur in the CPU and memory hardware, in I/O devices, in
user program
For each type of error, OS should take the appropriate action to
ensure correct and consistent computing
Debugging facilities can greatly enhance efficient use the of
system
OPERATING SYSTEM SERVICES (CONT.)
Another set of OS functions exists for ensuring the efficient operation of
the system itself via resource sharing
1. Resource allocation - When multiple users or multiple jobs running
concurrently, resources must be allocated to each of them
2. Accounting - To keep track of which users use how much and what
kinds of computer resources.
3. Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control use of
that information, concurrent processes should not interfere with each
other
Protection involves ensuring that all access to system resources is
controlled.
Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access
attempts
SYSTEM CALLS
Provides interface between the process & the OS
● Generally available as assembly-language instructions.
system call instruction generates an interrupt and allows OS to
gain control of the processors
Mostly accessed by programs via API rather than direct system
calls.
Three most common APIs are Win32 API for Windows, POSIX
API for POSIX-based systems and Java API for JVM
SYSTEM CALL – OS RELATIONSHIP
STANDARD C LIBRARY EXAMPLE
C program invoking printf() library call, which calls write() system call
SYSTEM CALL PARAMETER PASSING
Three general methods used to pass parameters to the OS
1. Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
2. Parameters stored in a block, or table, in memory, and address of
block passed as a parameter in a register
This approach taken by Linux and Solaris
3. Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system
⚫ Block and stack methods do not limit the number or length of
parameters being passed
PARAMETER PASSING VIA TABLE
TYPES OF SYSTEM CALLS
1. Process control
2. File management
3. Device management
4. Information maintenance
5. Communications
PROCESS CONTROL
end, abort
load, execute
create process, terminate process
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
A running program needs to be able to halt its execution either
normally (end) or abnormally (abort).
Under either normal or abnormal circumstances, the OS must
transfer control to the command interpreter.
The MS-DOS operating system is an example of a single-tasking
system, which has a command interpreter that is invoked when
the computer is started.
UNIX is a multitasking system, the command interpreter may
continue running while another program is executed
To start a new process, the shell executes a fork system call.
Then, the selected program is loaded into memory via an exec
system call, and the program is then executed.
MS-DOS EXECUTION