C/OS-III Users Guide - Farnell . 3 Table of Contents ... Chapter 18 Porting μC/OS-III ... 18-3...

download C/OS-III Users Guide - Farnell  . 3 Table of Contents ... Chapter 18 Porting μC/OS-III ... 18-3 μC/OS-III Port ...

If you can't read please download the document

  • date post

    30-May-2018
  • Category

    Documents

  • view

    212
  • download

    0

Embed Size (px)

Transcript of C/OS-III Users Guide - Farnell . 3 Table of Contents ... Chapter 18 Porting μC/OS-III ... 18-3...

  • C/OS-III TMThe Real-Time Kernel

    Users Manual

    Weston, FL 33326

  • Micrim Press1290 Weston Road, Suite 306Weston, FL 33326USAwww.micrium.com

    Designations used by companies to distinguish their products are often claimed as trademarks.In all instances where Micrim Press is aware of a trademark claim, the product name appears ininitial capital letters, in all capital letters, or in accordance with the vendors capitalizationpreference. Readers should contact the appropriate companies for more complete informationon trademarks and trademark registrations. All trademarks and registered trademarks in thisbook are the property of their respective holders.

    Copyright 2012 by Micrim except where noted otherwise. All rights reserved. Printed in theUnited States of America. No part of this publication may be reproduced or distributed in anyform or by any means, or stored in a database or retrieval system, without the prior writtenpermission of the publisher; with the exception that the program listings may be entered, stored,and executed in a computer system, but they may not be reproduced for publication.

    The programs and code examples in this book are presented for instructional value. Theprograms and examples have been carefully tested, but are not guaranteed to any particularpurpose. The publisher does not offer any warranties and does not guarantee the accuracy,adequacy, or completeness of any information herein and is not responsible for any errors oromissions. The publisher assumes no liability for damages resulting from the use of theinformation in this book or for any infringement of the intellectual property rights of third partiesthat would result from the use of this information.

    For bulk orders, please contact Micrium Press at: +1 954 217 2036

    ISBN: 978-0-9823375-9-2600-uCOS-III-Users-Manual-004

  • 3

    Table of Contents

    Preface .................................................................................................. 13

    Chapter 1 Introduction .......................................................................................... 151-1 Foreground/Background Systems ...................................................... 161-2 Real-Time Kernels ................................................................................ 171-3 RTOS (Real-Time Operating System) .................................................. 191-4 C/OS-III ............................................................................................... 191-5 C/OS, C/OS-II and C/OS-III Features Comparison ...................... 241-6 How the Book is Organized ................................................................. 261-7 C/Probe .............................................................................................. 261-8 Conventions ......................................................................................... 271-9 Chapter Contents ................................................................................. 281-10 Licensing .............................................................................................. 321-11 Contacting Micrium .............................................................................. 32

    Chapter 2 Directories and Files ............................................................................ 332-1 Application Code ................................................................................. 362-2 CPU ....................................................................................................... 372-3 Board Support Package (BSP) ............................................................ 382-4 C/OS-III, CPU Independent Source Code ........................................ 392-5 C/OS-III, CPU Specific Source Code ................................................ 432-6 C/CPU, CPU Specific Source Code .................................................. 442-7 C/LIB, Portable Library Functions ..................................................... 462-8 Summary .............................................................................................. 48

    Chapter 3 Getting Started with C/OS-III ............................................................ 513-1 Single Task Application ....................................................................... 523-2 Multiple Tasks Application with Kernel Objects ................................. 60

  • 4

    Table of Contents

    Chapter 4 Critical Sections ................................................................................... 694-1 Disabling Interrupts .............................................................................. 704-1-1 Measuring Interrupt Disable Time ....................................................... 704-2 Locking the Scheduler ......................................................................... 714-2-1 Measuring Scheduler Lock Time ......................................................... 724-3 C/OS-III Features with Longer Critical Sections ............................... 734-4 Summary .............................................................................................. 74

    Chapter 5 Task Management ............................................................................... 755-1 Assigning Task Priorities ..................................................................... 845-2 Determining the Size of a Stack .......................................................... 865-3 Detecting Task Stack Overflows ......................................................... 875-4 Task Management Services ................................................................ 915-5 Task Management Internals ................................................................ 925-5-1 Task States ........................................................................................... 925-5-2 Task Control Blocks (TCBs) ................................................................. 975-6 Internal Tasks ..................................................................................... 1095-6-1 The Idle Task (OS_IdleTask(), os_core.c) .......................................... 1095-6-2 The Tick Task (OS_TickTask(), os_tick.c) .......................................... 1115-6-3 The Statistic Task (OS_StatTask(), os_stat.c) ................................... 1185-6-4 The Timer Task (OS_TmrTask(), os_tmr.c) ........................................ 1215-6-5 The ISR Handler Task (OS_IntQTask(), os_int.c) .............................. 1225-7 Summary ............................................................................................ 123

    Chapter 6 The Ready List ................................................................................... 1256-1 Priority Levels ..................................................................................... 1266-2 The Ready List ................................................................................... 1306-3 Adding Tasks to the Ready List ........................................................ 1336-4 Summary ............................................................................................ 134

    Chapter 7 Scheduling .......................................................................................... 1357-1 Preemptive Scheduling ...................................................................... 1367-2 Scheduling Points .............................................................................. 1387-3 Round-Robin Scheduling .................................................................. 1407-4 Scheduling Internals .......................................................................... 1427-4-1 OSSched() .......................................................................................... 1437-4-2 OSIntExit() ........................................................................................... 144

  • 5

    7-4-3 OS_SchedRoundRobin() .................................................................... 1457-5 Summary ............................................................................................ 147

    Chapter 8 Context Switching .............................................................................. 1498-1 OSCtxSw() .......................................................................................... 1528-2 OSIntCtxSw() ...................................................................................... 1548-3 Summary ............................................................................................ 157

    Chapter 9 Interrupt Management ....................................................................... 1599-1 Handling CPU Interrupts .................................................................... 1609-2 Typical C/OS-III Interrupt Service Routine (ISR) ............................. 1619-3 Non Kernel-Aware Interrupt Service Routine (ISR) ........................... 1649-4 Processors with Multiple Interrupt Priorities .................................... 1659-5 All Interrupts Vector to a Common Location .................................... 1679-6 Every Interrupt Vectors to a Unique Location .................................. 1699-7 Direct and Deferred Post Methods ................................................... 1709-7-1 Direct Post Method ............................................................................ 1709-7-2 Deferred Post Method ....................................................................... 1739-8 Direct vs. Deferred Post Method ....................................................... 1769-9 The Clock Tick (or System Tick) ........................................................ 1779-10 Summary ............................................................................................ 179

    Chapter 10 Pend Lists (or Wait Lists) .............................