outlines - university of north carolina at charlottejmconrad/ecgr6185-2006... · ¡kernel structure...

36
Outlines ¡ Introduction ¡ Kernel Structure ¡ Porting

Upload: hatuong

Post on 26-Mar-2018

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Outlines

¡ Introduction¡ Kernel Structure¡ Porting

Page 2: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Introduction

¡ Embedded Systemsl Big Picturel System

¡ Hardwired¡ Real Time¡ Development tools

l Compilerl Linkerl Debuggerl Emulatorl Simulators

Page 3: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task
Page 4: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task
Page 5: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Operating System

¡ History and Purpose¡ A decent Embedded System

Page 6: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

What is a Real Time Operating System?

¡ An operating system enforcing timing constraintsl VxWorksl RTLinuxl WinCEl TinyOSl Symbianl uC/OS-II

Page 7: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Real Time System Concepts

¡ Multitasking¡ Kernel¡ Scheduling¡ Mutual Exclusion¡ Synchronization¡ Interrupt

Page 8: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Multitasking

¡ Multitaskingl A process of scheduling and switching

CPU between several tasksl Tasks

¡ Ready, Running, Waiting, ISR, Dormant

l Resource sharingl Critical section

Page 9: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Kernel

¡ A part of the multitasking system responsible for management of tasks.

¡ Context switching is the fundamental service of a kernell Can be Preemptive and Non-

Preemptive

Page 10: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Non-Preemptive Kernel

¡ The new higher priority task gains control of the CPU only when current task gives up CPU.

¡ An ISR can make a higher priority task ready to run, but ISR will eventually return to the interrupted task.l Interrupt latency is lowl Low responsiveness.

Page 11: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task
Page 12: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Preemptive Kernel

¡ System responsiveness is important.

¡ Most real time kernels are preemptive in nature.l How about uC/OS-II??

Page 13: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task
Page 14: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Function Reentrancy

Page 15: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Scheduling

¡ Priority based scheduling¡ Round Robin Schedulingl How about uC/os-II

¡ Issues:l Priority Inversion

¡ Priority inheritance is needed

Page 16: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Priority Inversion

Page 17: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Priority Inheritance

Page 18: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Mutual Exclusion

¡ Protecting shared data of processesl Disabling and enabling Interruptsl Semaphores

¡ Binary¡ Counting

¡ Deadlock- Set timeout

Page 19: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task
Page 20: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Synchronization

¡ Synchronization mechanism is used between tasks or task to ISR.

¡ Unilateral rendezvous¡ Bilateral rendezvous

Page 21: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Interrupts

¡ An interrupt is a hardware mechanism to inform CPU that an asynchronous event has happen.

¡ Interrupt response¡ Interrupt Recovery¡ Interrupt Latency¡ NMI

Page 22: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Interrupt Latency

¡ To manipulate critical sections Interrupts are disabled.l longer Interrupts are disabled, higher is

Interrupt Latencyl Interrupt Latency is given by:

Page 23: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Interrupt Response

¡ It is the time between the reception of the interrupt and start of the user code that handles the interrupt.l It is given by:

Page 24: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Interrupt Response(contd)

¡ For Preemptive Kernel, an extra execution time of kernel ISR entry Function.

Page 25: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Non-Preemptive Kernel

Page 26: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Pre-emptive Kernel

Page 27: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Tasks

¡ Small piece of independent code or ‘Threads’.

¡ OS maintains information about each task---called as Task’s context.

¡ Uses a data structure for keeping track of tasks…called as Task control Block.

Page 28: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Example-code

Page 29: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Creating a Task

Page 30: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Clock Tick

¡ It’s a special interrupt that occurs periodically.

¡ It is triggered by timer Interrupt.¡ It keeps track of time delays and

Timeouts.l Should occur between 10-100 times

per second.l Defined by function OSTimeTick().

Page 31: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task
Page 32: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Delaying a task, OSTimeDly()

¡ It allows the calling task to delay itself for a user specified number of clock ticks.

Page 33: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

OSTimeDlyHMSM()

¡ Specifying time in Hours, minutes, seconds and miliseconds.

¡ Resuming a delayed task: OSTimeDlyResume().

Page 34: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Boot Strap Loader

¡ A small program that loads the operating system into the computer’s memory when the system is booted and also starts the operating system

Page 35: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

Porting UC/OS-II on Renesas

¡ Loading uC/OS-II¡ Initializing the hardware¡ Building the application

Page 36: Outlines - University of North Carolina at Charlottejmconrad/ECGR6185-2006... · ¡Kernel Structure ¡Porting ... ¡Uses a data structure for keeping track of tasks…called as Task

UCOS-II Hardware/Software Arch.