1
Mary Margarat Valentine
Chapter : 1
Overview
of
OPERATING SYSTEMS
2
Introduction:
 Operating System Structure and operations,
 Process management,
 Memory management,
 storage management,
 Protection and security,
 Distributed and special purpose Systems;
What Is In This Chapter?
3
System Structure:
 Operating system services and interface,
 System calls and its types,
 System programs,
 Operating System Design and implementation,
 OS structure,
 Virtual machines,
 OS debugging and generation,
 System boot.
What Is In This Chapter?
Introduction
• A computer is a system composed of two
major components: hardware and software.
4
• Software is a collection of computer programs and related
data that provides the instructions for telling a computer
what to do and how to do it.
• Computer software can be broadly classified into two
categories :
(a) System software
(b) Application software
5
Software
• System software is a collection of programs, mainly used
to manage the hardware resources of a computer.
• Programs that interfaces with the hardware
Categories of system software :
Programming in C 6
SYSTEM SOFTWARE
• Application software is written to enable the computer
to solve a specific data processing task.
• Categories of application software :
7
APPLICATION SOFTWARE
What is an Operating System?
 An Operating system (OS) is a software
which acts as an interface between the end
user and computer hardware.
 Every computer must have at least one OS to
run other programs.
 An application like Chrome, MS Word,
Games, etc needs some environment in
which it will run and perform its task.
8
What is an Operating System?
 The OS helps you to communicate with the
computer without knowing how to speak the
computer's language.
 It is not possible for the user to use any
computer or mobile device without having an
operating system.
9
10
11
PROCESS MANAGEMENT
 A process is a program in execution: (A program is
passive, a process active.)
 A process needs certain resources, including CPU time,
memory, files, and I/O devices, to accomplish its task and
attributes that must be managed.
Management of processes includes:
 Process Scheduling (priority, time management, . . . )
 Creation/termination
 Block/Unblock (suspension/resumption )
 Synchronization
 Communication
 Deadlock handling
 Debugging
12
Processes and programs
The difference between a process and a program:
 Test :
o Term Test = Program
o Student = Processor
o Question paper = input data
o writing an exam= Process
o Marks = Output
13
 Allocation/de-allocation for processes, files, I/O.
 Maintenance of several processes at a time
 Keep track of who's using what memory
 Movement of process memory to/from
secondary storage.
MAIN MEMORY MANAGEMENT
• A file is a collection of related information defined by its
creator.
• Commonly, files represent programs (both source and object
forms) and data.
• The operating system is responsible for the following
activities in connections with file management:
• File creation and deletion.
• Directory creation and deletion.
• Support of primitives for manipulating files and directories.
• Mapping files onto secondary storage.
• File backup on stable (nonvolatile) storage media.
FILE MANAGEMENT
Disks, tapes, optical, ...
Free space management ( paging/swapping )
Storage allocation ( what data goes where on disk )
Disk scheduling
SECONDARY STORAGE MANAGEMENT
Types of Operating Systems
• Batch processing Operating Systems
• Multi tasking Operating Systems
• Multi programming or Time-sharing OS
• Distributed operating System
• Network operating System
• Real Time operating System
• Hard real-time systems
• Soft real-time systems 17
BATCH OPERATING SYSTEM
• The users of a batch operating system do not
interact with the computer directly.
• Each user prepares his job on an off-line device
like punch cards and submits it to the computer
operator.
• To speed up processing, jobs with similar needs
are batched together and run as a group.
• The programmers leave their programs with the
operator and the operator then sorts the programs
with similar requirements into batches. 18
19
20
BATCH OPERATING SYSTEM
• The problems with Batch Systems are as
follows
 Lack of interaction between the user and the job.
 CPU is often idle, because the speed of the
mechanical I/O devices is slower than the CPU.
 Difficult to provide the desired priority.
