Unit 1
Unit 1
IV-SEMESTER
OPERATING SYSTEMS
UNIT1
Syllabus
• Introduction,
• system calls.
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.
DTEL 6
• System software:-
• These software programs are designed to run a
computer's application programs and hardware.
DTEL 7
• The OS is the best example of system
software;
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
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.
DTEL 13
INTRODUCTION TO OS
DTEL 14
INTRODUCTION TO OS
https://www.toppr.com/guides/computer-science/computer-fundamentals/operating-
system/
DTEL 15
OPERATING SYSTEM
DTEL 16
OPERATING SYSTEM
DTEL 18
OPERATING SYSTEM
Status information:
This includes a list of I/O devices allocated to the
process.
DTEL 19
OPERATING SYSTEM
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 )
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
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
Applications
System calls
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.
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
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)
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.
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.
DTEL 56
Medium Term Scheduling
DTEL 57
Operation On Processes
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.
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.
DTEL 64
Threads
• User-level thread
• Kernel-level thread
DTEL 65
User-level Threads
DTEL 66
User-level Threads
Process
(“virtual processor”)
User Thread
space
Kernel
space
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.
DTEL 68
Kernel Threads
Process
User Thread
space
Kernel
space
DTEL 69
Difference between User Level thread and Kernel Level thread
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