SlideShare a Scribd company logo
Department of Information Technology
Session 2018-19
Eight Semester
Subject Incharge: Prof. Sarvesh Warjurkar
1
Department of Information Technology
Embedded Systems
UNIT –III
Syllabus
UNIT –III
• Architecture of the kernel, Tasks and Task Scheduler,
Threads , ISR, Multiprocessing and Multitasking,
Semaphore and Shared Data, Mutex, Mailboxes,
Message Queue, Events, Pipes, Timers, Signals,
Memory Management, RTOS Task Scheduling
Models, Interrupt Latency, Response of the task, OS
Security issues, Introduction to Android.
Department of Information Technology 2
Windows Architecture
hardware interfaces (buses, I/O devices, interrupts,
interval timers, DMA, memory cache control, etc., etc.)
System Service Dispatcher
Task Manager
Explorer
SvcHost.Exe
WinMgt.Exe
SpoolSv.Exe
Service
Control Mgr.
LSASS
Object
Mgr.
Windows
USER,
GDI
File
System
Cache
I/O Mgr
Environment
Subsystems
User
Application
Subsystem DLLs
System Processes Services Applications
System
Threads
User
Mode
Kernel
Mode
NTDLL.DLL
Device &
File Sys.
Drivers
WinLogon
Session Manager
Services.Exe POSIX
Windows DLLs
Plug
and
Play
Mgr.
Power
Mgr.
Security
Reference
Monitor
Virtual
Memory
Processes
&
Threads
Local
Procedure
Call
Graphics
Drivers
Kernel
Hardware Abstraction Layer (HAL)
(kernel mode callable interfaces)
Configura-
tion
Mgr
(registry)
OS/2
Windows
Copyright Microsoft Corporation
Kernel-mode Architecture of Windows
Copyright Microsoft Corporation
NT API stubs (wrap sysenter) -- system library (ntdll.dll)
user
mode
kernel
mode
NTOS executive layer
Trap/Exception/Interrupt Dispatch
CPU mgmt: scheduling, synchr, ISRs/DPCs/APCs
Drivers
Devices, Filters,
Volumes,
Networking,
Graphics
Hardware Abstraction Layer (HAL): BIOS/chipset details
firmware/
hardware CPU, MMU, APIC, BIOS/ACPI, memory, devices
NTOS
kernel
layer
Caching Mgr
Security
Procs/Threads
Virtual Memory
IPC
glue
I/O
Object Mgr
Registry
Copyright Microsoft Corporation
Real-Time System
• Real-time systems have been defined as: “those systems in
which the correctness of the system depends not only on the
logical result of the computation, but also on the time at
which the results are produced“
• Correct function at correct time
• Usually embedded
• Deadlines
– Hard real-time systems
– Soft real-time systems
Real-Time System continue
• Soft RTS: meet timing constraints most of the time, it is not
necessary that every time constraint be met. Some deadline
miss is tolerated.
• Hard RTS: meet all time constraints exactly, Every resource
management system must work in the correct order to meet
time constraints. No deadline miss is allowed.
Tasks Categories
• Invocation
– Periodic (time-triggered)
– Aperiodic (event-triggered)
• Creation
– Static
– Dynamic
• Multi-Tasking System
– Preemptive: higher-priority process taking control
of the processor from a lower-priority
– Non-Preemptive : Each task can control the CPU
for as long as it needs it.
Why we need scheduling ?!
• each computation (task) we want to execute needs resources
• resources: processor, memory segments, communication, I/O
devices etc.)
• the computation must be executed in particular order
(relative to each other and/or relative to time)
• the possible ordering is either completely or statistically a
priori known (described)
• scheduling: assignment of processor to computations;
• allocation: assignment of other resources to computations;
• Job (Jij): Unit of work, scheduled and executed by system. Jobs
repeated at regular or semi-regular intervals modeled as
periodic
• Task (Ti): Set of related jobs.
• Jobs scheduled and allocated resources based on a set of
scheduling algorithms and access control protocols.
• Scheduler: Module implementing scheduling algorithms
• Schedule: assignment of all jobs to available processors,
produced by scheduler.
• Valid schedule: All jobs meet their deadline
• Clock-driven scheduling vs Event(priority)-driven scheduling
• Fixed Priority vs Dynamic Priority assignment
Real-time Scheduling Taxonomy
Scheduling Periodic Tasks
 In hard real-time systems, set of tasks are known apriori
 Task Ti is a series of periodic Jobs Jij. Each task has the
