Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using ThreadX ® and IAR Embedded Workbench on the.

Slides:



Advertisements
Similar presentations
Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
Advertisements

Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Processes CSCI 444/544 Operating Systems Fall 2008.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
3.5 Interprocess Communication
Threads CSCI 444/544 Operating Systems Fall 2008.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Chapter 6 Real-Time Embedded Multithreading The Thread – The Essential Component.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Performance Evaluation of Real-Time Operating Systems
Outline Introduction to MQX Initializing and starting MQX
July, Getting started with IAR PowerPac for MSP430 Mats Pettersson, IAR Systems Fast… Everything can be found on Evaluation and kickstart.
Introduction to Embedded Systems
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Debugging on RX with IAR Embedded Workbench.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L13B David Hedley, Applications Engineer Advanced.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 9L02I Software Development with an Open Source.
Scheduling policies for real- time embedded systems.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
1 RTOS Design Some of the content of this set of slides is taken from the documentation existing on the FreeRTOS website
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Debugging on RX with IAR Embedded Workbench Micael.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
What Every Developer Should Know about the Kernel Dr. Michael L. Collard 1.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
Processes CSCI 4534 Chapter 4. Introduction Early computer systems allowed one program to be executed at a time –The program had complete control of the.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L05I Advanced Debugging on the RX600 Fatih Peksenar.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Department of Computer Science and Software Engineering
Processes & Threads Introduction to Operating Systems: Module 5.
ID 721C: Using an RTOS in SH Based Product Development John Carbone VP, Marketing 13 October 2010 Version: 3.2 Express Logic, Inc.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Cs431-cotter1 Processes and Threads Tanenbaum 2.1, 2.2 Crowley Chapters 3, 5 Stallings Chapter 3, 4 Silberschaz & Galvin 3, 4.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Chapter 3 RTOS Concepts And Definitions Department of Computer Science Hsu Hao Chen Professor Hsung-Pin Chang.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Software Building Blocks for Faster.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Processes and threads.
Process concept.
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Chapter 3: Process Concept
Topics Covered What is Real Time Operating System (RTOS)
OPERATING SYSTEMS CS3502 Fall 2017
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 2 Scheduling.
Chapter 6: CPU Scheduling
Lecture 2: Processes Part 1
Chapter 6: CPU Scheduling
Computer System Overview
Introduction What is an operating system bootstrap
Lecture Topics: 11/1 General Operating System Concepts Processes
CPU scheduling decisions may take place when a process:
Processes Hank Levy 1.
CS510 Operating System Foundations
Processes Hank Levy 1.
CS703 – Advanced Operating Systems
Chapter 3: Process Management
Presentation transcript:

Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using ThreadX ® and IAR Embedded Workbench on the Renesas RX Processor John Carbone, VP Marketing, Express Logic, Inc. Sean Prestridge, Field Applications Engineer, IAR 9C08I

© 2012 Renesas Electronics America Inc. All rights reserved.2 Part I - Key Concepts ThreadX RTOS – Threads and Priorities – Context Switching – Types of Scheduling – Multithreading – Preemptive Scheduling – Preemption-Threshold™ Scheduling IAR Embedded Workbench IDE – Compiler – Debugger – RTOS Awareness – Macros – External Tools Agenda

© 2012 Renesas Electronics America Inc. All rights reserved.3 Part II – An Example Structure of the Example – 4 Threads – Message-Passing Setting Priorities – Equal Round-Robin Scheduling – Unique Preemptive Scheduling Preemption-Threshold Scheduling Assessing The Results Using TraceX Summary and Conclusion Q/A For More Information Agenda (continued)

© 2012 Renesas Electronics America Inc. All rights reserved.4 Presenter: John A. Carbone VP, Marketing, Express Logic, Inc. Responsible for product and corporate marketing, Renesas partner relationship, technical articles, and technical training. Presenter at Renesas DevCon 2008, 2010, and various industry conferences Authored technical papers on real-time multithreading, certification, and measurement of real-time performance PREVIOUS EXPERIENCE: VP, Marketing at Green Hills Software Embedded developer and FAE Member of the IEEE BA, Mathematics, Boston College

© 2012 Renesas Electronics America Inc. All rights reserved.5 Shawn A. Prestridge Senior Field Applications Engineer Responsible for Embedded Workbench training Develops applications for many different boards Develops applications for middleware such as: – RTOS – GUI – Projects as examples and for customers PREVIOUS EXPERIENCE: Embedded hardware/software engineer for Texas instruments. Contractual-based development for Ministry of Software Degree work from Southern Methodist University: BSEE, BS Mathematics, MSEE, MS Software Engineering, PhD in EE

© 2012 Renesas Electronics America Inc. All rights reserved.6 ThreadX is Express Logic’s small, fast, RTOS for hard real-time applications Small: Under 3KB for RX Fast: Under 1.0us context switch 96MHz Easy-to-Use: Intuitive API, Textbook, User Guide, Training and Commercial Support Full source code, Royalty-free ThreadX Services Scheduling Interrupt Servicing Threads Timers Queues Semaphores Mutexes Event Flag Groups Block/Byte Memory Pools ThreadX

