Operating System Introduction
Operating System Introduction
Operating System Introduction
User1
User1 User2
User2 User3
User3 ... User
Usernn
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
Mode bit=1
API
Mode bit=0
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
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