novos fcfs environment user guide sample v1...novos fcfs environment user guide -
TRANSCRIPT
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 2 of 154
Disclaimers Embedded Environments Co. (Company), provides this User Guide “as is” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The complete text of the Novos Documentation License is available at the Company website, www.ee-novos.com.
The Company reserves the right to revise this publication at any time and to make changes to its content and the software it represents and without obligation to inform any person or entity of such revisions or changes.
Trademarks Novos and the following derivatives are trademarks of Embedded Environments Co:
Novos,
Novos FB, Novos Foreground/Background,
Novos EFB, Novos Extended Foreground/Background,
Novos FCFS, Novos First Come, First Served Scheduling,
Novos RRS, Novos Round Robin Scheduling,
Novos PPS, Novos Pre-emptive Priority Scheduling
Other product and company names mentioned in this document may be the trademarks or registered trademarks of their respective owners.
Copyrights Ownership of and all copyrights to the source code of the Novos environment as it relates to this document are held by Embedded Environments Co. It is distributed as free software. You can copy it, modify it and even redistribute it under the terms of the Novos Software License as published on the Company website, www.ee-novos.com.
Ownership of and all rights to this publication, including the copyright, are held and/or reserved by Embedded Environments Co. This document is licensed to you as the sole user. No part of this document may be reproduced, photocopied, stored on a retrieval system, redistributed or transmitted without the express written consent of Embedded Environments Co.
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 3 of 154
Modification History
Version #
Major Release
#
Minor Release
# Date Author Revised Sections
2 0 0 28-Oct-2016 ATB Initial Release
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 4 of 154
Table of Contents Disclaimers .............................................................................................................................. 2
Trademarks .............................................................................................................................. 2
Copyrights ................................................................................................................................ 2
Modification History .................................................................................................................. 3
Table of Contents ..................................................................................................................... 4
List of Examples ..................................................................................................................... 12
List of Figures ........................................................................................................................ 13
List of Tables .......................................................................................................................... 14
Foreword ................................................................................................................................ 16
Chapter 1 How to Use This Guide ..................................................................................... 17
Scope of this Guide ........................................................................................................... 17
Novos Usage ..................................................................................................................... 17
Commercial Usage ........................................................................................................ 18
Errors and Inaccuracies ................................................................................................. 18
Conventions Used in This Guide ....................................................................................... 18
Cautions, Tips and Notes ............................................................................................... 18
Font and Capitalization Usage ....................................................................................... 19
Chapter 2 Novos Environments for Embedded Systems .................................................. 20
Source Code ..................................................................................................................... 20
Common Code and Headers ......................................................................................... 21
Novos Environment APIs ............................................................................................... 21
Port-Specific Code and Headers ................................................................................... 21
Core Functions ............................................................................................................... 22
Configuring ........................................................................................................................ 22
System Processing Priority Queue Size ........................................................................ 22
Enumerated Values of DIH Priorities ............................................................................. 24
Enumerated Values of FG Task Priorities ...................................................................... 25
Stack Alignment ............................................................................................................. 26
Parametric Diagnostics .................................................................................................. 26
Terminal Error Return Mode .......................................................................................... 26
Compiling .......................................................................................................................... 27
Object Classes .................................................................................................................. 27
Class Properties ............................................................................................................. 27
Objects .............................................................................................................................. 28
Object Properties ........................................................................................................... 28
Object Identifiers ............................................................................................................ 28
Creating Objects ............................................................................................................ 28
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 5 of 154
Allocating RAM for an Object ..................................................................................... 29
Object Header ............................................................................................................ 29
Terminal Errors .................................................................................................................. 30
Terminal Error Packet .................................................................................................... 31
Terminal Error Handler .................................................................................................. 31
Exiting the Terminal Error Handler ............................................................................. 31
User-Defined Terminal Error Handler ......................................................................... 32
Application Program Interface (API) .................................................................................. 32
The Service Name ......................................................................................................... 32
Service Completion Code .............................................................................................. 32
Usage Target ..................................................................................................................... 33
Chapter 3 The Novos First Come, First Served Scheduling (FCFS) Environment ............ 34
Introduction ........................................................................................................................ 34
Features ............................................................................................................................ 35
Planes of Operation ........................................................................................................... 35
Interrupt Plane ............................................................................................................... 36
Foreground Plane .......................................................................................................... 36
Background Plane .......................................................................................................... 36
Stacks ................................................................................................................................ 37
Stack Orientation ........................................................................................................... 37
Guard Words .................................................................................................................. 37
System Stack ................................................................................................................. 38
Background Stacks ........................................................................................................ 38
System Initialization ........................................................................................................... 38
System Properties .......................................................................................................... 38
System RAM .............................................................................................................. 39
User RAM ................................................................................................................... 39
System Stack ............................................................................................................. 40
Idle Task Stack ........................................................................................................... 40
System Processing Priority Queue ............................................................................. 40
Classes .............................................................................................................................. 41
Foreground Execution Entities .......................................................................................... 42
Foreground Execution Support ...................................................................................... 42
Foreground Entity Control Block ................................................................................ 43
Foreground Carrier Packet ......................................................................................... 43
Deferred Interrupt Handler ............................................................................................. 44
Event Action Routine ..................................................................................................... 45
Foreground Tasks .......................................................................................................... 45
Background Execution Entities (Tasks) ............................................................................. 45
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 6 of 154
Reusing User RAM ............................................................................................................ 46
Used RAM List ............................................................................................................... 46
Chapter 4 Interrupt Processing .......................................................................................... 48
Introduction ........................................................................................................................ 48
Interrupt Processing Sequence ......................................................................................... 48
Interrupt Vectors ............................................................................................................ 49
Starting an ISR ............................................................................................................... 49
Preserving the Interrupted CPU Context .................................................................... 50
Switching Stacks in an ISR ........................................................................................ 50
Immediate Interrupt Handling ......................................................................................... 50
Form of the IIH ........................................................................................................... 51
Scheduling the Deferred Interrupt Handler ................................................................. 51
Ending an ISR ................................................................................................................ 51
Deferred Interrupt Handler (DIH) ................................................................................... 51
Example ISR ..................................................................................................................... 52
Chapter 5 Deferred Interrupt Handlers .............................................................................. 53
Introduction ........................................................................................................................ 53
States of a DIH ............................................................................................................... 53
Using Deferred Interrupt Handlers .................................................................................... 54
Definition of a DIH Object .............................................................................................. 54
DIH Properties ............................................................................................................ 54
Creating a DIH ............................................................................................................ 55
Referencing a DIH ......................................................................................................... 56
DIH Services ..................................................................................................................... 56
DIH Example ..................................................................................................................... 56
Chapter 6 Event Action Routines ....................................................................................... 57
Introduction ........................................................................................................................ 57
States of an EAR ........................................................................................................... 57
Using Event Action Routines ............................................................................................. 57
Definition of an EAR Object ........................................................................................... 58
EAR Properties ........................................................................................................... 58
Creating an EAR ........................................................................................................ 59
Referencing an EAR ...................................................................................................... 59
EAR-Event Association Options ................................................................................. 59
Multiple EARs Associated with an Event .................................................................... 60
Execution of an EAR .................................................................................................. 60
EAR Services .................................................................................................................... 61
EAR Example .................................................................................................................... 61
Chapter 7 Foreground Tasks ............................................................................................ 62
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 7 of 154
Introduction ........................................................................................................................ 62
Using FG Tasks ................................................................................................................. 62
Definition of a FG Task Object ....................................................................................... 63
FG Task Properties .................................................................................................... 64
Creating a FG Task .................................................................................................... 65
Referencing a FG Task .................................................................................................. 65
FG Task Services .............................................................................................................. 65
Chapter 8 Background Tasks ............................................................................................ 66
Introduction ........................................................................................................................ 66
Task Control Block ......................................................................................................... 67
The Idle Task ................................................................................................................. 67
Current Task .................................................................................................................. 67
Pre-emption ................................................................................................................... 68
Background Ready List .................................................................................................. 68
What is a Task? ................................................................................................................. 70
Task Code Template ...................................................................................................... 70
Infinite Life Model ....................................................................................................... 70
Finite Life Model ......................................................................................................... 71
Task Priority ................................................................................................................... 72
Background Task States ................................................................................................ 72
INITIALIZED State ...................................................................................................... 72
READY State .............................................................................................................. 73
RUNNING State ......................................................................................................... 73
BLOCKED State ......................................................................................................... 73
CLOSED State ........................................................................................................... 73
Using Background Tasks .................................................................................................. 74
Task Scheduling ............................................................................................................ 75
Definition of a Background Task .................................................................................... 75
Background Task Properties ...................................................................................... 75
Task Stack .............................................................................................................................. 76
Creating a Background Task ...................................................................................... 77
Referencing a Background Task .................................................................................... 77
Referencing the Current Task .................................................................................... 77
Referencing the Idle Task .......................................................................................... 77
Background Task Events ............................................................................................... 78
Background Task Operations ........................................................................................ 78
Closing a Background Task ....................................................................................... 78
Terminating a Background Task ................................................................................ 78
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 8 of 154
Background Task Services ................................................................................................ 79
Chapter 9 Timebase Counter ............................................................................................ 80
Introduction ........................................................................................................................ 80
Timebase Counter States .............................................................................................. 80
Using the Timebase Counter ............................................................................................. 81
Definition of the Timebase Counter ............................................................................... 81
Timebase Counter Properties .................................................................................... 81
Creating the Timebase Counter ................................................................................. 81
Conversion of Real-Time to Ticks .................................................................................. 81
Referencing the Timebase Counter ............................................................................... 82
Timebase Counter Services .............................................................................................. 82
Chapter 10 Alarms ............................................................................................................. 83
Introduction ........................................................................................................................ 83
Alarm Types ................................................................................................................... 83
One-Shot Alarms ........................................................................................................ 83
Cyclic Alarms .............................................................................................................. 84
Alarm States ...................................................................................................................... 84
Using Alarms ..................................................................................................................... 85
Definition of an Alarm Object ......................................................................................... 85
Alarm Properties ......................................................................................................... 85
Creating an Alarm ...................................................................................................... 86
Closing an Alarm ........................................................................................................ 86
Referencing an Alarm .................................................................................................... 87
Conversion from Time to Ticks ...................................................................................... 87
Relative Time ............................................................................................................. 87
Alarm Period Ambiguity .............................................................................................. 89
Testing an Alarm ............................................................................................................ 90
Alarm Events .................................................................................................................. 91
Associating an Alarm Event with an EAR ...................................................................... 92
Alarm Services .................................................................................................................. 94
Chapter 11 Event Groups .................................................................................................. 95
Introduction ........................................................................................................................ 95
Event Group States ........................................................................................................ 95
Using Event Groups .......................................................................................................... 96
Definition of an Event Group Object .............................................................................. 96
Event Group Properties .............................................................................................. 96
Creating an Event Group ............................................................................................ 97
Closing an Event Group ............................................................................................. 97
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 9 of 154
Referencing an Event Group ......................................................................................... 97
Testing Event Group Flags ............................................................................................ 97
Boolean Operators ..................................................................................................... 98
Testing from a Background Task ............................................................................... 99
Multiple Tests on an Event Group ............................................................................ 100
Testing from a Foreground Entity or Idle Task ......................................................... 101
Event Group Events ..................................................................................................... 101
Associating an Event Group Event with an EAR ......................................................... 102
Multiple EAR Associations with an Event Group Event ............................................ 102
Event Group Services ..................................................................................................... 103
Chapter 12 Queues ......................................................................................................... 105
Introduction ...................................................................................................................... 105
Queue Producer ........................................................................................................... 105
Multiple Producers .................................................................................................... 106
Queue Consumer ......................................................................................................... 106
Multiple Consumers .................................................................................................. 106
Data Transfer Modes ................................................................................................... 106
Order of Data Movement ............................................................................................. 107
First-In, First-Out (FIFO) Order ................................................................................ 107
Last-In, First-Out (LIFO) Order ................................................................................. 107
Peeking in a Queue .................................................................................................. 107
Queue States .................................................................................................................. 107
Using Queues .................................................................................................................. 108
Definition of a Queue Object ........................................................................................ 108
Queue Properties ..................................................................................................... 108
Creating a Queue ..................................................................................................... 109
Closing a Queue ....................................................................................................... 110
Referencing a Queue ................................................................................................... 110
Queue Operations ........................................................................................................ 110
Queue Operations in a Background Task ................................................................ 111
Queue Operations in a Foreground Entity ................................................................ 112
Queue Events .............................................................................................................. 112
Associating a Queue Event with an EAR ..................................................................... 113
Background Tasks .................................................................................................... 113
Foreground Tasks and the Idle Task ........................................................................ 115
Queue Services ............................................................................................................... 115
Chapter 13 Semaphores ................................................................................................... 116
Introduction ...................................................................................................................... 116
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 10 of 154
Semaphore States ....................................................................................................... 117
Using Semaphores .......................................................................................................... 119
Definition of a Semaphore Object ................................................................................ 119
Semaphore Types .................................................................................................... 119
Semaphore Properties ............................................................................................. 119
Creating a Semaphore ............................................................................................. 120
Closing a Semaphore ............................................................................................... 120
Referencing a Semaphore ........................................................................................... 121
Semaphore Operations ................................................................................................ 121
Semaphore Operations in the Background .............................................................. 121
Posting a Signal ................................................................................................................... 122
Testing for a Posted Signal .................................................................................................. 122
Semaphore Operations in the Foreground ............................................................... 124
Semaphore Events ...................................................................................................... 124
Associating a Semaphore Event with an EAR ............................................................. 125
Semaphore Services ....................................................................................................... 126
Chapter 14 Memory Pools ................................................................................................ 128
Introduction ...................................................................................................................... 128
Memory Pool Types ..................................................................................................... 128
Memory Pool States ..................................................................................................... 129
Using Memory Pools ....................................................................................................... 130
Definition of a Memory Pool Object ............................................................................. 130
Memory Pool Properties ........................................................................................... 130
Creating a Memory Pool ........................................................................................... 131
HARD_FIXED Memory Pool ................................................................................................ 131
SOFT_FIXED Memory Pool .................................................................................................. 133
SOFT_DEMAND Memory Pool ............................................................................................ 133
Closing a Memory Pool ............................................................................................ 134
Referencing a Memory Pool ........................................................................................ 136
Memory Pool Operations ............................................................................................. 136
Memory Pool Operations in the Background ............................................................ 137
Getting a RAM Block ........................................................................................................... 137
Empty Fixed Memory Pool .............................................................................................. 137
Empty SOFT_DEMAND Memory Pool............................................................................. 138
Freeing a RAM Block ........................................................................................................... 139
Memory Pool Operations in the Foreground ............................................................ 139
Memory Pool Events .................................................................................................... 140
Associating a Memory Pool Event with an EAR .......................................................... 140
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 11 of 154
Background Tasks .................................................................................................... 141
Foreground Tasks and the Idle Task ........................................................................ 141
Memory Pool Services .................................................................................................... 142
Chapter 15 Mutex Class .................................................................................................... 143
Introduction ...................................................................................................................... 143
Mutex States ................................................................................................................ 143
Mutex and Semaphore Differences ............................................................................. 143
Nested Ownership .................................................................................................... 144
Definition of a Mutex Object ............................................................................................ 144
Mutex Properties ...................................................................................................... 144
Creating a Mutex ...................................................................................................... 144
Closing a Mutex ........................................................................................................ 145
Using Mutexes ................................................................................................................. 145
Referencing a Mutex .................................................................................................... 145
Mutex Operations ......................................................................................................... 145
Acquiring a Mutex ..................................................................................................... 146
Releasing a Mutex .................................................................................................... 147
Priority Inversion Handling ........................................................................................... 147
Mutex Services ................................................................................................................ 147
Chapter 16 Special Services ............................................................................................. 149
Appendix A ISR Examples ............................................................................................. 150
Cortex-Mx SysTick Driver with ISR ................................................................................. 150
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 12 of 154
List of Examples Example 1-1 Code example .............................................................................................. 19
Example 2-1 Definition of Size of System Processing Priority Queue .............................. 22
Example 2-2 Default DIH Priority Definitions .................................................................... 24
Example 2-3 Default Foreground Task Priority Definitions ............................................... 25
Example 2-4 Stack Alignment Definition ........................................................................... 26
Example 2-5 Class Properties Structure ........................................................................... 27
Example 2-6 Object Header Structure .............................................................................. 29
Example 2-7 Terminal Error Packet .................................................................................. 31
Example 2-8 Novos Service Name Conventions .............................................................. 32
Example 3-1 System Properties Structure ........................................................................ 39
Example 3-2 Used Block Header Structure ...................................................................... 46
Example 5-1 Service to Schedule a DIH ........................................................................... 54
Example 5-2 Deferred Interrupt Handler Property Structure ............................................. 54
Example 5-3 Service Prototype to Create a DIH .............................................................. 55
Example 6-1 Event Action Routine Property Structure ..................................................... 58
Example 6-2 Service Prototype to Create an EAR ........................................................... 59
Example 7-1 Foreground Task Property Structure ........................................................... 64
Example 7-2 Service Prototype to Create a Foreground Task ......................................... 65
Example 8-1 Task Code Prototype ................................................................................... 70
Example 8-2 Infinite Life Task Model ................................................................................ 71
Example 8-3 Finite Life Task Model (Using Conditional) .................................................. 71
Example 8-4 Finite Life Task Model (Using Count) .......................................................... 72
Example 8-5 Background Task Properties Structure ........................................................ 76
Example 8-6 Service Prototype to Create a Background Task ......................................... 77
Example 8-7 Current Task Reference Examples .............................................................. 77
Example 10-1 Alarm Properties ...................................................................................... 85
Example 10-2 Service Prototype to Create an Alarm ...................................................... 86
Example 10-3 Converting from Time to Ticks ................................................................. 87
Example 11-1 Event Group Properties Structure ............................................................ 96
Example 11-2 Service Prototype to Create an Event Group ........................................... 97
Example 12-1 Queue Properties Structure ................................................................... 109
Example 12-2 Service Prototype to Create a Queue .................................................... 110
Example 13-1 Semaphore Properties Structure ............................................................ 120
Example 13-2 Service Prototype to Create a Semaphore ............................................ 120
Example 14-1 Memory Pool Properties Structure ......................................................... 130
Example 14-2 Service Prototype to Create a Memory Pool .......................................... 131
Example 15-1 Mutex Properties Structure .................................................................... 144
Example 15-2 Service Prototype to Create a Mutex ..................................................... 145
Example A-1 Cortex-M0 SysTick Driver with ISR............................................................ 150
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 13 of 154
List of Figures Figure 2-1 Novos FCFS Default SPPQ Organization ....................................................... 23
Figure 2-2 SPPQ Priority Level Mapping .......................................................................... 24
Figure 3-1 The Empty SPPQ ............................................................................................ 41
Figure 3-2 SPPQ with One FGE Scheduled ..................................................................... 44
Figure 3-6 Used RAM List Organization ........................................................................... 47
Figure 7-1 Time Triggered Rate Monotonic Scheduling Example .................................... 63
Figure 8-1 Initial Background Ready List .......................................................................... 68
Figure 8-2 BRL with TASK_C Added ................................................................................ 69
Figure 8-3 Current Task and BRL Changes ..................................................................... 69
Figure 8-4 Task State Transitions ..................................................................................... 74
Figure 10-1 Alarm State Transitions ............................................................................... 85
Figure 10-2a Alarm Activation ........................................................................................... 88
Figure 10-2b Alarm Activation with Earlier Expiration ....................................................... 89
Figure 10-3 Problem with One Tick Alarm Period ........................................................... 89
Figure 10-4 Testing an Alarm at Irregular Intervals ......................................................... 91
Figure 10-5 Alarm Associated with Event Action Routine ............................................... 93
Figure 11-1a One Task Waiting for an Event Group Match ............................................ 100
Figure 11-1b Two Tasks Waiting for an Event Group Match .......................................... 101
Figure 11-2 Event Group with Multiple Tests ................................................................ 103
Figure 12-1 One Queue Event Association with One Event Action Routine ................. 114
Figure 13-1 Semaphore State Transitions .................................................................... 118
Figure 13-2 Response Time for Semaphore Signal in FCFS Scheduling ..................... 123
Figure 13-3 Use of EAR with Semaphore Event ........................................................... 126
Figure 14-1 Newly Created HARD_FIXED Memory Pool in Full State ........................ 132
Figure 14-2 Newly Created SOFT_DEMAND Memory Pool ......................................... 134
Figure 14-3 Full SOFT_DEMAND Memory Pool .............................................................. 136
Figure 14-4 SOFT_DEMAND Memory Pool with Two Blocks Assigned ....................... 139
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 14 of 154
List of Tables Table 2-1 Novos Environment Names and Abbreviations ............................................... 21
Table 2-2 Descriptions of Object Header Properties ....................................................... 29
Table 3-1 Special Services allowed in the IIH ................................................................. 36
Table 3-2 Novos FCFS Supported Classes .................................................................... 42
Table 5-1 Descriptions of DIH Properties ........................................................................ 54
Table 5-2 Novos FCFS Services for DIH class ............................................................... 56
Table 6-1 EAR Property Descriptions .............................................................................. 58
Table 6-2 Options for Managing EAR and Event Associations ....................................... 60
Table 6-3 Novos FCFS Services for EAR class .............................................................. 61
Table 7-1 Foreground Task Property Descriptions .......................................................... 64
Table 7-2 Novos FCFS Services for Foreground Task class .......................................... 65
Table 8-1 Background Task Property Descriptions ......................................................... 76
Table 8-2 Background Task Class Services .................................................................... 79
Table 9-1 Timebase Counter States ................................................................................ 81
Table 9-2 Novos Timebase Counter Services ................................................................. 82
Table 10-1 Alarm States .................................................................................................... 84
Table 10-2 Alarm Properties Descriptions ......................................................................... 86
Table 10-3 Pend Options for Unexpired Alarms ................................................................ 90
Table 10-4 Alarm Event Definitions ................................................................................... 91
Table 10-5 Alarm Services ................................................................................................ 94
Table 11-1 Event Group States ......................................................................................... 95
Table 11-2 Event Group Property Descriptions ................................................................. 97
Table 11-3 Pend Options for Incomplete Queueing Operations ........................................ 98
Table 11-4 Boolean Operator and Flag Clearing Options ................................................. 99
Table 11-5 Event Group Services ................................................................................... 103
Table 12-1 Queue Transfer Modes ................................................................................. 106
Table 12-2 Queue States ................................................................................................ 108
Table 12-3 Queue Properties Descriptions ..................................................................... 109
Table 12-4 Pend Options for Incomplete Queueing Operations ...................................... 111
Table 12-5 Queue Transition Events ............................................................................... 112
Table 12-6 Queue Class Services ................................................................................... 115
Table 13-1 Semaphore States ......................................................................................... 117
Table 13-2 Semaphore Types ......................................................................................... 119
Table 13-3 Queue Properties Descriptions ..................................................................... 120
Table 13-4 Pend Options for Incomplete Semaphore Testing Operations ...................... 121
Table 13-5 Semaphore Events ........................................................................................ 125
Table 13-6 Semaphore Class Services ........................................................................... 126
Table 14-1 Memory Pool Types ...................................................................................... 129
Table 14-2 Memory Pool States ...................................................................................... 129
Table 14-3 Memory Pool Properties Descriptions ........................................................... 130
Table 14-4 Pend Options for Incomplete RAM Block Allocation Requests ..................... 137
Table 14-5 Memory Pool State Transition Events ........................................................... 140
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 15 of 154
Table 14-6 Memory Pool Class Services ........................................................................ 142
Table 15-1 Mutex States ................................................................................................. 143
Table 15-2 Mutex Properties Descriptions ...................................................................... 144
Table 15-3 Pend Options for Incomplete Mutex Acquisition Operations ......................... 146
Table 15-4 Mutex Class Services .................................................................................... 147
Table 16-1 Special Services ............................................................................................ 149
Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 16 of 154
Foreword Over many years as a designer and developer of schedulers, real-time kernels and executives, and real-time operating system (RTOS) products for embedded systems, I have witnessed the effect that the choice of environment has on the success or failure of a project.
For the past 25 years or so, the environment of choice has tended towards the RTOS. There are many RTOS products available in the market today and they are solid, proven packages. Some are free and some are not. But without regard to their license fee, or lack thereof, an RTOS is not always the best foundation for the application at hand.
With the advent of the Internet of Things (IoT), there will be billions of processors used in tens of thousands of IoT applications. Some of these applications will be good candidates for the RTOS environment. Many others will not because the typical RTOS is likely to be overkill in terms of functionality and footprint. I believe that developers of embedded systems, whether for IoT or general applications, will benefit from environment choices other than the typical RTOS.
The Novos environments for embedded systems represent those choices. They were created for use in applications that use resource constrained 9-, 16- and 32-bit CPUs. The Novos environments are not only easy to use but very well suited for use where the designer has to be mindful of the constraints imposed by RAM, ROM and power budgets.
It is my opinion that the application itself dictates the environment for which it is best suited. That is especially true for embedded systems that share a single primary resource – the processor. Central to the environment is how the application shares that processor. The essence of processor sharing is best described as “scheduling”, of which there are many types. Some are simple and some not so simple.
Numerous questions about scheduling will confront the designer. Do application components require priorities? Does the application need pre-emptive scheduling? Is a cooperative scheduling policy sufficient? Is deterministic performance necessary? Is a simple loop-based approach sufficient? Hard or soft real-time?
Albert Einstein is often quoted as saying “Everything should be made as simple as possible, but not simpler.” In deference to Dr. Einstein, a good dictum for engineering an embedded system is to use the simplest environment with the simplest scheduling policy that fits the application’s requirements. It makes good sense because simpler environments tend to make testing and maintenance easier. Taken together, the use of the appropriate environment for the application greatly improves the probability of achieving a successful result.
Thank you for choosing a Novos environment and we trust you will find it meets your application’s requirements and is also easy to use. And if you have ideas on its usage, extensions or ways to improve the product, we would like to hear from you. In the meantime, good luck with your development.
Tom Barrett
Chapter 1: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 17 of 154
Chapter 1 How to Use This Guide
Scope of this Guide This document is intended to explain how the Novos First Come, First Served Scheduling (FCFS) environment works and how it is organized to help you achieve a successful application development. It assumes the reader has a basic knowledge of developing embedded systems, how Foreground/Background systems work in general and the use of First Come, First Served cooperative task scheduling in particular. It is not meant to be a tutorial on how to design or implement embedded applications based on such organizations or whether the Novos FCFS environment is best for your application.
Because this document does not deal with the details of individual Novos environment services, there is limited information about them herein except where they serve illustrative purposes. However, there is an accompanying manual, The Novos First Come, First Served Scheduling Environment Services Reference Guide, available for a small fee, which provides detailed usage information on all services in the Novos FCFS environment. In combination with this guide, you should have an in-depth knowledge about successfully employing the Novos FCFS environment in your embedded application. For more information, please go to our website at www.ee-novos.com.
Novos Usage Unless you have agreed to and purchased a commercial license to the Novos First Come, First Served Scheduling environment, your use of this publication and the related source code is limited to your personal use only.
Chapter 1: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 18 of 154
The Company has invested considerable time and expense in order to provide the source code for the Novos First Come, First Served Scheduling environment free of charge for non-commercial use. We do not ask for nor require a portion of any compensation you might receive from your efforts that incorporate it. Our compensation comes partly from your purchase of the license to this Guide. By accepting that license you have agreed to treat us in a fair and equitable manner. Distribution, copying or otherwise making this Guide available to third parties is not fair treatment. You would not only be in violation of that agreement, but you would be depriving us of revenue that will go towards product improvement and as compensation for our efforts.
Commercial Usage For commercial users, the Novos commercial license includes an initial warranty period within which Embedded Environments Co. will provide you with maintenance and updates to your licensed product. For more information on commercial use licenses for Novos environments, please visit our website at www.ee-novos.com.
Errors and Inaccuracies Every effort has been made to ensure that the information herein is correct and accurately reflects the capabilities and services of the Novos First Come, First Served Scheduling environment. However, as in all such documents, technical inaccuracies and typographical errors do occur. Should you detect such errors, we invite you to submit information about them to us. The Company will make changes to this document from time-to-time and we will correct errors and incorporate useful changes into any new editions. Your comments and assistance in this effort helps us improve the product and benefits other users.
Conventions Used in This Guide This document uses several conventions that are intended to improve your experience in using it. Some of the conventions are typographical and some are graphical.
Cautions, Tips and Notes Warnings, cautions, tips and notes are graphical icons intended to highlight an associated paragraph or concept in order to save you time and to improve your understanding of the product.
The presented information is of critical importance and you should understand it and take it into consideration in your development. Failing to do so may lead you to induce errors that can lead to unintended system behavior or cause a loss of time.
Chapter 1: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 19 of 154
This is information useful to clarify a particular point about the current or recent topic.
An idea or usage suggestion that may help you solve a problem related to the current topic
Font and Capitalization Usage The document employs several typographical conventions to identify elements commonly used in a discussion about embedded software.
File names are represented in Regular 11 point Courier font such as
Novos_api.h.
Novos service names are represented in Regular 11 point Courier font
such as ES_CreateAlarm.
Excluding object identifiers, specifically defined elements and those defined as a variable of an enumerated type are represented in Bold 12 point Courier font such as Q_NOT_EMPTY or NOPEND.
Service call parameters, object states, variables and elements in system or object properties structures are represented in Italicized 11
point Courier font such as pVariable or Not_Empty.
Object identifiers are represented in upper case Regular 11 point
Courier font such as ALARMID.
Code fragments, examples and property structures are represented in Regular 10 point Courier font as shown in Example 1-1.
Example 1-1 Code example
void myFunc(parameter1, parameter2)
{
... /* code for the function in here */
}
Chapter 2: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 20 of 154
Chapter 2 Novos Environments for Embedded Systems
Source Code Embedded Environments Co. supplies all of the Novos environment code for a particular processor as C source.
The code set contains components that are common to all environments and some that are specific to the port to a particular processor. In general, those
elements of the latter type are found in one file, PORT_Functions.c and an
associated header file, TOOL_CPUspecs.h.
Unless otherwise stated elsewhere, the Novos environment code is specific to a processor core. It does not attempt to cover all of the variants that the semiconductor manufacturer builds around the processor core.
The source code is tuned to serve particular environments commonly used in the development of embedded systems. There are five environments in the Novos suite whose names are taken from the primary scheduling model used for the application. An abbreviation is used for each member used to distinguish one environment from another.
For the sake of brevity, this document will primarily use the abbreviations where it is necessary to draw distinctions between the products.
The five environments and their abbreviations are shown in Table 2-1.
Chapter 2: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 21 of 154
Table 2-1 Novos Environment Names and Abbreviations
Novos Environment Name Abbreviation
Novos Foreground/Background Environment Novos FB
Novos Extended Foreground/Background Environment Novos EFB
Novos First Come, First Served Scheduling Environment Novos FCFS
Novos Round Robin Scheduling Environment Novos RRS
Novos Pre-emptive Priority Scheduling Environment Novos PPS
Common Code and Headers The complete set of common code for the Novos FCFS environment resides
in twelve .c files and ten .h files. A particular file name may appear in all
Novos environments but the contents of the file for the various environments
will not be the same. All of the .h header files are present in each Novos
environment but they, too, contain differences between the various environments.
Within these files, the specific environment determines what the content will be. Different environments have some common services and some that are only found in another environment. The result is a set of files with content specifically tuned for the particular environment you are using, which should help to ease the memory budget for your application.
Novos Environment APIs The file names in the Novos environment source code distribution that begin
with the prefix “APIs for” contain the services for the associated class. The
symbols of the Novos environment’s services are visible to the application and form the Application Program Interface (API). When you want to perform a particular Novos service, just call the associated function. The set of services that are available to the application is found in the header file
Novos_api.h.
A complete explanation of each service in the Novos FCFS environment, including its input parameters, outputs, errors and completion codes is available in the aforementioned publication Novos First Come, First Served Scheduling Environment Services Reference Guide, which is a stand-alone document.
In any application code module that makes calls to the Novos
environment services, you must ensure the Novos_api.h file is
among the module’s set of included files.
Port-Specific Code and Headers The file PORT_Functions.c and its related header, TOOL_CPUspecs.h,
contain all of the content that has anything to do with processor-specific and tool-specific details. In other words, these files reflect the port of the Novos products to a given processor and/or toolchain. When included and compiled
Chapter 2: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 22 of 154
with the common files for the Novos environment, the result is the Novos environment library for use on a particular processor.
Core Functions The Core_Functions.c file contains functions used by the Novos
environment service functions and some internal operations. The functions in
the Core_Functions.c file are not callable from the application.
The application should never call a function found in the
Core_Functions.c file. Direct use of those functions may result in
errors or other unintended consequences.
Configuring The distributed code for the Novos FCFS environment comes defined for a very capable configuration that should be amenable to a large number of applications. All you need to do is to compile it into a library, link that library with your compiled application code and start your tests.
However, if the default Novos FCFS environment configuration does not meet your requirements, it is very easy to change. There are only a few minor configuration options that you have in any Novos environment. These
configuration options are found in the header file NovosConfig.h.
System Processing Priority Queue Size The most important of the configuration options is the definition of the number of priority levels in the System Processing Priority Queue (SPPQ), which
governs all Foreground operations. The default definition is LEVELS_8, which
defines the SPPQ as having eight priority levels, is shown in Example 2-1.
Example 2-1 Definition of Size of System Processing Priority Queue
#define LEVELS_8 /* This the default value */
The default Novos FCFS environment supports all eight priority levels – three for DIH operations, one for Event Action Routines and four for Foreground tasks (FG tasks) as depicted in Figure 2-1.
The Novos environments use an interrupt servicing model that has two levels – an immediate level and a deferred level (See Chapter 4 for complete details). By default, the Deferred Interrupt Handlers (DIH) run in the highest three priority levels in the SPPQ.
Chapter 2: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 23 of 154
Figure 2-1 Novos FCFS Default SPPQ Organization
If that number of priority levels is too small for your application, you will need to make a change to the definition. Changing the definition has implications throughout the system and requires a compilation of the
PORT_Functions.c file and a new link.
Any re-definition of the number of priority levels in the System Processing Priority Queue must be a multiple of 8. Other acceptable
values are LEVELS_16, LEVELS_24 and LEVELS_32. Any extension of
the number of DIH priority levels in the System Processing Priority Queue must include a re-definition of the enumerated variables of
type DIH_PRIORITY in the NovosConfig.h file.
If the processor port of the Novos environment does not support instructions that find the most significant bit in a data word, the Novos port will have to map the SPPQ priorities with bytes. Depending on the number of SPPQ levels you define, the SPPQ and its priority levels are mapped in one or more bytes as illustrated in Figure 2-2.
Chapter 2: Novos FCFS Environment User Guide
Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 24 of 154
The default definition of LEVELS_8 for the Novos FCFS environment
requires only one byte for the SPPQ_LevelMask as there are 8 priority levels
in the System Processing Priority Queue.
Higher levels of priority require a different approach. The variable
SPPQ_LevelMask contains 2, 3 or 4 high order bits that map the bytes for
definitions of LEVELS_16, LEVELS_24 and LEVELS_32. The definition for
the number of SPPQ priority levels is found in the C header file,
NovosConfig.h.
Figure 2-2 SPPQ Priority Level Mapping
Enumerated Values of DIH Priorities The Novos environments use an interrupt servicing model that has two levels – an immediate level and a deferred level. The Deferred Interrupt Handlers run in the highest three priority levels in the SPPQ by default. These priority
levels are found as values of the enumerated type DIH_PRIORITY, in the
ENUMcodes.h file and have the values shown in Example 2-2. However, if
you wish to change the definitions to more or fewer priorities, you may do so, but it will be necessary to recompile the library.
Example 2-2 Default DIH Priority Definitions
typedef enum dihprio
{
HIGH_PRI = 1, /* High priority at FG level 1 */
MEDIUM_PRI = 2, /* Medium priority at FG level 2 */
LOW_PRI = 3 /* Low priority at FG level 3 */
} DIH_PRIORITY;