Aos Sa1
Aos Sa1
Aos Sa1
MODULE 1 – IT0035
• Examples: Microsoft Windows Server × CPU moves data from/to main memory
2003, Microsoft Windows Server 2008, to/from local buffers.
UNIX, Linux, Mac OS X Server, Novell × I/O is from the device to local buffer of
NetWare, and BSD/OS (Berkeley controller.
Software Design) × Device controller informs CPU that it has
5. Real-time Operating System finished its operation by causing an interrupt.
• RTOS is an operating system intended
to serve real-time systems/applications What is an Interrupt?
that process data as it comes in, mostly › Interrupt is a signal emitted by hardware or
without buffer delay. software when a process or an event needs
• The time interval required to process immediate attention.
and respond to inputs is very small. › It alerts the processor temporarily to a high
This time interval is called response priority process requiring interruption of the
time. current working process and then return to
• Real-time systems are used when there its previous task.
are time requirements are very strict › Types of Interrupts:
like missile systems, air traffic control o Hardware Interrupt
systems, robots, etc. o Software Interrupt
• Examples: LynxOS, OSE, QNX, RTLinux, › An operating system is interrupt driven.
VxWorks, Windows CE
6. Handheld Operating System HARDWARE INTERRUPT
• It is also known as Mobile OS which is → A signal created and sent to the CPU that is
built exclusively for a mobile device, caused by some action taken by a hardware
such as a smartphone, personal device.
digital assistant (PDA), tablet, → Example: When a key is pressed or when
wearable devices or other embedded the mouse is moved.
mobile OS.
• Examples: Android, Symbian, iOS, SOFTWARE INTERRUPT
BlackBerry OS and Windows Mobile → Arises due to illegal and erroneous use of
an instruction or data. It often occurs when
COMPUTER SYSTEM ORGANIZATION an application software terminates or when
× One or more CPUs, device controllers connect it requests the operating system for some
through common bus providing access to service.
shared memory. → Example: stack overflow, division by zero,
× Concurrent execution of CPUs and devices invalid opcode, etc. These are also called
completing for memory cycles. traps.
× I/O devices and the CPU can execute
INTERRUPT HANDLING
concurrently.
× Each device controller is in charge of a The operating system preserves the state of the
particular device type CPU by storing registers and the program counter.
× Each device controller has a local buffer. Determines which type of interrupt has occurred:
Applied Operating System
MODULE 1 – IT0035
› Virtualization
• It is a technology that allows operating
systems to run as applications within OPEN-SOURCE OPERATING SYSTEM
other operating system. × Open Source operating systems are
• It is one member of the class software released under a license where the copyright
that also includes emulation. Emulation holder allows others to study, change as well
is used when the source CPU type is as distribute the software to other people.
different from the target CPU type. × Counter to the copy protection and Digital
• Example: virtual machine, Rights Management (DRM) movement.
OracleVirtualBox × Started by Free Software Foundation (FSF),
› Cloud Computing which has “copyleft” GNU Public License
• It is a type of computing that delivers (GPL)
computing, storage and even × Examples: GNU (GNU’s Not Unix) / Linux,
applications as a service across a BSD UNIX (including core of Mac OS X), and
network. Sun Solaris
• It is a logical extension of virtualization
→ Public Cloud – cloud available via
the Internet
→ Private Cloud – cloud run by a
company for that company’s own
use
→ Hybrid Cloud – cloud that includes
both public and private
› Cloud Computing Service Models
• Software as a Service (SaaS) – one or
more applications available via the
Internet
• Platform as a Service (PaaS) – software
stack ready for application use via the
Internet
• Infrastructure as a Service (IaaS) –
servers or storage available over the
Internet.
Platform Type Common Examples
Google Apps, Dropbox, Salesforce,
SaaS
Cisco WebEx, Concur, GoToMeeting
AWS Elastic Beanstalk, Windows Azure,
PaaS Heroku, Force.com, Google App
Engine, Apache Stratos, OpenShift
DigitalOcean, Linode, Rackspace,
Amazon Web Services (AWS), Cisco
IaaS
Metapod, Microsoft Azure, Google
Compute Engine (GCE)
Applied Operating System
MODULE 2 – IT0035
PROCESS CONCEPT
Example of the CPU being switched from one
PROCESS CONTROL BLOCK
process to another. This is also known as Context
Each process is represented in the operating Switch Diagram.
system by a process control block (PCB) – also
called a task control block. A PCB is a data block CONCURRENT PROCESSES
or record containing many pieces of the o The processes in the system can execute
information associated with a specific process concurrently; that is, many processes may be
including: multitasked on a CPU.
1. Process state. The state may be new, o A process may create several new processes,
ready, running, waiting, or halted. via a create-process system call, during the
2. Program Counter. The program counter course of execution. Each of these new
indicates the address of the next processes may in turn create other processes.
instruction to be executed for this process. o The creating process is the parent process
3. CPU Registers. These include whereas the new processes are the children
accumulators, index registers, stack of that process.
pointers, and general-purpose registers, o When a process creates a sub-process, the
plus any condition-code information. sub-process may be able to obtain its
Along with the program counter, this resources directly from the OS or it may use a
information must be saved when an subset of the resources of the parent process.
interrupt occurs, to allow the process to be o Restricting a child process to a subset of the
continued correctly afterward. parent’s resources prevents any process from
4. CPU Scheduling Information. This overloading the system by creating too
information includes a process priority, many processes
pointers to scheduling queues, and any o When a process creates a new process, two
other scheduling parameters. common implementations exist in terms of
5. Memory Management Information. This execution:
information includes limit registers or page 1. The parent continues to execute
tables. concurrently with its children.
6. Accounting Information. This information 2. The parent waits until all its children
includes the amount of CPU and real time have terminated.
Applied Operating System
MODULE 2 – IT0035
o A process terminates when it finishes its last 2. The result of its execution is
statement and asks the operating system to nondeterministic since it will not always
delete it using the exit system call. be the same for the same input.
o A parent may terminate the execution of one o Concurrent execution of cooperating process
of its children for a variety of reason, such as: requires mechanisms that allow processes to
1. The child has exceeded its usage of communicate with one another and to
some of the resources it has been synchronize their actions
allocated.
2. The task assigned to the child is no SCHEDULING CONCEPTS
longer required. • The objective of multiprogramming is to
3. The parent is exiting, and the OS does have some process running at all times, to
not allow a child to continue if its parent maximize CPU utilization.
terminates. In such systems, if a process • Multiprogramming also increases
terminates, then all its children must also throughput, which is the amount of work
be terminated by the operating system. the system accomplishes in a given time
This phenomenon is referred to as interval (for example, 17 processes per
cascading termination. minute).
o The concurrent processes executing in the OS • Example: Given two processes, P0 and P1.
may either be independent processes or
cooperating processes.
o A process is independent if it cannot affect or
be affected by the other processes. Clearly, • The idea of multiprogramming is if one
any process that does not share any data process is in the waiting state, then another
(temporary or persistent) with any other process which is in the ready state goes to
process is independent. Such a process has the running state.
the following characteristics: • As processes enter the system, they are put
1. Its execution is deterministic; that is, the into a job queue. This queue consists of all
result of the execution depends solely processes in the system.
on the input state. • The processes that are residing in main
2. Its execution is reproducible; that is, the memory and are ready and waiting to
result of the execution will always be the execute are kept on another queue which is
same for the same input. the ready queue.
3. Its execution can be stopped and • A process migrates between the various
restarted without causing ill effects. scheduling queues throughout its lifetime.
o A process is cooperating if it can affect or be The OS must select processes from these
affected by the other processes. Clearly, any queues in some fashion.
process that shares data with other processes • The selection process is the responsibility of
is a cooperating process. Such a process has the appropriate scheduler.
the following characteristics:
1. The results of its execution cannot be
predicted in advance, since it depends
on relative execution sequence.
Applied Operating System
MODULE 2 – IT0035
TYPES OF SCHEDULER process and loading the saved state for the
o Long-term scheduler ( or Job scheduler ) new process. This task is known as context
→ selects processes from the secondary switch.
storage and loads them into memory › Context-switch time is pure overhead,
for execution. because the system does no useful work
→ The long-term scheduler executes while switching and should therefore be
much less frequently. minimized.
→ There may be minutes between the › Whenever the CPU becomes idle, the OS
creation of new processes in the (particularly the CPU scheduler) must select
system. one of the processes in the ready queue for
→ The long-term scheduler controls the execution.
degree of multiprogramming – the
CPU SCHEDULER
number of processes in memory.
→ Because of the longer interval between CPU scheduling decisions may take place under
executions, the long-term scheduler the following four circumstances:
can afford to take more time to select 1. When a process switches from the running
a process for execution. state to the waiting state (for example, I/O
o Short-term scheduler ( or CPU scheduler ) request, invocation of wait for the
→ selects process from among the termination of one of the child processes).
processes that are ready to execute, 2. When a process switches from the running
and allocates the CPU to one of them. state to the ready state (for example, when
→ The short-term scheduler must select a an interrupt occurs).
new process for the CPU frequently. 3. When a process switches from the waiting
→ A process may execute for only a few state to the ready state (for example,
milliseconds before waiting for an I/O completion of I/O).
request. 4. When a process terminates.
→ Because of the brief time between For circumstances 1 and 4, there is no choice in
executions, the short-term scheduler terms of scheduling. A new process (if one exists
must be very fast. in the ready queue) must be selected for
execution. There is a choice, however, for
SCHEDULING CONCEPTS
circumstances 2 and 3.
› Medium-term scheduler removes (swaps
When scheduling takes place only under
out) certain processes from memory to lessen
circumstances 1 and 4, the scheduling scheme is
the degree of multiprogramming (particularly
non-preemptive; otherwise, the scheduling
when thrashing occurs)
scheme is preemptive.
› At some later time, the process can be
reintroduced into memory and its execution CPU SCHEDULING
can be continued where it left off.
• Non-preemptive scheduling, once the CPU
› This scheme is called swapping.
has been allocated to a process, the process
› Switching the CPU to another process
keeps the CPU until it releases the CPU either
requires some time to save the state of the old
by terminating or switching states. No process
Applied Operating System
MODULE 2 – IT0035
is interrupted until it is completed, and after waiting in the ready queue, executing in the
that processor switches to another process. CPU, and doing I/O.
• Preemptive scheduling works by dividing 4. Waiting Time is the time a job waits for
time slots of CPU to a given process. The time resource allocation when several jobs are
slot given might be able to complete the whole competing in multiprogramming system.
process or might not be able to it. When the Waiting time is the total amount of time a
burst time of the process is greater than CPU process spends waiting in the ready queue.
cycle, it is placed back into the ready queue and 5. Response Time is the time from the
will execute in the next chance. This scheduling submission of a request until the system
is used when the process switch to ready state. makes the first response. It is the amount of
time it takes to start responding but not the
CPU SCHEDULING ALGORITHMS time that it takes to output that response.
• Different CPU-scheduling algorithms have
A good CPU scheduling algorithm maximizes
different properties and may favor one class
CPU utilization and throughput and minimizes
of processes over another.
turnaround time, waiting time and response time.
• Many criteria have been suggested for
comparing CPU-scheduling algorithms. • In most cases, the average measure is
• The characteristics used for comparison can optimized. However, in some cases, it is
make a substantial difference in the desired to optimize the minimum or
determination of the best algorithm. The maximum values, rather than the average.
criteria should include: CPU Utilization, • For example, to guarantee that all users get
Throughput, Turnaround Time, Waiting good service, it may be better to minimize
Time, and Response Time the maximum response time.
• For interactive systems (time-sharing
CPU SCHEDULING ALGORITHMS systems), some analysts suggests that
1. CPU Utilization measures how busy is the minimizing the variance in the response
CPU. CPU utilization may range from 0 to 100 time is more important than averaging
percent. In a real system, it should range from response time.
40% (for a lightly loaded system) to 90% (for • A system with a reasonable and predictable
a heavily loaded system). response may be considered more desirable
2. Throughput is the amount of work than a system that is faster on the average,
completed in a unit of time. In other words but is highly variable.
throughput is the processes executed to • Non-preemptive:
number of jobs completed in a unit of time. › First-Come First-Served(FCFS)
The scheduling algorithm must look to › Shortest Job First (SJF)
maximize the number of jobs processed per › Priority Scheduling (Non-preemptive)
time unit. • Preemptive:
3. Turnaround Time measures how long it › Shortest Remaining Time First (SRTF)
takes to execute a process. Turnaround time › Priority Scheduling (Preemptive)
is the interval from the time of submission to › Round-robin (RR)
the time of completion. It is the sum of the
periods spent waiting to get into memory,
Applied Operating System
MODULE 2 – IT0035
Arrival Burst Waiting Turnaround
Process
CPU SCHEDULING TECHNIQUES—NON Time Time Time Time
PREEMPTIVE P1 0 5 0-0 = 0 5-0 = 5
P2 1 3 5-0 = 5 8-0 = 8
FIRST-COME FIRST-SERVED (FCFS) P3 2 8 8-0 = 8 16-0 =16
→ FCFS is the simplest CPU-scheduling 16-0 =
P4 3 6 22-0 = 22
algorithm. 16
→ The process that requests the CPU first gets 29/4 51/4
Average
7.25 ms 12.75 ms
the CPU first.
→ The FCFS algorithm is non-preemptive.
→ Example 1: Gantt Chart:
o Consider the following set of P1 P2 P3 P4
processes that arrive at time 0, with
the length of the CPU burst given in
0 5 8 16 22
milliseconds (ms).
o Illustrate the Gantt chart and SHORTEST JOB FIRST (SJF)
compute for the average waiting → SJF algorithm associates with each process
time and average turnaround the length of the latter’s next CPU burst.
time. → When the CPU is available, it is assigned
Given: to the process that has the smallest next
Arrival Burst Waiting Turnaround CPU burst.
Process
Time Time Time Time
→ If two processes have the same length next
P1 0 5 0-0 = 0 5-0 = 5
P2 0 3 5-0 = 5 8-0 = 8
CPU burst, FCFS scheduling is used to
P3 0 8 8-0 = 8 16-0 =16 break the tie.
16-0 = → SJF algorithm is non-preemptive.
P4 0 6 22-0 = 22
16 → Example 1:
29/4 51/4 Arrival Burst Waiting Turnaround
Average Process
7.25 ms 12.75 ms Time Time Time Time
P1 0 5 3-0 = 3 8-0 = 8
Gantt Chart:
P2 0 3 0-0 = 0 3-0 = 3
P1 P2 P3 P4 14-0 =
P3 0 8 22-0 = 22
14
P4 0 6 8-0 = 8 14-0 = 14
0 5 8 16 22 25/4 47/4
Average
Formulas: 6.25 ms 11.75 ms
• Waiting time = Start time – Arrival Gantt Chart:
time
P2 P1 P4 P3
• Turnaround time = Completion time
– Arrival time
• Average Waiting time = Sum of 0 3 8 14 22
Waiting time / No. of processes
• Average Waiting Time = Sum of
Turnaround time / No. of processes
→ Example 2:
Applied Operating System
MODULE 2 – IT0035
→ Example 3:
Proce Arrival Burst
Priority
Waiting Turnaroun → The performance of the RR algorithm
ss Time Time Time d Time
P1 0 5 1 0-0 = 0 5-0 = 5
depends heavily on the size of the time
13-1 = quantum.
P2 1 3 2 16-1 = 15
12 → If the time quantum is too large (infinite),
P3 2 8 1 5-2 = 3 13-2 = 11
the RR policy degenerates into the FCFS
16-3 =
P4 3 6 3
13
22-3 = 19 policy.
Average
28/4 50/4 → If the time quantum is too small, then the
7 ms 12.5 ms effect of the context switch time becomes
Gantt Chart: a significant overhead.
P1 P1 P1 P1 P3 P2 P4 → As a general rule, 80 percent of the CPU
burst should be shorter than the time
quantum.
0 1 2 3 5 13 16 22
0 3 6 9 12 14 17 20 22