21
Multi tasking Operating Systems
• Multitasking, in an operating system, is
allowing a user to perform more than one
computer task at a time.
• Each task consumes system storage and
other resources.
• As more tasks are started, the system may
slow down or begin to run out of shared
storage.
22
Multi programming / Time-sharing OS
• Multiple programs executed at the same time.
• The main idea of multi programming is to
maximize the CPU time.
23
Distributed operating System
• Distributed systems use multiple central
processors to serve multiple real-time
applications and multiple users.
• Data processing jobs are distributed among
the processors accordingly.
• Processors in a distributed system may vary in
size and function. These processors are
referred as sites, nodes, computers, and so
on. 24
Network operating System
• A Network Operating System runs on a server
and provides the server the capability to
manage data, users, groups, security,
applications, and other networking functions.
• The primary purpose of the network operating
system is to allow shared file and printer
access among multiple computers in a
network, typically a local area network (LAN),
a private network or to other networks. 25
Network operating System
Examples of network operating systems include
• Microsoft Windows Server 2003
• Microsoft Windows Server 2008
• UNIX
• Linux
• Mac OS X
• Novell NetWare
• BSD 26
Real Time operating System
• Real time system means that the system is
subjected to real time, i.e., response should be
guaranteed within a specified timing constraint
or system should meet the specified deadline.
Example:
flight control system
real time monitors etc.
27
Real Time operating System
• Hard Real time system
• Soft Real time system
28
Hard Real Time operating System
• This type of system can never miss its
deadline.
• Missing the deadline may have disastrous
consequences.
• The usefulness of result produced by a hard
real time system decreases abruptly and may
become negative if tardiness increases.
Tardiness means how late a real time system
completes its task with respect to its deadline.
Example: Flight controller system 29
Soft Real Time operating System
• This type of system can miss its deadline
occasionally with some acceptably low
probability.
• Missing the deadline have no disastrous
consequences.
• The usefulness of result produced by a soft
real time system decreases gradually with
increase in tardiness.
Example: Telephone switches.
30
Operating System Services
• An Operating System provides services to both the users
and to the programs.
• Following are a few common services provided by an OS:
 File System management
 Communication
 Program execution
 Error Detection
 I/O operations
 Resource Allocation
 Security and Protection
31
File System Management
• OS programs needs to read a file or write a file
• OS controls the permission of a given file.
• creating, deleting and editing of files.
• Management of directories
32
Program Execution
• OS provides an environment to the users to
execute the programs
• Thus user does not have to be concerned with
the memory allocation process.
33
Communication
• Process needs to swap over information with
other process.
• Processes executing on same computer
system or on different computer systems can
communicate using operating system support.
• Communication between two processes can
be done using shared memory or via message
passing.
34
Error Detection
• Errors may occur within CPU, memory
hardware, I/O devices and in the user
program.
• For each type of error, the OS takes adequate
action for ensuring correct and consistent
computing
35
I/O Operations
• Each program requires an input and
produces an output. This involves the use of
I/O devices.
• The OS hides the user the details of
underlying hardware for the I/O.
• For efficiency and protection, users cannot
directly govern the I/O devices.
• So, the OS provide a means to do I/O Input /
Output operation which means read or write
operation with any file. 36
Accounting
• This service of the operating system keeps
track of which users are using how much and
what kinds of computer resources have been
used for accounting or simply to accumulate
usage statistics.
37
Protection and Security
• Protection includes in ensuring all access to
system resources in a controlled manner.
• For making a system secure, the user needs
to authenticate him or her to the system before
using (usually via login ID and password).
38
Two modes of operation
• User mode
• Kernel mode
39
Modes supported by the operating system
40
Kernel Mode
 When CPU is in kernel mode, the code being executed can
access any memory address and any hardware resource.
 Hence kernel mode is a very privileged and powerful mode.
 If a program crashes in kernel mode, the entire system will be
halted.
User Mode
 When CPU is in user mode, the programs don't have direct
access to memory and hardware resources.
 In user mode, if any program crashes, only that particular
program is halted.
 That means the system will be in a safe state even if a program
in user mode crashes.
 Hence, most programs in an OS run in user mode.
System Call
• When a program in user mode requires access to
RAM or a hardware resource, it must ask the
kernel to provide access to that resource. This is
done via something called a system call.
• When a program makes a system call, the mode is
switched from user mode to kernel mode. This is
called a context switch.
41
System Call
Generally, system calls are made by the user level
programs in the following situations:
 Creating, opening, closing and deleting files in
the file system.
 Creating and managing new processes.
 Creating a connection in the network, sending
and receiving packets.
 Requesting access to a hardware device, like a
mouse or a printer. 42
System Call
• A system call is the programmatic way in
which a computer program requests a
service from the kernel of the operating
system it is executed on.
• System calls are the only entry points
into the kernel system.
43
44
Services Provided by System
Calls
• Process creation and management
• Main memory management
• File Access, Directory and File system
management
• Device handling(I/O)
• Protection
• Networking, etc.
45
Types of System Calls
There are 5 different categories of system calls
• Process control
• File management
• Device management
• Information maintenance
• Communication
46
47
Fork()
• The fork() system call is used to create processes.
• When a process (a program in execution) makes a
fork() call, an exact copy of the process is created.
• Now there are two processes, one being the
parent process and the other being the child
process.
• The process which called the fork() call is the
parent process and the process which is created
newly is called the child process 48
Fork()
49
// example.c
#include <stdio.h>
void main()
{
int val;
val = fork();
printf("%d", val);
}

