RTOS Implementation - 2006. 12. 18. - Yeon YoonMo.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
Introduction to Assembly language
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Real-Time Library: RTX
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Mark Schaumburg.  Dash Module for Formula Car  Sample pulse from engine for RPM  Display Information  Control gui  Can network interface  Request.
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Synchronization Principles. Race Conditions Race Conditions: An Example spooler directory out in 4 7 somefile.txt list.c scores.txt Process.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
P ORTING F REE RTOS TO MCB2140 BOARD Ashwini Athalye Sravya Kusam Shruti Ponkshe.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
MicroC/OS-II Embedded Systems Design and Implementation.
Process Description and Control A process is sometimes called a task, it is a program in execution.
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
Evolution of Microcontroller Firmware Development David Benjamin.
Real Time Operating System
MSP430 Mixed Signal Microcontroller – Parte 2 Afonso Ferreira Miguel Source: slau056d – Texas instruments.
Scheduling in µC/OS-III Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Microprocessors 1 MCS-51 Interrupts.
FreeRTOS.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM511.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
MicroC/OS-II S O T R.  MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2.  It.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
More Discussions on hw5 Timer interrupts –called ticks. ISR called tick handler Kernel uses ticks for: –time keeping, incrementing the global system time.
1 Run-to-Completion Non-Preemptive Scheduler. 2 In These Notes... What is Scheduling? What is non-preemptive scheduling? Examples Run to completion (cooperative)
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Co-routine YoonMo, Yeon. Co-routine generalize subroutines multiple entry points suspending and resuming of execution at certain locations.
Outlines  Introduction  Kernel Structure  Porting.
LPC2148's RTOS Bruce Chhuon 4/10/07. What is a Real Time Operating System? ● A Real Time Operating System (RTOS) manages hardware and software resources.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Introduction In this lab , we will learn
MQX GPIO.
Interrupts and signals
CS703 – Advanced Operating Systems
Timer and Interrupts.
CS4101 嵌入式系統概論 Tasks and Scheduling
UNIT 5 TIMRERS/COUNTERS
The Arduino Microcontroller: Atmel AVR Atmega 328
Timer/Counter Modified from Dr. Lam Phung’s Slides.
Writing and Testing Your First RTOS Project with MQX
Structure of Processes
A Play Core Timer Interrupts
Module 2.2 COP4600 – Operating Systems Richard Newman
Computer System Overview
Scheduling in µC/OS-III
More examples How many processes does this piece of code create?
Synchronization Issues
TIARA Thread Management
BRX Technical Training
Lecture 9: TI MSP430 Interrupts & Low Power Modes
A Play Lab. 2 Task 8 Core Timer Interrupts
EE 472 – Embedded Systems Dr. Shwetak Patel.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
An Embedded Software Primer
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes and Process Table
Presentation transcript:

RTOS Implementation Yeon YoonMo

Focus RTOS context switch process from the bottom up used example The FreeRTOS Atmel AVR microcontroller port WinAVR development tools

The RTOS Tick time measurement is needed sleeping task : waking time blocked task : maximum waiting time tickmeasure time using a tick count variable

Tick ISR

GCC Signal Attribute interrupts written in C A compare match event on the AVR timer 1 peripheral __attribute__((signal)) modifiedregister that gets modified during the ISR is restored to its original value when the ISR exits a 'return from interrupt' instruction (RETI) to be used

code output

GCC Naked Attribute entire contextPerforming a context switch requires the entire context to be saved explicitly save all registers → some registers being saved twice The 'naked' attribute prevents the compiler generating any function entry or exit code

code output (naked)

save & restore context portSAVE_CONTEXT() portRESTORE_CONTEXT()

FreeRTOS Tick Code void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal, naked ) ); void vPortYieldFromTick( void ) __attribute__ ( ( naked ) ); void SIG_OUTPUT_COMPARE1A( void ) { vPortYieldFromTick(); asm volatile ( "reti" ); } void vPortYieldFromTick( void ) { portSAVE_CONTEXT(); vTaskIncrementTick(); vTaskSwitchContext(); portRESTORE_CONTEXT(); asm volatile ( "ret" ); }

The AVR Context

Saving the Context

Restoring the Context

Detailed Example a context switch on the AVR microcontroller two tasks low priority : task A high priority :task B

Step 1

Step 2

Step 3

Step 4 Incrementing the Tick Count after the TaskA context has been saved vTaskIncrementTick(); TaskBreadyTaskB(higher priority) to become ready to run vTaskSwitchContext() ;

Step 5

Step 6

Step 7