[go: up one dir, main page]

0% found this document useful (0 votes)
39 views72 pages

Unit 1

The document provides information about operating systems and the services they provide. It discusses topics like process management, threads, computer hardware architecture, software types including application software, system software and utility software. It describes the main functions of an operating system as resource management and virtual machine management. It also lists and explains the various services provided by operating systems like user interface, program execution, input/output operations, file system manipulation, communication, error detection, resource allocation, accounting and security/protection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views72 pages

Unit 1

The document provides information about operating systems and the services they provide. It discusses topics like process management, threads, computer hardware architecture, software types including application software, system software and utility software. It describes the main functions of an operating system as resource management and virtual machine management. It also lists and explains the various services provided by operating systems like user interface, program execution, input/output operations, file system manipulation, communication, error detection, resource allocation, accounting and security/protection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

DEPARTMENT OF COMPUTER TECHNOLOGY

IV-SEMESTER
OPERATING SYSTEMS

UNIT1
Syllabus
• Introduction,

• services provided by OS,

• system calls.

• Process Management- Introduction, process

control block (PCB), process states, process


context switch.
• Threads : user level and kernel level

DTEL 2
Computer Hardware Architecture

DTEL 3
Computer Software Types

DTEL 4
• Introduction,
• Software is a set of instructions, data or
programs used to operate computers and
execute specific tasks.
• Software is a general term used to refer to
applications, scripts and programs that run on
a device.
In computer programming, a script is a program
or sequence of instructions that is
interpreted...

DTEL 5
• The two main categories of software are
• Application software
• System software and
• Utility software.
• An Application software is a software that
fulfills a specific need or that performs a specific
function for a user.

• Examples. office suites, graphics software, databases and


database management programs, web browsers, word
processors, software development tools( GitHub,
performance analysis tools etc) image editors and
communication platforms.

DTEL 6
• System software:-
• These software programs are designed to run a
computer's application programs and hardware.

• It coordinates the activities and functions of the