Introduction to Operating Systems - Mary Margarat

  • 1.
    1 Mary Margarat Valentine Chapter: 1 Overview of OPERATING SYSTEMS
  • 2.
    2 Introduction:  Operating SystemStructure and operations,  Process management,  Memory management,  storage management,  Protection and security,  Distributed and special purpose Systems; What Is In This Chapter?
  • 3.
    3 System Structure:  Operatingsystem services and interface,  System calls and its types,  System programs,  Operating System Design and implementation,  OS structure,  Virtual machines,  OS debugging and generation,  System boot. What Is In This Chapter?
  • 4.
    Introduction • A computeris a system composed of two major components: hardware and software. 4
  • 5.
    • Software isa collection of computer programs and related data that provides the instructions for telling a computer what to do and how to do it. • Computer software can be broadly classified into two categories : (a) System software (b) Application software 5 Software
  • 6.
    • System softwareis a collection of programs, mainly used to manage the hardware resources of a computer. • Programs that interfaces with the hardware Categories of system software : Programming in C 6 SYSTEM SOFTWARE
  • 7.
    • Application softwareis written to enable the computer to solve a specific data processing task. • Categories of application software : 7 APPLICATION SOFTWARE
  • 8.
    What is anOperating System?  An Operating system (OS) is a software which acts as an interface between the end user and computer hardware.  Every computer must have at least one OS to run other programs.  An application like Chrome, MS Word, Games, etc needs some environment in which it will run and perform its task. 8
  • 9.
    What is anOperating System?  The OS helps you to communicate with the computer without knowing how to speak the computer's language.  It is not possible for the user to use any computer or mobile device without having an operating system. 9
  • 10.
  • 11.
    11 PROCESS MANAGEMENT  Aprocess is a program in execution: (A program is passive, a process active.)  A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task and attributes that must be managed. Management of processes includes:  Process Scheduling (priority, time management, . . . )  Creation/termination  Block/Unblock (suspension/resumption )  Synchronization  Communication  Deadlock handling  Debugging
  • 12.
    12 Processes and programs Thedifference between a process and a program:  Test : o Term Test = Program o Student = Processor o Question paper = input data o writing an exam= Process o Marks = Output
  • 13.
    13  Allocation/de-allocation forprocesses, files, I/O.  Maintenance of several processes at a time  Keep track of who's using what memory  Movement of process memory to/from secondary storage. MAIN MEMORY MANAGEMENT
  • 14.
    • A fileis a collection of related information defined by its creator. • Commonly, files represent programs (both source and object forms) and data. • The operating system is responsible for the following activities in connections with file management: • File creation and deletion. • Directory creation and deletion. • Support of primitives for manipulating files and directories. • Mapping files onto secondary storage. • File backup on stable (nonvolatile) storage media. FILE MANAGEMENT
  • 15.
    Disks, tapes, optical,... Free space management ( paging/swapping ) Storage allocation ( what data goes where on disk ) Disk scheduling SECONDARY STORAGE MANAGEMENT
  • 16.
    Types of OperatingSystems • Batch processing Operating Systems • Multi tasking Operating Systems • Multi programming or Time-sharing OS • Distributed operating System • Network operating System • Real Time operating System • Hard real-time systems • Soft real-time systems 17
  • 17.
    BATCH OPERATING SYSTEM •The users of a batch operating system do not interact with the computer directly. • Each user prepares his job on an off-line device like punch cards and submits it to the computer operator. • To speed up processing, jobs with similar needs are batched together and run as a group. • The programmers leave their programs with the operator and the operator then sorts the programs with similar requirements into batches. 18
  • 18.
  • 19.
  • 20.
    BATCH OPERATING SYSTEM •The problems with Batch Systems are as follows  Lack of interaction between the user and the job.  CPU is often idle, because the speed of the mechanical I/O devices is slower than the CPU.  Difficult to provide the desired priority. 21
  • 21.
    Multi tasking OperatingSystems • Multitasking, in an operating system, is allowing a user to perform more than one computer task at a time. • Each task consumes system storage and other resources. • As more tasks are started, the system may slow down or begin to run out of shared storage. 22
  • 22.
    Multi programming /Time-sharing OS • Multiple programs executed at the same time. • The main idea of multi programming is to maximize the CPU time. 23
  • 23.
    Distributed operating System •Distributed systems use multiple central processors to serve multiple real-time applications and multiple users. • Data processing jobs are distributed among the processors accordingly. • Processors in a distributed system may vary in size and function. These processors are referred as sites, nodes, computers, and so on. 24
  • 24.
    Network operating System •A Network Operating System runs on a server and provides the server the capability to manage data, users, groups, security, applications, and other networking functions. • The primary purpose of the network operating system is to allow shared file and printer access among multiple computers in a network, typically a local area network (LAN), a private network or to other networks. 25
  • 25.
    Network operating System Examplesof network operating systems include • Microsoft Windows Server 2003 • Microsoft Windows Server 2008 • UNIX • Linux • Mac OS X • Novell NetWare • BSD 26
  • 26.
    Real Time operatingSystem • Real time system means that the system is subjected to real time, i.e., response should be guaranteed within a specified timing constraint or system should meet the specified deadline. Example: flight control system real time monitors etc. 27
  • 27.
    Real Time operatingSystem • Hard Real time system • Soft Real time system 28
  • 28.
    Hard Real Timeoperating System • This type of system can never miss its deadline. • Missing the deadline may have disastrous consequences. • The usefulness of result produced by a hard real time system decreases abruptly and may become negative if tardiness increases. Tardiness means how late a real time system completes its task with respect to its deadline. Example: Flight controller system 29
  • 29.
    Soft Real Timeoperating System • This type of system can miss its deadline occasionally with some acceptably low probability. • Missing the deadline have no disastrous consequences. • The usefulness of result produced by a soft real time system decreases gradually with increase in tardiness. Example: Telephone switches. 30
  • 30.
    Operating System Services •An Operating System provides services to both the users and to the programs. • Following are a few common services provided by an OS:  File System management  Communication  Program execution  Error Detection  I/O operations  Resource Allocation  Security and Protection 31
  • 31.
    File System Management •OS programs needs to read a file or write a file • OS controls the permission of a given file. • creating, deleting and editing of files. • Management of directories 32
  • 32.
    Program Execution • OSprovides an environment to the users to execute the programs • Thus user does not have to be concerned with the memory allocation process. 33
  • 33.
    Communication • Process needsto swap over information with other process. • Processes executing on same computer system or on different computer systems can communicate using operating system support. • Communication between two processes can be done using shared memory or via message passing. 34
  • 34.
    Error Detection • Errorsmay occur within CPU, memory hardware, I/O devices and in the user program. • For each type of error, the OS takes adequate action for ensuring correct and consistent computing 35
  • 35.
    I/O Operations • Eachprogram requires an input and produces an output. This involves the use of I/O devices. • The OS hides the user the details of underlying hardware for the I/O. • For efficiency and protection, users cannot directly govern the I/O devices. • So, the OS provide a means to do I/O Input / Output operation which means read or write operation with any file. 36
  • 36.
    Accounting • This serviceof the operating system keeps track of which users are using how much and what kinds of computer resources have been used for accounting or simply to accumulate usage statistics. 37
  • 37.
    Protection and Security •Protection includes in ensuring all access to system resources in a controlled manner. • For making a system secure, the user needs to authenticate him or her to the system before using (usually via login ID and password). 38
  • 38.
    Two modes ofoperation • User mode • Kernel mode 39 Modes supported by the operating system
  • 39.
    40 Kernel Mode  WhenCPU is in kernel mode, the code being executed can access any memory address and any hardware resource.  Hence kernel mode is a very privileged and powerful mode.  If a program crashes in kernel mode, the entire system will be halted. User Mode  When CPU is in user mode, the programs don't have direct access to memory and hardware resources.  In user mode, if any program crashes, only that particular program is halted.  That means the system will be in a safe state even if a program in user mode crashes.  Hence, most programs in an OS run in user mode.
  • 40.
    System Call • Whena program in user mode requires access to RAM or a hardware resource, it must ask the kernel to provide access to that resource. This is done via something called a system call. • When a program makes a system call, the mode is switched from user mode to kernel mode. This is called a context switch. 41
  • 41.
    System Call Generally, systemcalls are made by the user level programs in the following situations:  Creating, opening, closing and deleting files in the file system.  Creating and managing new processes.  Creating a connection in the network, sending and receiving packets.  Requesting access to a hardware device, like a mouse or a printer. 42
  • 42.
    System Call • Asystem call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. • System calls are the only entry points into the kernel system. 43
  • 43.
  • 44.
    Services Provided bySystem Calls • Process creation and management • Main memory management • File Access, Directory and File system management • Device handling(I/O) • Protection • Networking, etc. 45
  • 45.
    Types of SystemCalls There are 5 different categories of system calls • Process control • File management • Device management • Information maintenance • Communication 46
  • 46.
  • 47.
    Fork() • The fork()system call is used to create processes. • When a process (a program in execution) makes a fork() call, an exact copy of the process is created. • Now there are two processes, one being the parent process and the other being the child process. • The process which called the fork() call is the parent process and the process which is created newly is called the child process 48
  • 48.
    Fork() 49 // example.c #include <stdio.h> voidmain() { int val; val = fork(); printf("%d", val); }