following parameters
 ti - period, minimum interrelease interval between jobs in
Task Ti.
 ci - maximum execution time for jobs in task Ti.
 rij - release time of the jth Job in Task i (Jij in Ti).
 i - phase of Task Ti, equal to ri1.
 ui - utilization of Task Ti = ci / ti
 In addition the following parameters apply to a set of
tasks
 H - Hyperperiod = Least Common Multiple of pi for all i: H =
lcm(pi), for all i.
 U - Total utilization = Sum over all ui.
Real-Time Scheduling Algorithms
Fixed Priority Algorithms Dynamic Priority Algorithms Hybrid algorithms
Rate
Monotonic
scheduling
Deadline
Monotonic
scheduling
Earliest
Deadline
First
Least Laxity
First
Maximum
Urgency
First
Scheduling Algorithm
Static vs. Dynamic
 Static Scheduling:
All scheduling decisions at compile time.
 Temporal task structure fixed.
 Precedence and mutual exclusion satisfied by the
schedule (implicit synchronization).
 One solution is sufficient.
 Any solution is a sufficient schedulability test.
 Benefits
 Simplicity
Scheduling Algorithm
Static vs. Dynamic
• Dynamic Scheduling:
– All scheduling decisions at run time.
• Based upon set of ready tasks.
• Mutual exclusion and synchronization enforced by
explicit synchronization constructs.
– Benefits
• Flexibility.
• Only actually used resources are claimed.
– Disadvantages
• Guarantees difficult to support
• Computational resources required for scheduling
Scheduling Algorithm
Preemptive vs. Nonpreemptive
• Preemptive Scheduling:
– Event driven.
• Each event causes interruption of running tasks.
• Choice of running tasks reconsidered after each
interruption.
– Benefits:
• Can minimize response time to events.
– Disadvantages:
• Requires considerable computational resources for
scheduling
• Nonpreemptive Scheduling:
– Tasks remain active till completion
• Scheduling decisions only made after task completion.
– Benefits:
• Reasonable when
task execution times ~= task switching times.
• Less computational resources needed for scheduling
– Disadvantages:
• Can leads to starvation (not met the deadline)
especially for those real time tasks ( or high priority
tasks).
Scheduling Algorithm
Preemptive vs. Nonpreemptive
Rate Monotonic scheduling
• Priority assignment based on rates of tasks
• Higher rate task assigned higher priority
• Schedulable utilization = 0.693 (Liu and Leyland)
Where Ci is the computation time, and Ti is the release period
• If U < 0.693, schedulability is guaranteed
• Tasks may be schedulable even if U > 0.693
RM example
Period
Execution Time
Process
8
1
P1
5
2
P2
10
2
P3
The utilization will be:
The theoretical limit for processes, under which we can conclude that
the system is schedulable is:
Since the system is schedulable!
Deadline Monotonic scheduling
• Priority assignment based on relative deadlines of tasks
• Shorter the relative deadline, higher the priority
Earliest Deadline First (EDF)
• Dynamic Priority Scheduling
• Priorities are assigned according to deadlines:
– Earlier deadline, higher priority
– Later deadline, lower priority
• The first and the most effectively widely used dynamic
priority-driven scheduling algorithm.
• Effective for both preemptive and non-preemptive scheduling.
Two Periodic Tasks
• Execution profile of two periodic tasks
– Process A
• Arrives 0 20 40 …
• Execution Time 10 10 10 …
• End by 20 40 60 …
– Process B
• Arrives 0 50 100 …
• Execution Time 25 25 25 …
• End by 50 100 150 …
• Question: Is there enough time for the execution of two periodic
tasks?
Five Periodic Tasks
• Execution profile of five periodic tasks
Process Arrival Time
Execution
Time
Starting
Deadline
A 10 20 110
B 20 20 20
C 40 20 50
D 50 20 90
E 60 20 70
Least Laxity First (LLF)
• Dynamic preemptive scheduling with dynamic priorities
• Laxity : The difference between the time until a tasks
completion deadline and its remaining processing time
requirement.
• a laxity is assigned to each task in the system and minimum
laxity tasks are executed first.
• Larger overhead than EDF due to higher number of context
switches caused by laxity changes at run time
– Less studies than EDF due to this reason
Least Laxity First Cont
• LLF considers the execution time of a task, which EDF does
not.
• LLF assigns higher priority to a task with the least laxity.
• A task with zero laxity must be scheduled right away and
executed without preemption or it will fail to meet its
deadline.
• The negative laxity indicates that the task will miss the
deadline, no matter when it is picked up for execution.
Least Laxity First Example
Maximum Urgency First Algorithm
• This algorithm is a combination of fixed and dynamic priority
scheduling, also called mixed priority scheduling.
• With this algorithm, each task is given an urgency which is
defined as a combination of two fixed priorities (criticality and
user priority) and a dynamic priority that is inversely
proportional to the laxity.
• The MUF algorithm assigns priorities in two phases
• Phase One concerns the assignment of static priorities to
tasks
• Phase Two deals with the run-time behavior of the MUF
scheduler
The first phase consists of these steps :
1) It sorts the tasks from the shortest period to the longest
period. Then it defines the critical set as the first N tasks such
that the total CPU load factor does not exceed 100%. These
tasks are guaranteed not to fail even during a transient
overload.
2) All tasks in the critical set are assigned high criticality. The
remaining tasks are considered to have low criticality.
3) Every task in the system is assigned an optional unique user
priority
Maximum Urgency First Algorithm phase 1
 In the second phase, the MUF scheduler follows an algorithm
