Contents
● What is an operating system(OS)?
● Computer System Components
● Types of Operating systems
● Introduction to System call
● Introduction to Process management
● Process states
● Operation on process
● Process Scheduling
● Operating system services
What is an Operating System?
• Operating System can be defined as an
 interface/mediator between user and the hardware.
• OS is Resource allocator.
• It provides an environment to the user so that, the
 user can perform its task in convenient and
 efficient way.
Examples of OS: Windows,Linux,Android,Mac OS.
OS primary goals is :
– To provide convenience to the user.
OS Secondary goal is :
– Use the computer hardware in an efficient manner.
Computer System Components
Computer system can be divided into four components:
 – Hardware – provides basic computing resources
 • CPU, memory, I/O devices,…
 – Operating system- Controls the hardware and
 coordinates its use among various applications
 programs for the various users.
 – Application programs – Solve computing problems
 of users (Word processors, compilers, web browsers,
 database systems, video games, text editor).
 – Users
 • People, machines, other computers
Abstract View of the Components of a
Computer System
 User1
 User1 User2
 User2 User3
 User3 ... User
 Usernn
 compiler assembler Text editor Database
 system
 System
 Systemand
 andApplication
 ApplicationPrograms
 Programs
 Operating
 OperatingSystem
 System
 Computer
 Computer
 Hardware
 Hardware
 4
 Why do we need OS?
• We need an environment in which a user can
 execute programs.
• The purpose is three fold:
 • To ensure the correct operation of the computer
 system.
 • To make the computer system convenient to use.
 • To use the computer hardware in an efficient
 manner.
Disadvantages of using Operating System
 • If any issue occurs in OS, you may lose all the
 contents which have been stored in your
 system.
 • Operating system's software is quite expensive
 for small size organization which adds burden
 on them. Example Windows.
 • It is never entirely secure as a threat can occur
 at any time.
 OS Functionality
• Resource management/Governor.
• Process management(Eg: ms word, game app,
 video, open all) (CPU Schedulig).
• Storage management(Hard disk/secondary device).
• Memory management (RAM).
• Security and privacy provided by the OS (Eg.
 Password).
Types of Operating System
• There are many types of operating system exists
 in the current scenario:
1. Batch OS
2. Multiprogramming OS
3. Multitasking OS
4. Multiprocessing OS
5. Real time OS
 Batch Operating System:
• In Batch OS will work to submit similar kinds of
 job together.
• In this OS user do not interact directly with our
 computer system.
Advantages:
• It is useful when we working with large files which can
 take more time to execute.
Disadvantages of Batch OS:
1. Starvation
• Batch processing suffers from starvation
2. Not Interactive to the user.
3. Efficiency is very less.
4. Increased CPU idleness
5. Decreased throughput of the system(Throughput means
 the number of jobs completed for unit time)
Multiprogramming OS
• Multiprogramming is an extension to the batch
 processing where the CPU is kept always busy.
• In multiprogramming Efficiency is increased.
• CPU used efficiently.
Note: Each process needs two types of system time: CPU time and
I/O time.
Multi tasking (Timesharing) OS
 The time sharing OS works with time sharing concept.
 Here the CPU will provide a same time period to each an every
 process to complete its task as soon as possible whether it is a long
 process or short process.
 Programs queued for execution in FIFO order.
 Like multiprogramming, but timer device interrupts after a
 quantum (timeslice).
Advantages:
• User interactive is improved.
Multiprocessing OS
• In Multiprocessing, Parallel computing is
 achieved. There are more than one processors
 present in the system which can execute more
 than one process at the same time.
• This will increase the throughput of the
 system.
• Reliability increased.(one cpu fail it work give
 to another cpu).
 Real Time Operating System
• In Real Time systems, each job carries a certain
 deadline within which the Job is supposed to be
 completed, otherwise the huge loss will be there
 or even if the result is produced then it will be
 completely useless.
• The Application of a Real Time system exists in
 the case of military applications, if you want to
 drop a missile then the missile is supposed to be
 dropped with certain precision.
 Introduction to System Calls