© 2012 Renesas Electronics America Inc. All rights reserved.7 Support for all RX devices Hardware FPU support ROPI (position independent code/data) support ThreadX RTOS awerness Renesas ABI (Application Binary Interface) compliant  Link compatible  Renesas libraries can be linked with EW  RPDL compliant (Renesas Peripheral Driver Library) IAR Embedded Workbench for RX

© 2012 Renesas Electronics America Inc. All rights reserved.8 Ready-made example projects demonstrating the different peripheral’s of the MCU Most popular boards supported Kickstart version of EW included in Renesas Starterkits Best optimized RX compiler! IAR Embedded Workbench for RX

© 2012 Renesas Electronics America Inc. All rights reserved.9 ThreadX is Integrated for use with IAR Embedded Workbench for RX (EWRX) Delivered as EWRX Projects (Library Build and Demo App) EWRX RTOS Awareness for ThreadX EWRX ThreadX Execution Profiling EWRX Launch of TraceX Analysis Tool Build Library Set compile options – Optimization Level – Debug symbols – Event Trace (see TraceX later) – Execution Profiling Link with Application Any C/C++ code Also link initialization code (provided with ThreadX) Download Run Debug Optimize Using ThreadX and IAR EWRX

© 2012 Renesas Electronics America Inc. All rights reserved.10 Threads What is a thread? – Semi-independent program segment – Share same memory space – Run “concurrently” How are threads used? – Modularize a program – Minimize stalls Thread Services – Create, Suspend, Relinquish, Terminate, Exit, Prioritize Thread States – READY, RUNNING, SUSPENDED, TERMINATED Thread Priorities Often 0-n, with 0 highest Dynamic or Static Equal priorities – Multiple threads at same priority Unique priorities – Each thread has unique priority Threads and Priorities Process Thread … Process memory space Highest Lowest Priority … n

© 2012 Renesas Electronics America Inc. All rights reserved.11 Context Switch Thread Context Information critical to thread’s operation Register Contents, Program Counter, Stack Pointer Saved when thread is preempted Restored when thread is resumed Context Switch Interrupt running thread and do something else Result of preemption, interrupt, or cooperative service What’s involved in a context switch? See StepOperationCycles 1 Save the current thread’s context (ie: GP and FP register values and PC) on the stack Save the current stack pointer in the thread's control block Switch to the system stack pointer Return to the scheduler Find the highest priority thread that is ready to run Switch to the new thread's stack Recover the new thread's context Return to the new thread at its previous PC Other processing TOTAL Registers PC SP

© 2012 Renesas Electronics America Inc. All rights reserved.12 Multithreading Enabling an activity to use the CPU while other activities don’t need it – I/O Delay Thread A Thread B Thread A I/O Start I/O Finish Time Thread A has to wait for I/O When I/O is done, Thread A can continue While Thread A is waiting for I/O, Thread B can use CPU Thread A Waits

© 2012 Renesas Electronics America Inc. All rights reserved.13 Preemptive Scheduling Preemption Interruption for higher- priority activity – Interrupt – Thread Preemptive Scheduling Always run highest priority thread that is READY to run – Maximum responsiveness – No Polling, so more efficient – Always results in a context switch Thread-1 Begins Thread-2 Runs Thread-1 Resumes Priority Time Context Switch

© 2012 Renesas Electronics America Inc. All rights reserved.14 Among threads of a given priority Threads of different priorities use either preemptive or preemption-threshold scheduling Threads take turns Run to Completion Or, relinquish (suspend) Or, until blocked (suspend) Or, until time slice is exhausted (suspend) Round-Robin Scheduling

© 2012 Renesas Electronics America Inc. All rights reserved.15 Preemption-Threshold Scheduling A technique to reduce context switches Preemption-Threshold Scheduling establishes a priority for preemption. Preemption requires a priority higher (lower number) than the preemption-threshold. PriorityComment 0 Preemption allowed for threads with priorities from 0 to 14 (inclusive) : Thread is assigned Preemption-Threshold = 15 [this has the effect of disabling preemption for threads with priority values from 15 to 19 (inclusive)] : Thread is assigned Priority = 20 : 31 For example, assume a thread’s priority is 20, and its preemption threshold is set to 15 Threads with priority lower than (larger number) 14, even if higher than (smaller number) the running thread’s priority (20), will not preempt the running thread

© 2012 Renesas Electronics America Inc. All rights reserved.16 Part-II: An example to show how various scheduling techniques affect performance

© 2012 Renesas Electronics America Inc. All rights reserved.17 The Application Fully Preemptive, Round-Robin, or Preemption-Threshold Scheduling: What are the consequences of each with respect to context switching? Construct a system to run and observe Producer-consumer application – One producer, three consumers – 9 messages sent, 9 received – Continuous operation Log events Use EWRX and TraceX to debug Count context switches Measure throughput Draw conclusions Producer Consumer