to select a task for execution.
 This algorithm is executed whenever a new task is arrived to
the ready queue.
 The algorithm is as follows:
1) If there is only one highly critical task, pick it up and execute it.
2) If there are more than one highly critical task, select the one
with the highest dynamic priority. Here, the task with the least
laxity is considered to be the one with the highest priority.
3) If there is more than one task with the same laxity, select the
one with the highest user priority.
Maximum Urgency First Algorithm phase 2
Questions ??
Referances
• http://en.wikipedia.org/wiki/RTOS#Scheduling
• http://en.wikipedia.org/wiki/Rate-
monotonic_scheduling
• http://www.netrino.com/Publications/Glossar
y/RMA.php
What is real-time?
• Correctness of output depends on timing as
well as result
• Hard vs. soft real-time
• Are Windows and Linux real-time?
In a Hard RTOS…
• Thread priorities can be set by the client
• Threads always run according to priority
• Kernel must be preemptible or bounded
• Interrupts must be bounded
• No virtual memory
In a Soft RTOS…
• Like a hard RTOS:
– Priority scheduling, with no degradation
– Low dispatch latency
– Preemptible system calls
– No virtual memory (or allow pages to be locked)
• Linux: guarantees about relative timing of
tasks, no guarantees about syscalls
Basic RTOS References
• http://www.dedicated-
systems.com/encyc/publications/faq/rtfaq.htm
• http://www.steroidmicros.com/mtkernel.html
• http://www.qnx.com/developer/articles/dec1200b/
• Silberschatz and Galvin, Operating System Concepts.
Example RTOS’s
• Micrium c-OS II
http://www.ucos-ii.com/
• AvrX
http://www.barello.net/avrx/
• RTLinux
http://fsmlabs.com/developers/man_pages
/
• QNX Neutrino
http://www.qnx.com/
c-OS II
• Features
• Sample main() function
• Calling OSTaskCreate()
• Creating a task
C-OS II
• Ports to the AVR, ATmega103
• Comes with book: Micro-C OS: The Real-Time
Kernel by Jean Labrosse ($52)
• Features
– Semaphores and mutexes
– Event flags
– Message mailboxes and queues
– Task management (priority settings)
void main (void) {
/* Perform Initializations */
...
OSInit();
...
/* Create at least one task by
calling OSTaskCreate() */
OSStart();
}
C-OS Sample Code
INT8U OSTaskCreate (
void (*task)(void *pd),
void *pdata,
OS_STK *ptos,
INT8U prio);
C-OS Sample Code
void UserTask (void *pdata) {
pdata = pdata;
/* User task initialization */
while (1) {
/* User code goes here */
/* You MUST invoke a service
provided by µC/OS-II to: */
/* ... a) Delay the task for ‘n’
ticks */
/* ... b) Wait on a semaphore */
/* ... c) Wait for a message from a
task or an ISR */
/* ... d) Suspend execution of this
C-OS Sample Code
AvrX
• Specs
• Internal structures
• Sample code: task creation
AvrX Specs
• Code size: 500-700 words (2x bigger with
debug monitor)
• 16 priority levels
• Overhead: 20% of CPU
• Version 2.3 for assembly code, 2.6 for C
interface
AvrX Internals
• Routine _Prolog saves state, _Epilog
restores it
• Task info stored in a PID block and a task
control block
• Modules for timers, semaphores, etc.
An AvrX Task
AVRX_TASKDEF(myTask, 10, 3){
TimerControlBlock MyTimer;
while (1)
{
AvrXDelay(&MyTimer, 10);
// 10ms delay
AvrXSetSemaphore(&Timeout)
;
}}
Arguments: task name, additional stack bytes, priority
RTLinux
• Additional layer between Linux kernel and
hardware
• Worst-case dispatch latency on x86: 15 s
RTLinux: Basic Idea
QNX Neutrino
• Powerful hard RTOS
• Includes GUI
• Memory protection and fault tolerance
Summary
• Hard real-time, soft real-time
• Characteristics of an RTOS
• Example RTOS’s
– Specs
– Internal structure/ideas
– Sample code

More Related Content

Similar to ESC UNIT 3.ppt

Real time system tsp
Real time system tspReal time system tsp
Real time system tsp
Pradeep Kumar TS
 
Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
Praveen Penumathsa
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
knowdiff
 
Event Scheduling
Event SchedulingEvent Scheduling
Event Scheduling
Ayesha Kanwal
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
ansariparveen06
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
ansariparveen06
 
Task assignment and scheduling
Task assignment and schedulingTask assignment and scheduling
Task assignment and scheduling
RajalakshmiSermadurai
 
Section05 scheduling
Section05 schedulingSection05 scheduling
Section05 scheduling
Venkatesh Chowdary Nagilla
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.
Shreya Kumar
 
Scheduling and Scheduler's Process and Premptive
Scheduling and Scheduler's Process and PremptiveScheduling and Scheduler's Process and Premptive
Scheduling and Scheduler's Process and Premptive
choudharyxdevansh
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
Sundaresan Sundar
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
rohassanie
 
Embedded system scheduling Algorithm .pptx
Embedded system scheduling Algorithm .pptxEmbedded system scheduling Algorithm .pptx
Embedded system scheduling Algorithm .pptx
Swati Shekapure
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
amadayshwan
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
AnitaSofiaKeyser
 
AugCog Overview
AugCog OverviewAugCog Overview
AugCog Overview
Polly Tremoulet
 
Scheduling in Cloud Computing
Scheduling in Cloud ComputingScheduling in Cloud Computing
Scheduling in Cloud Computing
Hitesh Mohapatra
 
Rt kernel-prn
Rt kernel-prnRt kernel-prn
Rt kernel-prn
Arun Pratap Singh
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
Farhanahmad540205
 
multiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.pptmultiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.ppt
naghamallella
 

Similar to ESC UNIT 3.ppt (20)

Real time system tsp
Real time system tspReal time system tsp
Real time system tsp
 
Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
 
Event Scheduling
Event SchedulingEvent Scheduling
Event Scheduling
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
 
Task assignment and scheduling
Task assignment and schedulingTask assignment and scheduling
Task assignment and scheduling
 
Section05 scheduling
Section05 schedulingSection05 scheduling
Section05 scheduling
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.
 
Scheduling and Scheduler's Process and Premptive
Scheduling and Scheduler's Process and PremptiveScheduling and Scheduler's Process and Premptive
Scheduling and Scheduler's Process and Premptive
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Embedded system scheduling Algorithm .pptx
Embedded system scheduling Algorithm .pptxEmbedded system scheduling Algorithm .pptx
Embedded system scheduling Algorithm .pptx
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
 
AugCog Overview
AugCog OverviewAugCog Overview
AugCog Overview
 
Scheduling in Cloud Computing
Scheduling in Cloud ComputingScheduling in Cloud Computing
Scheduling in Cloud Computing
 
Rt kernel-prn
Rt kernel-prnRt kernel-prn
Rt kernel-prn
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
 
multiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.pptmultiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.ppt
 

Recently uploaded

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 

ESC UNIT 3.ppt

  • 1. Department of Information Technology Session 2018-19 Eight Semester Subject Incharge: Prof. Sarvesh Warjurkar 1 Department of Information Technology Embedded Systems UNIT –III
  • 2. Syllabus UNIT –III • Architecture of the kernel, Tasks and Task Scheduler, Threads , ISR, Multiprocessing and Multitasking, Semaphore and Shared Data, Mutex, Mailboxes, Message Queue, Events, Pipes, Timers, Signals, Memory Management, RTOS Task Scheduling Models, Interrupt Latency, Response of the task, OS Security issues, Introduction to Android. Department of Information Technology 2
  • 3. Windows Architecture hardware interfaces (buses, I/O devices, interrupts, interval timers, DMA, memory cache control, etc., etc.) System Service Dispatcher Task Manager Explorer SvcHost.Exe WinMgt.Exe SpoolSv.Exe Service Control Mgr. LSASS Object Mgr. Windows USER, GDI File System Cache I/O Mgr Environment Subsystems User Application Subsystem DLLs System Processes Services Applications System Threads User Mode Kernel Mode NTDLL.DLL Device & File Sys. Drivers WinLogon Session Manager Services.Exe POSIX Windows DLLs Plug and Play Mgr. Power Mgr. Security Reference Monitor Virtual Memory Processes & Threads Local Procedure Call Graphics Drivers Kernel Hardware Abstraction Layer (HAL) (kernel mode callable interfaces) Configura- tion Mgr (registry) OS/2 Windows Copyright Microsoft Corporation
  • 4. Kernel-mode Architecture of Windows Copyright Microsoft Corporation NT API stubs (wrap sysenter) -- system library (ntdll.dll) user mode kernel mode NTOS executive layer Trap/Exception/Interrupt Dispatch CPU mgmt: scheduling, synchr, ISRs/DPCs/APCs Drivers Devices, Filters, Volumes, Networking, Graphics Hardware Abstraction Layer (HAL): BIOS/chipset details firmware/ hardware CPU, MMU, APIC, BIOS/ACPI, memory, devices NTOS kernel layer Caching Mgr Security Procs/Threads Virtual Memory IPC glue I/O Object Mgr Registry Copyright Microsoft Corporation
  • 5. Real-Time System • Real-time systems have been defined as: “those systems in which the correctness of the system depends not only on the logical result of the computation, but also on the time at which the results are produced“ • Correct function at correct time • Usually embedded • Deadlines – Hard real-time systems – Soft real-time systems
  • 6. Real-Time System continue • Soft RTS: meet timing constraints most of the time, it is not necessary that every time constraint be met. Some deadline miss is tolerated. • Hard RTS: meet all time constraints exactly, Every resource management system must work in the correct order to meet time constraints. No deadline miss is allowed.
  • 7. Tasks Categories • Invocation – Periodic (time-triggered) – Aperiodic (event-triggered) • Creation – Static – Dynamic • Multi-Tasking System – Preemptive: higher-priority process taking control of the processor from a lower-priority – Non-Preemptive : Each task can control the CPU for as long as it needs it.
  • 8. Why we need scheduling ?! • each computation (task) we want to execute needs resources • resources: processor, memory segments, communication, I/O devices etc.) • the computation must be executed in particular order (relative to each other and/or relative to time) • the possible ordering is either completely or statistically a priori known (described) • scheduling: assignment of processor to computations; • allocation: assignment of other resources to computations;
  • 9. • Job (Jij): Unit of work, scheduled and executed by system. Jobs repeated at regular or semi-regular intervals modeled as periodic • Task (Ti): Set of related jobs. • Jobs scheduled and allocated resources based on a set of scheduling algorithms and access control protocols. • Scheduler: Module implementing scheduling algorithms • Schedule: assignment of all jobs to available processors, produced by scheduler. • Valid schedule: All jobs meet their deadline • Clock-driven scheduling vs Event(priority)-driven scheduling • Fixed Priority vs Dynamic Priority assignment Real-time Scheduling Taxonomy
  • 10. Scheduling Periodic Tasks  In hard real-time systems, set of tasks are known apriori  Task Ti is a series of periodic Jobs Jij. Each task has the following parameters  ti - period, minimum interrelease interval between jobs in Task Ti.  ci - maximum execution time for jobs in task Ti.  rij - release time of the jth Job in Task i (Jij in Ti).  i - phase of Task Ti, equal to ri1.  ui - utilization of Task Ti = ci / ti  In addition the following parameters apply to a set of tasks  H - Hyperperiod = Least Common Multiple of pi for all i: H = lcm(pi), for all i.  U - Total utilization = Sum over all ui.
  • 11. Real-Time Scheduling Algorithms Fixed Priority Algorithms Dynamic Priority Algorithms Hybrid algorithms Rate Monotonic scheduling Deadline Monotonic scheduling Earliest Deadline First Least Laxity First Maximum Urgency First
  • 12. Scheduling Algorithm Static vs. Dynamic  Static Scheduling: All scheduling decisions at compile time.  Temporal task structure fixed.  Precedence and mutual exclusion satisfied by the schedule (implicit synchronization).  One solution is sufficient.  Any solution is a sufficient schedulability test.  Benefits  Simplicity
  • 13. Scheduling Algorithm Static vs. Dynamic • Dynamic Scheduling: – All scheduling decisions at run time. • Based upon set of ready tasks. • Mutual exclusion and synchronization enforced by explicit synchronization constructs. – Benefits • Flexibility. • Only actually used resources are claimed. – Disadvantages • Guarantees difficult to support • Computational resources required for scheduling
  • 14. Scheduling Algorithm Preemptive vs. Nonpreemptive • Preemptive Scheduling: – Event driven. • Each event causes interruption of running tasks. • Choice of running tasks reconsidered after each interruption. – Benefits: • Can minimize response time to events. – Disadvantages: • Requires considerable computational resources for scheduling
  • 15. • Nonpreemptive Scheduling: – Tasks remain active till completion • Scheduling decisions only made after task completion. – Benefits: • Reasonable when task execution times ~= task switching times. • Less computational resources needed for scheduling – Disadvantages: • Can leads to starvation (not met the deadline) especially for those real time tasks ( or high priority tasks). Scheduling Algorithm Preemptive vs. Nonpreemptive
  • 16. Rate Monotonic scheduling • Priority assignment based on rates of tasks • Higher rate task assigned higher priority • Schedulable utilization = 0.693 (Liu and Leyland) Where Ci is the computation time, and Ti is the release period • If U < 0.693, schedulability is guaranteed • Tasks may be schedulable even if U > 0.693
  • 17. RM example Period Execution Time Process 8 1 P1 5 2 P2 10 2 P3 The utilization will be: The theoretical limit for processes, under which we can conclude that the system is schedulable is: Since the system is schedulable!
  • 18. Deadline Monotonic scheduling • Priority assignment based on relative deadlines of tasks • Shorter the relative deadline, higher the priority
  • 19. Earliest Deadline First (EDF) • Dynamic Priority Scheduling • Priorities are assigned according to deadlines: – Earlier deadline, higher priority – Later deadline, lower priority • The first and the most effectively widely used dynamic priority-driven scheduling algorithm. • Effective for both preemptive and non-preemptive scheduling.
  • 20. Two Periodic Tasks • Execution profile of two periodic tasks – Process A • Arrives 0 20 40 … • Execution Time 10 10 10 … • End by 20 40 60 … – Process B • Arrives 0 50 100 … • Execution Time 25 25 25 … • End by 50 100 150 … • Question: Is there enough time for the execution of two periodic tasks?
  • 21.
  • 22. Five Periodic Tasks • Execution profile of five periodic tasks Process Arrival Time Execution Time Starting Deadline A 10 20 110 B 20 20 20 C 40 20 50 D 50 20 90 E 60 20 70
  • 23.
  • 24. Least Laxity First (LLF) • Dynamic preemptive scheduling with dynamic priorities • Laxity : The difference between the time until a tasks completion deadline and its remaining processing time requirement. • a laxity is assigned to each task in the system and minimum laxity tasks are executed first. • Larger overhead than EDF due to higher number of context switches caused by laxity changes at run time – Less studies than EDF due to this reason
  • 25. Least Laxity First Cont • LLF considers the execution time of a task, which EDF does not. • LLF assigns higher priority to a task with the least laxity. • A task with zero laxity must be scheduled right away and executed without preemption or it will fail to meet its deadline. • The negative laxity indicates that the task will miss the deadline, no matter when it is picked up for execution.
  • 27. Maximum Urgency First Algorithm • This algorithm is a combination of fixed and dynamic priority scheduling, also called mixed priority scheduling. • With this algorithm, each task is given an urgency which is defined as a combination of two fixed priorities (criticality and user priority) and a dynamic priority that is inversely proportional to the laxity. • The MUF algorithm assigns priorities in two phases • Phase One concerns the assignment of static priorities to tasks • Phase Two deals with the run-time behavior of the MUF scheduler
  • 28. The first phase consists of these steps : 1) It sorts the tasks from the shortest period to the longest period. Then it defines the critical set as the first N tasks such that the total CPU load factor does not exceed 100%. These tasks are guaranteed not to fail even during a transient overload. 2) All tasks in the critical set are assigned high criticality. The remaining tasks are considered to have low criticality. 3) Every task in the system is assigned an optional unique user priority Maximum Urgency First Algorithm phase 1
  • 29.  In the second phase, the MUF scheduler follows an algorithm to select a task for execution.  This algorithm is executed whenever a new task is arrived to the ready queue.  The algorithm is as follows: 1) If there is only one highly critical task, pick it up and execute it. 2) If there are more than one highly critical task, select the one with the highest dynamic priority. Here, the task with the least laxity is considered to be the one with the highest priority. 3) If there is more than one task with the same laxity, select the one with the highest user priority. Maximum Urgency First Algorithm phase 2
  • 32. What is real-time? • Correctness of output depends on timing as well as result • Hard vs. soft real-time • Are Windows and Linux real-time?
  • 33. In a Hard RTOS… • Thread priorities can be set by the client • Threads always run according to priority • Kernel must be preemptible or bounded • Interrupts must be bounded • No virtual memory
  • 34. In a Soft RTOS… • Like a hard RTOS: – Priority scheduling, with no degradation – Low dispatch latency – Preemptible system calls – No virtual memory (or allow pages to be locked) • Linux: guarantees about relative timing of tasks, no guarantees about syscalls
  • 35. Basic RTOS References • http://www.dedicated- systems.com/encyc/publications/faq/rtfaq.htm • http://www.steroidmicros.com/mtkernel.html • http://www.qnx.com/developer/articles/dec1200b/ • Silberschatz and Galvin, Operating System Concepts.
  • 36. Example RTOS’s • Micrium c-OS II http://www.ucos-ii.com/ • AvrX http://www.barello.net/avrx/ • RTLinux http://fsmlabs.com/developers/man_pages / • QNX Neutrino http://www.qnx.com/
  • 37. c-OS II • Features • Sample main() function • Calling OSTaskCreate() • Creating a task
  • 38. C-OS II • Ports to the AVR, ATmega103 • Comes with book: Micro-C OS: The Real-Time Kernel by Jean Labrosse ($52) • Features – Semaphores and mutexes – Event flags – Message mailboxes and queues – Task management (priority settings)
  • 39. void main (void) { /* Perform Initializations */ ... OSInit(); ... /* Create at least one task by calling OSTaskCreate() */ OSStart(); } C-OS Sample Code
  • 40. INT8U OSTaskCreate ( void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio); C-OS Sample Code
  • 41. void UserTask (void *pdata) { pdata = pdata; /* User task initialization */ while (1) { /* User code goes here */ /* You MUST invoke a service provided by µC/OS-II to: */ /* ... a) Delay the task for ‘n’ ticks */ /* ... b) Wait on a semaphore */ /* ... c) Wait for a message from a task or an ISR */ /* ... d) Suspend execution of this C-OS Sample Code
  • 42. AvrX • Specs • Internal structures • Sample code: task creation
  • 43. AvrX Specs • Code size: 500-700 words (2x bigger with debug monitor) • 16 priority levels • Overhead: 20% of CPU • Version 2.3 for assembly code, 2.6 for C interface
  • 44. AvrX Internals • Routine _Prolog saves state, _Epilog restores it • Task info stored in a PID block and a task control block • Modules for timers, semaphores, etc.
  • 45. An AvrX Task AVRX_TASKDEF(myTask, 10, 3){ TimerControlBlock MyTimer; while (1) { AvrXDelay(&MyTimer, 10); // 10ms delay AvrXSetSemaphore(&Timeout) ; }} Arguments: task name, additional stack bytes, priority
  • 46. RTLinux • Additional layer between Linux kernel and hardware • Worst-case dispatch latency on x86: 15 s
  • 48. QNX Neutrino • Powerful hard RTOS • Includes GUI • Memory protection and fault tolerance
  • 49. Summary • Hard real-time, soft real-time • Characteristics of an RTOS • Example RTOS’s – Specs – Internal structure/ideas – Sample code