• To understand system calls, first one needs to
 understand the difference between kernel
 mode and user mode of a CPU.
• Every modern operating system supports these two
 modes.
 Modes supported by the operating system
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.
 (or)
 System calls provide an interface between user programs and
 operating system.
• In general, system calls are available as assembly language
 instructions.
• When a program makes a system call, the mode is switched
 from user mode to kernel mode. This is called a context
 switch.
• Then the kernel provides the resource which the program
 requested. After that, another context switch happens which
 results in change of mode from kernel mode back to user mode.
 • A figure representing the execution of the system call is
 given as follows:
 Mode bit=1
API
 Mode bit=0
 Hard Disk access
Types of System call:
System call can be grouped roughly into five major categories:
1.File Management/Manipulation:-It handles file manipulation
 jobs like Creating, opening, closing and deleting files in the file
 system.
2.Process Control:-This system calls perform the task of Creating
 and managing new processes.
3.Communications:-These types of system calls are specially used
 for Creating a connection in the network, sending and receiving
 packets.
4.Device Management/Manipulation:-Requesting access to a
 hardware device, like a mouse, scanner or a printer.
5.Information Maintenance: It handles information and its transfer
 between the OS and the user program.
• Some of the examples of all the above types of system calls in Windows
 and Unix are given as follows −
 WINDOWS UNIX
 CreateProcess() fork()
 ExitProcess() exit()
 Process Control WaitForSingleObject() wait()
 CreateFile() open()
 ReadFile() read()
 WriteFile() write()
 File Manipulation CloseHandle() close()
 SetConsoleMode() ioctl()
 ReadConsole() read()
 Device Manipulation WriteConsole() write()
 GetCurrentProcessID() getpid()
 SetTimer() alarm()
 Information Maintenance Sleep() sleep()
 CreatePipe() pipe()
 CreateFileMapping() shmget()
 Communication MapViewOfFile() mmap()
 SetFileSecurity() chmod()
 InitlializeSecurityDescriptor() umask()
 Protection SetSecurityDescriptorGroup() chown()
Introduction of Process Management
Difference between program and process
 A program in execution is called a process. (or)
 A process is a program in execution.
 For example, when we write a program in C or
 C++ and compile it, the compiler creates
 binary code. The original code and binary code
 are both programs. When we actually run the
 binary code, it becomes a process.
What does a process look like in memory?
Text Section: A Process, sometimes known as the Text Section,
also includes the current activity represented by the value of
the Program Counter.
Stack: The Stack contains the temporary data, such as function
parameters, returns addresses, and local variables.
Data Section: Contains the global variable and static variables.
Heap Section: Dynamically allocated memory to process
during its run time.
Structure of Process in MM:
Process States (or) Process Life Cycle
• The process, from its creation to completion,
 passes through various states. The minimum
 number of states is four.
• A process is in one of the following states:
1. New
• A program which is going to be picked up by the OS
 into the main memory is called a new process.
2. Ready
• Whenever a process is created, it directly enters in the
 ready state, in which, it waits for the CPU to be
 assigned. The OS picks the new processes from the
 secondary memory and put all of them in the main
 memory.
• The processes which are ready for the execution and
 reside in the main memory are called ready state
 processes. There can be many processes present in the
 ready state.
3. Running
• One of the processes from the ready state will be chosen by the
 OS depending upon the scheduling algorithm. Hence, if we have
 only one CPU in our system, the number of running processes
 for a particular time will always be one. If we have n processors
 in the system then we can have n processes running
 simultaneously.
4. Block or wait
• From the Running state, a process can make the transition to the
 block or wait state depending upon the scheduling algorithm or
 the intrinsic behavior of the process.
• When a process waits for a certain resource to be assigned or for
 the input from the user then the OS move this process to the
 block or wait state and assigns the CPU to the other processes.