hardware and software,
• it controls the operations of the computer
hardware and provides an environment or
platform for all the other types of software to
work in. ( firmware, computer language translators
and system utilities, Driver software etc..

DTEL 7
• The OS is the best example of system
software;

• It manages all the other computer programs.


• Other example includes the firmware,
computer language translators
(compilers. interpreters. assemblers )

DTEL 8
Utility software :
• Utility software is part of the system
software and performs specific tasks to
keep the computer running. Utility software
is always running in the background.
• Examples are: security (antivirus software) and

optimization programs.(include tools for system


clean-up, disk defragmentation, and file compression. )

DTEL 9
DTEL 10
• Main difference between SS & AS
• System s/w are designed to manage
system based resources and
operations and acts as an interface
between application s/w and computer
hardware.
• While application s/w are
designed to help users perform
specific tasks. It provides an
interface between the user and the
DTEL 11
DTEL 12
INTRODUCTION TO OS OPERATING SYSTEM
Definition:
An operating system is a set of programs
that enables a user to operate and interact
with a computer. The operating system is a
crucial component of the system software in
a computer system.

“It acts as an intermediary between a user


of computer and the computer hardware”
Examples: Windows, Linux, Unix and Mac OS, etc

DTEL 13
INTRODUCTION TO OS

Operating system Goals:

• Execute user programs and make solving


user problems easier.(ability)
• Make the computer system convenient to
use.(convenience)
• Use the computer hardware in an efficient
manner(efficiency)

DTEL 14
INTRODUCTION TO OS

Types of Operating Systems:


Four types based on their controlling and
supporting systems

• Real Time Operating System (RTOS)


• Single User Single Task OS
• Single User Multi Tasking OS
• Multi User OS

https://www.toppr.com/guides/computer-science/computer-fundamentals/operating-
system/

DTEL 15
OPERATING SYSTEM

An operating system is a layer of software on a


bare hardware machine that performs
Two main functions:
Resource Management
Virtual Machine Management(User friendliness)
• Resource Management:
Time Management(CPU, DISK scheduling)
Space Management(MM &SEC MEM)
Process Synchronization and Deadlock Handling
Accounting & Status Information
https://www.geeksforgeeks.org/cpu-scheduling-in-operating-systems/

DTEL 16
OPERATING SYSTEM

Time Management (CPU, DISK scheduling)


The purpose of CPU Scheduling is to make the
system more efficient, faster i.e scheduling of
process is done.

Disk scheduling is done by operating systems to


schedule I/O requests arriving for the disk.
Disk scheduling is also known as I/O scheduling
It is used to manage input and output requests to the
disk.

Space Management(MM &SEC MEM)


It optimizes the use of various storage devices.
DTEL 17
OPERATING SYSTEM

Process Synchronization and Deadlock Handling:


Process Synchronization is the task of coordinating the
execution of processes in a way that no two processes
can have access to the same shared resources and
data .
A deadlock is a condition that may happen in a system
composed of multiple processes that can access
shared resources. A deadlock is said to occur when two or
more processes are waiting for each other to release a
resource. None of the processes can make any progress.
Deadlock Handling :The deadlock avoidance
approach handles deadlocks before they occur.

DTEL 18
OPERATING SYSTEM

Accounting & Status Information:


This includes the amount of CPU used for process
execution, time limits, execution ID etc

Status information:
This includes a list of I/O devices allocated to the
process.

DTEL 19
OPERATING SYSTEM

Virtual Machine Management :


The users of the virtual machine have the illusion that
each one of them is the sole user of the machine, even
though the machine may be operating in a multiuser
environment
Execution Environment:
It includes process creation, management, control,
termination, file manipulation, interrupt handling,
support for I/O operation, language support.
Error detection and handling
Protection and security

DTEL 20
Abstract View of System Components

DTEL 21
Operating Systems Services
Services Provided by the Operating System :
An Operating System provides services to both the users
and to the programs.
1. User Interface
2. Program execution
3. Input / Output operations
4. File-system manipulation
5. Communication system
6. Error detection
7. Resource allocation
8. Accounting
9. Security and Protection
DTEL https://www.w3schools.in/operating-system/services 22
Operating Systems Services
1. User Interface :
Depending on the interface their types have been further
subdivided. These are:
• Command line interface
• Graphical User Interface

2. Program execution :
The operating system must have the capability to load a program into
memory and execute that program. Furthermore, the program must
be able to end its execution, either normally or abnormally /
forcefully.
3. Input / Output operations :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.
DTEL 23
Operating Systems Services

4. File-system manipulation –
program capability to read, write, create, and delete
files.
5. Communications – exchange of information between
processes executing either on the same computer or on different
systems can communicate using operating system support.
Communication between two processes can be done using shared
memory or message passing
6. Error detection – ensure correct computing by detecting
errors in the CPU (such as power failure) and memory hardware, in
I/O devices (such as connection failure), or in user programs. OS
must take appropriate action to ensure correct consistent
computing

DTEL 24
7. Resource allocation: When there are multiple users
or multiple jobs running at the same time, resources must be
allocated to each of them.
eg. CPU cycle, MM(main memory storage), I/O devices
etc.
8. Accounting: accumulating usage statistics (keeps
track of which users are using how much and what kinds of
computer resources have been used for accounting )

9.Protection & 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).

DTEL 25
Common System Components(Functions)

FUNCTIONS of OS :
1. Process Management
2. Main Memory Management
3. File Management
4. I/O System Management
5. Secondary Storage Management
6. Networking Management
7. Protection System Management
8. Command-Interpreter System Management

DTEL 26
PROCESS
• A process is a program in execution.
• A process needs certain resources, including CPU
time, memory, files, and I/O devices, to
accomplish its task.
• Processes can create sub-processes to execute
concurrently.
• A program by itself is not a process; a program is
a passive entity, whereas a process is an active
entity.

DTEL 27
Process management
• The operating system assign processors to the different
tasks that must be performed by computer system..
– Process creation and deletion.
– Process suspension - to temporarily stop the process
(Block_Suspend, Ready_Suspend) and resumption(wait
state-ready state).to restart it again.
– Provision of mechanisms for:
1)process synchronization(ref slide-18)
2)process communication(mechanism which allows the exchange of data
between processes )
– Deadlock handling(ref slide-18)
-- Process termination
DTEL 28
Main-Memory Management
• Memory is a large array of words or bytes, each with its
own address. It is a repository (storage) of quickly
accessible data shared by the CPU and I/O devices.
• Main memory is a volatile storage device. It loses its
contents in the case of system failure.
• The operating system is responsible for the following
activities in connections with memory management:
– Keep track of which parts of memory are currently
being used and by whom.
– Decide which processes to load when memory space
becomes available.
– Allocate and deallocate memory space as needed.
DTEL 29
File Management
• A file is a collection of related information defined by its creator..
• A file consists of a sequence of bits, bytes, lines, or records whose
meanings are defined by their creators.
• The operating system is responsible for the following activities in
connections with file management:
– File creation and deletion.
– Directory creation and deletion
– *Mapping files onto secondary storage.
– File and Directory manipulation
- Organization storage,retrieval,naming,sharing and protection of files.
* File mapping is the process of mapping the disk sectors of a file into the virtual memory
space of a process
A file system is a method an operating system uses to store, organize, and manage files and
directories on a storage device.

DTEL 30
I/O System Management
• Operating System is to manage various I/O devices including
mouse, keyboards, touch pad, disk drives, display adapter
• The I/O management subsystem controls all the input and
output of the computer system.
• OS has a set of device drivers(s/w routines)
• The I/O system consists of:
– A buffer-caching system
– * A general device-driver interface
– Drivers for specific hardware devices
•The O.S. hides the peculiarities of specific hardware devices from
the user
* A device driver is a special kind of software program that controls
a specific hardware device attached to a computer.

DTEL 31
Secondary-Storage Management

• Since main memory (primary storage) is volatile and too


small to accommodate all data and programs
permanently, the computer system must provide
secondary storage to back up main memory.
• Most modern computer systems use disks as the
principle on-line storage medium, for both programs
and data.
• The operating system is responsible for the following
activities in connection with disk management:
– Free space management
– Storage allocation
– *Disk scheduling *(to schedule I/O requests arriving for the disk)
Scheduling means to Execute all the Processes those are given to a CPU at a Time.
DTEL 32
Network Management
• A distributed system is a collection of processors that
do not share memory or a clock. Each processor has its
own local memory and clock.
• Network management is the process of
administering and managing computer networks.

• The processors in the system are connected through a


communication network.

• A distributed system provides user access to various


system resources

DTEL 33
Protection System
• System protection refers to the mechanism for
controlling the access to computer resources
• For e.g. memory- addressing hardware ensures that a
process can execute only with its own address space

DTEL 34
Command-Interpreter System
• Command-Interpreter system is a system program,
which is the interface between the user and the
operating system.
• Command-Interpreter system is known as the shell.
• Two ways in which one can interact with os
1. System Commands
2. System Calls

