We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 22
CoSc 6016 - Real Time and Embedded
Systems
CoSc 6016
Real-Time and Embedded Systems
Dagmawi Lemma (PhD)
Assistant Professor
Department of Computer
courses. [email protected]
hitp://sites. google.com /site/dagmawi2012
ence, AAU
2. Real-Time Operating System
CoSc 6016
Real-Time and Embedded Systems
Dagiawi Lemma (PAD)
Assistant Professor
Department of Computer Science, AAU
cuss. da@ mail cot
ntpisites google, comnsite/dapmasi2012
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded
Systems
+ Wh
° Wh
Review of Operating System
Basics
hat it is.
hy we need it,
* Task scheduling,
° Al
Tes)
What is an operation system?
ayer in the modern computer system that is
ponsible to manage several devices and
provide user programs with a simpler interface
to the hardware.
— Extended Machine
— Resource Manager
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded 5/31/2019
systems
What is an operation system?
Ter
system and application programe
‘operating system
computer hardware,
OS Structure and Services
Banking | Airline was | |
‘oysters | reservation | browser | > Application programs
‘Command | |
Compiters | Editors | ‘rerpreter | | System
programs
Operating system
Machine language
Microarchitecture * Hardware
Physical devices |
Dagmawi Lemma - AAU 2018CoSc 6016 - Real Time and Embedded 5/31/2019
Systems
OS Structure and Services
* Kernel Mode
— Protected from user application tampering by the
hardware
* User Mode
~The mode in which applications and system
programs run
— Permits only a subset of the instructions to be
executed and a subset of features to be accessed
+ Disallow 1/0 instruction, Memory Protection, PSW
Setting
Classification
+ Architectures of Operating Systems
— Monolithic
— Microkernel
— Virtual Machines
+ Increasing Efficiency
= Multi program
= Multi user
— Multi core
Dagmawi Lemma - AAU 2018CoSc 6016 - Real Time and Embedded
Systems
Monolithic Architecture
* Monolithic Architecture—the early operating,
systems
— Every component is contained in the kernel, can
directly communicate with other components
Monolithic Architecture
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded
Systems
Monolithic Architecture
Pros
—Highly efficient — by direct intercommunication
between components.
* Cons
~ difficult to develop
— difficult to isolate the source of bugs and other
errors
+ particularly susceptible to damage from malicious code
Layered Architecture
+ Layered OS structure:
— Group components that perform similar functions
into layers. Each layer communicates only with
neighbour layer
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded
Systems
Layered Architecture
Pros
=It provides good modularity — helps simplify the
development of an OS
* Cons
— Less efficient
— Complex design — each functionality has to be
divided into parts to fit into different layers.
Kernel Based Architecture
+ It separates the machinc-independent parts
from the machine-dependent parts
— Kernel is machine-dependent, It contains the basic
component of OS.
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded
Systems
Kernel Based Architecture
* Pros
—Better portability—Kemel encloses all the
machine-dependent code
* Cons
— Suffers similar problem as in layered OSs
Microkernel Based Architecture
+ As OS expanded, the kernel became large and
difficult to manage
—Microkernel approach removes all nonessential
components from the kernel and implementing
them as system and user-level programs.
+ Result: A smaller kernel
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded
Systems
Microkernel Based Architecture
Microkernel Based Architecture
* Pros
—Enhance portability, extensibility, reliability and
security
* Cons
— Less efficient—inereased system function
overhead
Dagmawi Lemma - AAU 2018
5/31/2019CoSc 6016 - Real Time and Embedded
Systems
Virtual Machines
Can create the
illusion that there
are more than one
separate machines
VML
OS Structure and Services
To obtain services from the operating system, a
user program must make a system call
The interface between the operating system
and the user programs is defined by the set of
system calls that the operating system
provides.
Dagmawi Lemma - AAU 2018
5/31/2019
10CoSc 6016 - Real Time and Embedded
systems
OS Structure and Services
OS Services
— Process Management
— Memory Management
— File Management
—1/O Management
— User Management
Process
* Process is a program in execution, including
the current value of program counter, registers
and variables
‘ne progam cour
ae . N
a Gl ==
le qed Ee “}|_- _-
@ »
Dagmawi Lemma - AAU 2018
5/31/2019
qtCoSc 6016 - Real Time and Embedded
Systems
Process
* Process Creation
—Bom, Live, Die
created?
— When is a proces
+ System Initialization
+ Execution of Process creation system call by a running
process
+ Auser request to create a new process
+ Initiation of a batch job
Process
* Process Termination
— When is a process terminated
+ Normal exit (voluntary)
+ Error exit
+ Fatal error
+ Killed by another process
Dagmawi Lemma - AAU 2018
5/31/2019
12CoSc 6016 - Real Time and Embedded
systems
Scheduling
* Scheduler
— Part of the OS that decide which process to pick from the ready
«queue and let to run
+ Scheduling Algorithm
~ The algorithm used by the scheduler for selecting the process
from the ready queue
~ The scheduler has to worry about making efficient use of the
CPU because process swiiching is expensive operation
+ Context Switch
Ready Que
Scheduling
+ Process Behavior
me ‘
@
»
Dagmawi Lemma - AAU 2018
5/31/2019
13CoSc 6016 - Real Time and Embedded 5/31/2019
Systems
Scheduling
+ When to schedule
—as new process is created
* Which one should run? The parent or the child?
as a process exit
— during 1/0 block
— when 1/O interrupt occurs
—If a hardware clock provides periodic interrupts at
some frequency, a scheduling decision can be
made at each clock interrupt or at every A-th clock
interrupt
Scheduling
Scheduling algorithms cab be
—Non-preemptive or
— Preemptive
Decision on the type of scheduling algorithm
has to be made in accordance to the type of
system
—Batch
— Interactive
— Real-time
Dagmawi Lemma - AAU 2018 14CoSc 6016 - Real Time and Embedded
Systems
Scheduling
* The Goal of scheduling algorithm
—For all systems, it has to
+ Be fair: giving each process a fair share of the CPU
+ Enforce policy: make sure that stated policy is carried
out
+ Balance: keeping all parts of the system busy
Scheduling
* The Goal of scheduling algorithm (continued)
—For batch systems
+ Throughput: maximize jobs per hour
+ Tumaround time: minimize time between subt
and termination
+ CPU utilization: keep the CPU busy all the time
Dagmawi Lemma - AAU 2018
5/31/2019
15CoSc 6016 - Real Time and Embedded 5/31/2019
Systems
Scheduling
* The Goal of scheduling algorithm (continued)
— For interactive systems
+ Response time: respond to request quickly
+ Proportionality: meet users” expectations
Scheduling
* The Goal of scheduling algorithm (continued)
—For real-time systems
+ Meeting deadlines
Dagmawi Lemma - AAU 2018 16CoSc 6016 - Real Time and Embedded
systems
Scheduling
+ Scheduling in Batch Systems
— First-come first-served
+ Applicable in batch systems
+ Non-preemptive
+ Basically uses single ready queue
~ Processes that are changing state from blocked to ready are
treated as newly arrived jobs, so put on the end of the queue
+ Easy to program
+ What if] process has un-proportioned compute and 1/0
bound?
Scheduling
* Scheduling in Batch Systems (continued)
— Shortest jobs first
* Applicable in batch systems
+ Non-preemptive
+ Assumes runtime in advance
* All jobs shall be available simultaneously
ae AA
a [efe}o alclo] a
® »
Dagmawi Lemma - AAU 2018
5/31/2019
17CoSc 6016 - Real Time and Embedded
systems
Scheduling
* Scheduling in Batch Systems (continued)
— Shortest remaining time next
+ Applicable in batch systems
+ Preemptive version of SJF
+ Assumes runtime in advance
Scheduling
* Scheduling in Batch Systems (continued)
1ree-level scheduling
+ Batch system allows scheduling at three different levels
2 ory andl disk (virtual memory)
~ Level 3 Running [oro 0 J
Dagmawi Lemma - AAU 2018
5/31/2019
18CoSc 6016 - Real Time and Embedded
systems
Scheduling
* Scheduling in Interactive Systems
—Round-robin scheduling
Priority scheduling
— Multiple queues
— Shortest process next
— Guaranteed scheduling
Lottery scheduling
—Fair-share scheduling
Scheduling
Scheduling in Interactive Systems (continued)
— Round-robin scheduling
* CPU is scheduled when a process
~ Useditsqumtan
Pocket
Ext
+ Whatshould be the length of the quantum?
quantum => high overhead
yantum => low response time
The other option s setting the quantum greater than the average CPL
te aoe .
peepee eee
[EHEHE} ] fHEHaHe]
wt
Dagmawi Lemma - AAU 2018
5/31/2019
19CoSc 6016 - Real Time and Embedded
systems
Scheduling
* Scheduling in Interactive Systems (continued)
— Priority scheduling
+ Fach process is assigned a priority
+ Preventing high-priority process from running
indefinitely
~ Dropping the priority at cach clock eysle
= Using variable quantum length
» Longer quantum = higher priority
» Shorter quantum = low priority
Scheduling
* Scheduling in Interactive Systems (continued)
— Multiple queues
Queue unable processes
teaders 0 en
Ponty & (Highest priority)
Proity 3
Prony 2
Proty 1 (Lowest pony)
Dagmawi Lemma - AAU 2018
5/31/2019
20CoSc 6016 - Real Time and Embedded
Systems
Scheduling
* Scheduling in Interactive Systems (continued)
— Shortest process next
* Similar to SIF
+ Estimating the process length based on past behavior
— Updating the estimated time by using weighted average
eg
aly + (-a)T,
7
Ty2tT 2
Ty4+T, 447, 2
Ty /8+ Ty B+ Ty A+ Ty 2
Scheduling
* Scheduling in Interactive Systems (continued)
— Guaranteed Scheduling
+ Distributing CPU share equally among proc
— How to use its share is upto the process
~ Ie there are m processes then each process as 1in share ofthe
cpu
+ The CPU share shall be periodically adjusted to assign
CPU share for new processes
+ What would be the problem of this approach?
(Assignment — discuss the pros and cons of this
algorithm)
Dagmawi Lemma - AAU 2018
5/31/2019
21CoSc 6016 - Real Time and Embedded
Systems
Scheduling
* Scheduling in Interactive Systems (continued)
—Lottery Scheduling
+ Each process is assigned with a unique number (lottery
ticket) and the scheduler pick either of the assigned
numbers randomly
+ Process can be assigned with more numbers to increase
their chance
+ Processes can collaborate by sharing their ticket
— Aprocess that is entering its /O block can give all its process
to other process with which it wants to collaborate
Scheduling
* Scheduling in Interactive Systems (continued)
—Fair-Share Scheduling
+ What if the number of processes initiated by different
users vary?
+ The scheduling is based on the share of users and each
user’s processes can be scheduled in the allotted CPU
share time
Dagmawi Lemma - AAU 2018
5/31/2019
22