5. Completion or termination
• When a process finishes its execution, it comes in the
 termination state. All the context of the process (Process
 Control Block) will also be deleted the process will be
 terminated by the Operating system.
6. Suspend ready
• A process in the ready state, which is moved to secondary
 memory from the main memory due to lack of the resources
 (mainly primary memory) is called in the suspend ready state.
• If the main memory is full and a higher priority process comes
 for the execution then the OS have to make the room for the
 process in the main memory by throwing the lower priority
 process out into the secondary memory. The suspend ready
 processes remain in the secondary memory until the main
 memory gets available.
7. Suspend wait
• Instead of removing the process from the ready
 queue, it's better to remove the blocked process
 which is waiting for some resources in the main
 memory.
• Since it is already waiting for some resource to get
 available hence it is better if it waits in the
 secondary memory and make room for the higher
 priority process. These processes complete their
 execution once the main memory gets available and
 their wait is finished.
Operations on the Process
There are many operations that can be performed on
 processes
1. Creation
• Once the process is created, it will be ready and
 come into the ready queue (main memory) and will
 be ready for the execution.
2. Scheduling
• Out of the many processes present in the ready
 queue, the Operating system chooses one process
 and start executing it. Selecting the process which
 is to be executed next, is known as scheduling.
3. Execution
 Once the process is scheduled for the
execution, the processor starts executing it.
Process may come to the blocked or wait state
during the execution then in that case the
processor starts executing the other processes.
4. Deletion/killing
 Once the purpose of the process gets over
then the OS will kill the process. The Context of
the process (PCB) will be deleted and the process
gets terminated by the Operating system.
 30
Process Schedulers
Operating system uses various schedulers for the process
 scheduling described below.
1. Long term scheduler (or) Job scheduler
• Long term scheduler is also known as job scheduler. It chooses
the processes from the pool (secondary memory) and keeps them
in the ready queue maintained in the primary memory.
• Long Term scheduler mainly controls the degree of
Multiprogramming. The purpose of long term scheduler is to
choose a perfect mix of IO bound and CPU bound processes
among the jobs present in the pool.
• If the job scheduler chooses more IO bound processes then all
of the jobs may reside in the blocked state all the time and the
CPU will remain idle most of the time. This will reduce the degree
of Multiprogramming. Therefore, the Job of long term scheduler is
very critical and may affect the system for a very long time.
2. Short term (or) CPU/Dispatch scheduler
• Short term scheduler is also known as CPU
scheduler. It selects one of the Jobs from the ready
queue and dispatch to the CPU for the execution.
• A scheduling algorithm is used to select which job
is going to be dispatched for the execution.
• The Job of the short term scheduler can be very
critical in the sense that if it selects job whose CPU
burst time is very high then all the jobs after that, will
have to wait in the ready queue for a very long time.
• This problem is called starvation which may arise
if the short term scheduler makes some mistakes
while selecting the job.
3. Medium term scheduler (or) process swapping scheduler
• Medium term scheduler takes care of the swapped out
processes. If the running state processes needs some IO
time for the completion then there is a need to change its
state from running to waiting.
• Medium term scheduler is used for this purpose. It
removes the process from the running state to make room
for the other processes. Such processes are the swapped out
processes and this procedure is called swapping.
•The medium term scheduler is responsible for suspending
and resuming the processes.
• It reduces the degree of multiprogramming. The
swapping is necessary to have a perfect mix of processes in
the ready queue.
Operating system services
• An Operating System supplies different kinds of
 services to both the users and to the programs as
 well.
• It also provides application programs (that run
 within an Operating system) an environment to
 execute it freely.
• It provides users the services run various
 programs in a convenient manner.
Here is a list of common services offered by an almost all operating
 systems:
1. User Interface: Eg:-Command line interface, GUI
2. Program Execution
Eg:- source code->compiler->object code->executor->o/p
3. File system manipulation
Eg:- how the files are controlled or manipulated,
4. Input / Output Operations
5. Communication
6. Resource Allocation
7. Error Detection
8. Accounting
9. Security and protection