(Kernel : interface between Applications and the operating


systems)
(System calls : interface between s/w applications
and kernel.)
DTEL 35
Command-Interpreter System
• (Kernel :
interface between Applications and the operating systems
Applications

• an operating system is a system software that acts as Kernel


the interface between the users and the machine
operating
systems
• a kernel is a part of the operating system that converts
user commands into machine language

Applications

System calls

• (System calls : Kernel


interface between s/w applications and kernel.)

DTEL 36
System Calls
• A system call is a request for the kernel to access a resource.
• System calls provide the interface between user (s/w) applications
and the kernel of operating system. OR It provides interface to the
services made available by an operating system.

• Generally available as assembly-language instructions.


• Languages defined to replace assembly language for systems
programming allow system calls to be made directly (e.g., C, C++)

• Three general methods are used to pass parameters between a


running program and the operating system.

1. Pass parameters in registers.

2. Store the parameters in a table in memory, and the table address is


passed as a parameter in a register.

3. Push (store) the parameters onto the stack by the program, and pop
off the stack by operating system.

DTEL 37
Passing of Parameters As A Table

DTEL 38
Types of System Calls

1. Process Control
2. File Management/Manipulation
3. Device Management/Manipulation
4. Information maintenance
5. Communications

DTEL 39
Types of System Calls

• Process control: These system calls deal with


processes such as process creation, process termination etc.
– create process, terminate process
– end, abort
– load, execute
– get process attributes, set process attributes
– wait for time
– wait event, signal event
– allocate and free memory

DTEL 40
Types of System Calls
• File management:These system calls are responsible for file
manipulation such as creating a file, reading a file, writing into a file etc.
– create file, delete file
– open, close file
– read, write, reposition
– get and set file attributes
• Device management:These system calls are responsible for
device manipulation such as reading from device buffers, writing into
device buffers etc.
– request device, release device
– read, write, reposition
– get device attributes, set device attributes
– logically attach or detach devices
DTEL 41
Types of System Calls
• Information maintenance: These system calls handle information and
its transfer between the operating system and the user program.
– get time or date, set time or date
– get system data, set system data
– get and set process, file, or device attributes
• Communications: These system calls are useful for interprocess
communication. They also deal with creating and deleting a communication
connection.
– create, delete communication connection
– send, receive messages if message passing model to host name or
process name
• From client to server
– Shared-memory model create and gain access to memory regions
– transfer status information
– attach and detach remote devices
http://www.it.uu.se/education/course/homepage/os/vt18/module-2/process-management/
DTEL (fork)
42
Examples of system calls in Windows and Linux
Types of System Windows Linux
Calls
Process Control CreateProcess() fork()
ExitProcess() exit()
WaitForSingleObject() wait()
File Management CreateFile() open()
ReadFile() read()
WriteFile() write()
CloseHandle() close()
Device Management SetConsoleMode() ioctl()
ReadConsole() read()
WriteConsole() write()
Information GetCurrentProcessID() getpid()
Maintenance SetTimer() alarm()
Sleep() sleep()
Communication CreatePipe() pipe()
CreateFileMapping() shmget()
MapViewOfFile() mmap()
DTEL 43
Process

• Process Concept
Process – a program in execution; process execution must
progress in sequential fashion

• A process includes:
– program counter
– Stack-for storing temporary data (e.g. subroutine
parameter, return address and temporary variable)
– data section-contains global variable

DTEL 44
Process

• Process Concept
• Diagram Of process state

DTEL 45
Process State
As a process executes, it changes state
The state of a process is determined based on the current
activity of the process.
Each Process may be in one of the following states:
• New : The process is being created
• Running : The program Instructions are being executed
• Waiting : The process is waiting for some event to occur
• Ready : The process is waiting in the ready queue to be

assigned to a processor.
• Terminated : The process has finished execution

DTEL 46
Process Control Block (PCB)

In the operating system, a process is represented by the


process control block. ( task control block)
It serves as a database for data related to a certain
process.

A PCB (Process Control Block) is a data


structure used in the operating system to store
all data related information to the process.
For example, when a process is created in the
operating system, updated information of the
process, switching information of the process,
terminated process in the PCB.

DTEL 47
Process Control Block (PCB)

DTEL 48
Cont..
• Pointer: Information associated with each process
• Process state :state may be new, ready, running,
waiting, halting and so on.
• Process number: a PID is a unique number that identifies each
running processes in an operating system
• Program counter: indicate address of new instruction to
be execute for a process
• CPU registers: CPU scheduling information process
priority ,pointer to scheduling queues, and other
scheduling parameters.

DTEL 49
Cont..

• Memory-management information :
information regarding base register, limit register, page table,
segment table related to process .
• Accounting information
• include amount of CPU and real time used, time limit,
account number, job or process number
• I/O status information
• list of I/O devices allocated to process, a list of open file for
a process

DTEL 50
CPU Switch From Process to Process

Context Switching
A context switching is a process that involves switching of
the CPU from one process or task to another. In this
phenomenon, the execution of the process that is present in
the running state is suspended by the kernel and another
process that is present in the ready state is executed by the
CPU.
Context Switching is the mechanism that allows
multiple processes to use a single CPU.
Context Switching stores the status of the ongoing
process so that the process can be reloaded from the
same point from where it was stopped.

DTEL 51
CPU Switch From Process to Process

DTEL 52
Scheduling Queue

1. Job Queue

2. Ready Queue

3. Device Queue

The processes that are entering into the system are stored in
the Job Queue. Suppose if the processes are in the Ready
state are generally placed in the Ready Queue.
The processes waiting for a device are placed in Device
Queues. There are unique device queues which are available
for every I/O device.

DTEL 53
Representation of Process Scheduling

DTEL 54
Schedulers
Schedulers are special system software which handles
process scheduling in various ways. Their main task is to
select the job to decide which process to run first.

Schedulers are of Three types


1. Long Term Scheduler
2. Short Term Scheduler
3. Medium Term Scheduler

Long Term Scheduler is also called job scheduler. Short


Term Scheduler is also called CPU scheduler. Medium
term scheduling is part of the swapping.

DTEL 55
Schedulers
Long Term Short Term Medium Term
Long Term is a job Short Term is a CPU Medium Term is
scheduler. scheduler. swapping.
Speed is less than short Medium Term Speed is in
Speed is very fast.
term scheduler. between both
Less control over the
It controls the degree of Reduce the degree of
degree of
multiprogramming. multiprogramming.
multiprogramming.
Absent or minimal in a Minimal in a time-sharing Time sharing system uses
time-sharing system. system. medium term scheduler.

It selects processes from It selects from among the Process can be


the pool and loads them processes that are ready to scheduled form SM to MM
into memory for execution. execute. and MM to SM

A Process state is (brings Process state is (decides


process from SM to MM which process goes from –
New to Ready). Ready to Running)
Select a good process, a
Select a new process for a
mix of I/O bound and CPU –
CPU quite frequently.
bound.

DTEL 56
Medium Term Scheduling

DTEL 57
Operation On Processes

• Process Creation: A process may create several new


processes, via a create –process system call, during
course of execution. The creating process is called
parent-process, whereas the new processes are called
the children of that process.

• Process Termination: A process terminates when it


finishes executing its last statement an as the operating
system to delete it by using the exit system call

DTEL 58
Process creation:
• 1. When a new process is created, the operating system assigns
a unique Process Identifier (PID) to it and inserts a new entry in
the primary process table.
2. Then required memory space for all the elements of the process
such as program, data, and stack is allocated including space for
its Process Control Block (PCB).
3. Next, the various values in PCB are initialized such as,
• The process identification part is filled with PID assigned to it in
step (1) and also its parent’s PID.
• The processor register values are mostly filled with zeroes, except
for the stack pointer and program counter. The stack pointer is
filled with the address of the stack-allocated to it in step (ii) and
the program counter is filled with the address of its program
entry point.

• The process state information would be set to ‘New’.
• Priority would be lowest by default, but the user can
specify any priority during creation.
4. Then the operating system will link this process to
the scheduling queue and the process state would be
changed from ‘New’ to ‘Ready’. Now the process is
competing for the CPU.
5. Additionally, the operating system will create some
other data structures such as log files or accounting
files to keep track of processes activity.
Process Deletion:
• Processes are terminated by themselves when they finish
executing their last statement, then operating system USES
exit( ) system call to delete its context. Then all the resources
held by that process like physical and virtual memory, buffers,
open files, etc., are taken back by the operating system. A
process P can be terminated either by the operating system or
by the parent process of P.
• A parent may terminate a process due to one of the following
reasons:
• When task given to the child is not required now.
• When the child has taken more resources than its limit.
• The parent of the process is exciting, as a result, all its
children are deleted. This is called cascaded termination.
Cooperating Processes
Cooperating processes are those that can affect or are
affected by other processes running on the system.
• Several reasons for providing an environment that
allows process co-operation.
• Information sharing
• Computation speedup
• Modularity
• Convenience

DTEL 62
Cooperating Processes
• Information sharing :Access to the same files. A mechanism is
required so that the processes can access the files in parallel to each
other.

• Computation speedup: This increases the computation speedup


as the task can be executed faster

• Modularity: Dividing complicated tasks into smaller subtasks

• Convenience :There are many tasks that a user needs to do such


as compiling, printing, editing etc. It is convenient if these tasks can
be managed by cooperating processes.

DTEL 63
Threads
Thread is a single sequence stream within a process.
they are called as light weight processes.
Threads are executed one after another but gives the
illusion as if they are executing in parallel.
Each thread has different states. Each thread has
A program counter
A register set
A stack space
Threads are not independent of each other as they share
the code, data, OS resources etc.

For example, in a browser, multiple tabs can be different


threads. MS Word uses multiple threads: one thread to
format the text, another thread to process inputs, etc

DTEL 64
Threads

• User-level thread

• Kernel-level thread

DTEL 65
User-level Threads

• Thread management routines linked into application


• No kernel intervention == high performance
• Supports customized scheduling algorithms == flexible

• (Virtual) processor blocked during system services == lack of


functionality
• I/O, page faults, and multiprogramming cause entire process
to block

DTEL 66
User-level Threads

Process
(“virtual processor”)
User Thread
space

Kernel
space

Runtime system Thread table Process table

DTEL 67
Kernel Threads
• No system integration problems (system calls can be
blocking calls) == high functionality
• OS kernel provides system call to create and manage
threads.

• Extra kernel trap and copy and check of all parameters on


all thread operations == poor performance

• Kernel schedules thread from same or other address space


(process)

• Single, general purpose scheduling algorithm == lack of


flexibility

DTEL 68
Kernel Threads

Process

User Thread
space

Kernel
space

Thread table Process table

DTEL 69
Difference between User Level thread and Kernel Level thread

User level thread Kernel level thread


User thread are implemented by users. kernel threads are implemented by OS.
OS doesn’t recognize user level threads. Kernel threads are recognized by OS.
Implementation of User threads is easy. Implementation of Kernel thread is complicated.
Context switch time is less. Context switch time is more.
Context switch requires no hardware support. Hardware support is needed.
If one user level thread perform blocking If one kernel thread perform blocking operation then
operation then entire process will be blocked. another thread can continue execution.
Example : Java thread, POSIX threads. Example : Window Solaris.
Diagram:

Diagram

DTEL 70
Kernel Threads
• OS-Definition
• Goals-(ACE)
• OS Types
• OS Services (UPI FCE RAS)
• OS functions(PMF ISS NPC)
• Process management
• Process
• Kernel
• Syscall
• Syscall types (PFDIC)
• Process states (n r r w t)
• PCB
• Context s/w
• Scheduling que(J R D)
• Scheduler
• Threads & types

DTEL 71
THANK YOU

DTEL 72

You might also like