© 2012 Renesas Electronics America Inc. All rights reserved.18 An Example To See The Impact Receive A’s Messages Receive B’s Messages Receive C’s Messages Receive C’s Messages Receive B’s Messages Receive A’s Messages Send a Message to Threads A, B, C Thread A Thread B Thread C Thread D Time Cycle 1Cycle 2 Send a Message to Threads A, B, C

© 2012 Renesas Electronics America Inc. All rights reserved.19 Priority Assignments Case-1 Preemptive Scheduling Thread A = 1 Thread B = 2 Thread C = 3 Thread D = 4 Case-2 Round-Robin Scheduling Thread A = 1 Thread B = 1 Thread C = 1 Thread D = 1 Case-3 Preemption-Threshold Scheduling Thread A = 1, PT=1 Thread B = 2, PT=2 Thread C = 3, PT=3 Thread D = 4, PT=1 Case-1Case-2 Thread C Thread D Thread B Thread A Thread C Thread D Thread B Thread A PriorityPT Thread C Thread B Thread D Priority Case-3 Thread C Thread D Thread B Thread A

© 2012 Renesas Electronics America Inc. All rights reserved.20 Open Project in EWRX View Project Files View/Edit Code Build, Download, Debug Build, Run, Debug the Application

© 2012 Renesas Electronics America Inc. All rights reserved.21 Stop at Breakpoint View Counters View Thread List View Message Queues, Memory, etc. Analyze results using TraceX Debug View

© 2012 Renesas Electronics America Inc. All rights reserved.22 Real-time event trace Shows RTOS events Shows Application events Target trace_buffer EWRX uploads to host at breakpoint via macro Launch from EWRX TraceX

© 2012 Renesas Electronics America Inc. All rights reserved.23 Launch TraceX from the Embedded Workbench IDE Analyzing Results Using TraceX

© 2012 Renesas Electronics America Inc. All rights reserved.24 Examining The Events Case-1: Preemptive Scheduling Thread D sends a message to Thread A Thread A preempts Thread A reads its message then suspends (queue empty) Thread D sends message to Thread B Thread B preempts Similarly for Thread C 9 Messages 18 Context Switches

© 2012 Renesas Electronics America Inc. All rights reserved.25 Examining The Events Case-2: Round-Robin Scheduling (Equal Priorities) Thread D sends 3 messages to each queue Thread D then suspends Thread A reads its 3 messages then suspends (queue empty) Similarly, for Threads B and C Thread D then writes another set of messages 9 Messages 4 Context Switches

© 2012 Renesas Electronics America Inc. All rights reserved.26 Examining The Events Case-3: Preemption- Threshold Scheduling Thread D sends 3 messages to each queue Thread D then suspends Thread A reads its 3 messages then suspends (queue empty) Similarly, for Threads B and C Thread D then writes another set of messages 9 Messages 4 Context Switches

© 2012 Renesas Electronics America Inc. All rights reserved Compare Context Switches Case-1 No PTS Case-2 and Case-3 Round-Robin or PTS Context Switches

© 2012 Renesas Electronics America Inc. All rights reserved.28 Compare Timing Case-1 shows 7,531 ticks in a cycle Case-2 and Case-3 show 4,420 ticks in a cycle

© 2012 Renesas Electronics America Inc. All rights reserved.29 Assessing The Results Context Switches Throughput CaseMessages Context Switches Case-1: Unique Priorities918 Case-2/3: Round- Robin/Preemption-Threshold 94 Measurement Case-1 (Unique Priorities) Case-2/3 (Round- Robin/Preemption -Threshold) Ratio (Case 1 vs Case-2/3) Context Switches184450% Elapsed Time7,531 ticks4,420 ticks170% Messages Sent99No Change Messages Received99No Change

© 2012 Renesas Electronics America Inc. All rights reserved.30 Summary And Conclusions Round-Robin or Preemption-Threshold Scheduling can reduce the number of context switches an application must perform Full Preemption delivers maximum responsiveness, but may result in overhead that has a negative impact on throughput Round-Robin and PTS offer solutions to excessive context switch overhead and can increase throughput Good Tools can make RX development easier IAR Embedded Workbench IDE makes building and debugging easy TraceX eases analysis of real-time applications Strong Integration Makes Tools easy To Use ThreadX Kernel Awareness in EWRX TraceX Launch from EWRX ThreadX delivered as EWRX Projects

© 2012 Renesas Electronics America Inc. All rights reserved.31 Q/A For further information about ThreadX: Contact Express Logic, Inc. – THREADX ( ) – Visit: For further information about IAR Embedded Workbench for RX: Contact IAR – (Western US) – (Eastern US) – (HQ – Sweden) – Visit

© 2012 Renesas Electronics America Inc. All rights reserved.32 Please utilize the ‘Guidebook’ application to leave feedback or Ask me for the paper feedback form for you to use… Please Provide Your Feedback…

Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved.