Page 1 of 155...Novos RRS Environment User Guide Copyright © 2016 Embedded Environments Co.- All...

24
Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 1 of 155

Transcript of Page 1 of 155...Novos RRS Environment User Guide Copyright © 2016 Embedded Environments Co.- All...

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 1 of 155

Peter
Sample

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 2 of 155

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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 3 of 155

Modification History

Version #

Major Release

#

Minor Release

# Date Author Revised Sections

2 0 0 28-Oct-2016 ATB Initial Release

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 4 of 155

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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 5 of 155

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 Round Robin Scheduling (RRS) 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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 6 of 155

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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 7 of 155

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 .............................................................................................................. 72

RUNNING State ......................................................................................................... 73

BLOCKED State ......................................................................................................... 73

CLOSED State ........................................................................................................... 73

Using Background Tasks .................................................................................................. 74

Definition of a Background Task .................................................................................... 75

Background Task Properties ...................................................................................... 75

Task Stack .............................................................................................................................. 76

Time Quantum ...................................................................................................................... 76

Choosing a Time Quantum ................................................................................................ 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

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 8 of 155

Terminating a Background Task ................................................................................ 78

Background Task Services ................................................................................................ 79

Chapter 9 Timebase Counter ............................................................................................ 81

Introduction ........................................................................................................................ 81

Timebase Counter States .............................................................................................. 81

Using the Timebase Counter ............................................................................................. 82

Definition of the Timebase Counter ............................................................................... 82

Timebase Counter Properties .................................................................................... 82

Creating the Timebase Counter ................................................................................. 82

Conversion of Real-Time to Ticks .................................................................................. 82

Referencing the Timebase Counter ............................................................................... 83

Timebase Counter Services .............................................................................................. 83

Chapter 10 Alarms ............................................................................................................. 84

Introduction ........................................................................................................................ 84

Alarm Types ................................................................................................................... 84

One-Shot Alarms ........................................................................................................ 84

Cyclic Alarms .............................................................................................................. 85

Alarm States ...................................................................................................................... 85

Using Alarms ..................................................................................................................... 86

Definition of an Alarm Object ......................................................................................... 86

Alarm Properties ......................................................................................................... 86

Creating an Alarm ...................................................................................................... 87

Closing an Alarm ........................................................................................................ 87

Referencing an Alarm .................................................................................................... 88

Conversion from Time to Ticks ...................................................................................... 88

Relative Time ............................................................................................................. 88

Alarm Period Ambiguity .............................................................................................. 90

Testing an Alarm ............................................................................................................ 91

Alarm Events .................................................................................................................. 92

Associating an Alarm Event with an EAR ...................................................................... 93

Alarm Services .................................................................................................................. 95

Chapter 11 Event Groups .................................................................................................. 96

Introduction ........................................................................................................................ 96

Event Group States ........................................................................................................ 96

Using Event Groups .......................................................................................................... 97

Definition of an Event Group Object .............................................................................. 97

Event Group Properties .............................................................................................. 97

Creating an Event Group ............................................................................................ 98

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 9 of 155

Closing an Event Group ............................................................................................. 98

Referencing an Event Group ......................................................................................... 98

Testing Event Group Flags ............................................................................................ 98

Boolean Operators ..................................................................................................... 99

Testing from a Background Task ............................................................................. 100

Multiple Tests on an Event Group ............................................................................ 101

Testing from a Foreground Entity or Idle Task ......................................................... 102

Event Group Events ..................................................................................................... 102

Associating an Event Group Event with an EAR ......................................................... 103

Multiple EAR Associations with an Event Group Event ............................................ 103

Event Group Services ..................................................................................................... 104

Chapter 12 Queues ......................................................................................................... 106

Introduction ...................................................................................................................... 106

Queue Producer ........................................................................................................... 106

Multiple Producers .................................................................................................... 107

Queue Consumer ......................................................................................................... 107

Multiple Consumers .................................................................................................. 107

Data Transfer Modes ................................................................................................... 107

Order of Data Movement ............................................................................................. 108

First-In, First-Out (FIFO) Order ................................................................................ 108

Last-In, First-Out (LIFO) Order ................................................................................. 108

Peeking in a Queue .................................................................................................. 108

Queue States .................................................................................................................. 108

Using Queues .................................................................................................................. 109

Definition of a Queue Object ........................................................................................ 109

Queue Properties ..................................................................................................... 109

Creating a Queue ..................................................................................................... 110

Closing a Queue ....................................................................................................... 111

Referencing a Queue ................................................................................................... 111

Queue Operations ........................................................................................................ 111

Queue Operations in a Background Task ................................................................ 112

Queue Operations in a Foreground Entity ................................................................ 113

Queue Events .............................................................................................................. 113

Associating a Queue Event with an EAR ..................................................................... 114

Background Tasks .................................................................................................... 114

Foreground Tasks and the Idle Task ........................................................................ 116

Queue Services ............................................................................................................... 116

Chapter 13 Semaphores .................................................................................................. 117

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 10 of 155

Introduction ...................................................................................................................... 117

Semaphore States ....................................................................................................... 118

Using Semaphores .......................................................................................................... 120

Definition of a Semaphore Object ................................................................................ 120

Semaphore Types .................................................................................................... 120

Semaphore Properties ............................................................................................. 120

Creating a Semaphore ............................................................................................. 121

Closing a Semaphore ............................................................................................... 121

Referencing a Semaphore ........................................................................................... 122

Semaphore Operations ................................................................................................ 122

Semaphore Operations in the Background .............................................................. 122

Posting a Signal ................................................................................................................... 123

Testing for a Posted Signal .................................................................................................. 123

Semaphore Operations in the Foreground ............................................................... 125

Semaphore Events ...................................................................................................... 125

Associating a Semaphore Event with an EAR ............................................................. 126

Semaphore Services ....................................................................................................... 127

Chapter 14 Memory Pools ............................................................................................... 129

Introduction ...................................................................................................................... 129

Memory Pool Types ..................................................................................................... 129

Memory Pool States ..................................................................................................... 130

Using Memory Pools ....................................................................................................... 131

Definition of a Memory Pool Object ............................................................................. 131

Memory Pool Properties ........................................................................................... 131

Creating a Memory Pool ........................................................................................... 132

HARD_FIXED Memory Pool ................................................................................................ 132

SOFT_FIXED Memory Pool .................................................................................................. 134

SOFT_DEMAND Memory Pool ............................................................................................ 134

Closing a Memory Pool ............................................................................................ 135

Referencing a Memory Pool ........................................................................................ 137

Memory Pool Operations ............................................................................................. 137

Memory Pool Operations in the Background ............................................................ 138

Getting a RAM Block ........................................................................................................... 138

Empty Fixed Memory Pool .............................................................................................. 138

Empty SOFT_DEMAND Memory Pool............................................................................. 139

Freeing a RAM Block ........................................................................................................... 140

Memory Pool Operations in the Foreground ............................................................ 140

Memory Pool Events .................................................................................................... 141

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 11 of 155

Associating a Memory Pool Event with an EAR .......................................................... 141

Background Tasks .................................................................................................... 142

Foreground Tasks and the Idle Task ........................................................................ 142

Memory Pool Services .................................................................................................... 143

Chapter 15 Mutex Class .................................................................................................. 144

Introduction ...................................................................................................................... 144

Mutex States ................................................................................................................ 144

Mutex and Semaphore Differences ............................................................................. 144

Nested Ownership .................................................................................................... 145

Using Mutexes ................................................................................................................. 145

Definition of a Mutex Object ......................................................................................... 145

Mutex Properties ...................................................................................................... 145

Creating a Mutex ...................................................................................................... 146

Closing a Mutex ........................................................................................................ 146

Referencing a Mutex .................................................................................................... 146

Mutex Operations ......................................................................................................... 146

Acquiring a Mutex ..................................................................................................... 147

Releasing a Mutex .................................................................................................... 148

Priority Inversion Handling ........................................................................................... 148

Mutex Services ................................................................................................................ 148

Chapter 16 Special Services ........................................................................................... 150

Appendix A ISR Examples ............................................................................................. 151

Cortex-Mx SysTick Driver with ISR ................................................................................. 151

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 12 of 155

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 ........................................................ 75

Example 8-6 Service Prototype to Create a Background Task ......................................... 77

Example 8-7 Current Task Reference Examples .............................................................. 77

Example 10-1 Alarm Properties ...................................................................................... 86

Example 10-2 Service Prototype to Create an Alarm ...................................................... 87

Example 10-3 Converting from Time to Ticks ................................................................. 88

Example 11-1 Event Group Properties Structure ............................................................ 97

Example 11-2 Service Prototype to Create an Event Group ........................................... 98

Example 12-1 Queue Properties Structure ................................................................... 110

Example 12-2 Service Prototype to Create a Queue .................................................... 111

Example 13-1 Semaphore Properties Structure ............................................................ 121

Example 13-2 Service Prototype to Create a Semaphore ............................................ 121

Example 14-1 Memory Pool Properties Structure ......................................................... 131

Example 14-2 Service Prototype to Create a Memory Pool .......................................... 132

Example 15-1 Mutex Properties Structure .................................................................... 145

Example 15-2 Service Prototype to Create a Mutex ..................................................... 146

Example A-1 Cortex-M0 SysTick Driver with ISR............................................................ 151

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 13 of 155

List of Figures Figure 2-1 Novos RRS 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-3 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 ............................................................................... 86

Figure 10-2a Alarm Activation ........................................................................................... 89

Figure 10-2b Alarm Activation with Earlier Expiration ....................................................... 90

Figure 10-3 Problem with One Tick Alarm Period ........................................................... 90

Figure 10-4 Testing an Alarm at Irregular Intervals ......................................................... 92

Figure 10-5 Alarm Associated with Event Action Routine ............................................... 94

Figure 11-1a One Task Waiting for an Event Group Match ............................................ 101

Figure 11-1b Two Tasks Waiting for an Event Group Match .......................................... 102

Figure 11-2 Event Group with Multiple Tests ................................................................ 104

Figure 12-1 One Queue Event Association with One Event Action Routine ................. 115

Figure 13-1 Semaphore State Transitions .................................................................... 119

Figure 13-2 Response Time for Semaphore Signal in RRS Scheduling ....................... 124

Figure 13-3 Use of EAR with Semaphore Event ........................................................... 127

Figure 14-1 Newly Created HARD_FIXED Memory Pool in Full State ........................ 133

Figure 14-2 Newly Created SOFT_DEMAND Memory Pool ......................................... 135

Figure 14-3 Full SOFT_DEMAND Memory Pool .............................................................. 137

Figure 14-4 SOFT_DEMAND Memory Pool with Two Blocks Assigned ....................... 140

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 14 of 155

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 RRS Supported Classes ...................................................................... 41

Table 5-1 Descriptions of DIH Properties ........................................................................ 54

Table 5-2 Novos RRS 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 RRS Services for EAR class ................................................................ 61

Table 7-1 Foreground Task Property Descriptions .......................................................... 64

Table 7-2 Novos RRS Services for Foreground Task class ............................................ 65

Table 8-1 Background Task Property Descriptions ......................................................... 75

Table 8-2 Background Task Class Services .................................................................... 79

Table 9-1 Timebase Counter States ................................................................................ 81

Table 9-2 Novos Timebase Counter Services ................................................................. 83

Table 10-1 Alarm States .................................................................................................... 85

Table 10-2 Alarm Properties Descriptions ......................................................................... 87

Table 10-3 Pend Options for Unexpired Alarms ................................................................ 91

Table 10-4 Alarm Event Definitions ................................................................................... 92

Table 10-5 Alarm Services ................................................................................................ 95

Table 11-1 Event Group States ......................................................................................... 96

Table 11-2 Event Group Property Descriptions ................................................................. 98

Table 11-3 Pend Options for Incomplete Queueing Operations ........................................ 99

Table 11-4 Boolean Operator and Flag Clearing Options ............................................... 100

Table 11-5 Event Group Services ................................................................................... 104

Table 12-1 Queue Transfer Modes ................................................................................. 107

Table 12-2 Queue States ................................................................................................ 109

Table 12-3 Queue Properties Descriptions ..................................................................... 110

Table 12-4 Pend Options for Incomplete Queueing Operations ...................................... 112

Table 12-5 Queue Transition Events ............................................................................... 113

Table 12-6 Queue Class Services ................................................................................... 116

Table 13-1 Semaphore States ......................................................................................... 118

Table 13-2 Semaphore Types ......................................................................................... 120

Table 13-3 Queue Properties Descriptions ..................................................................... 121

Table 13-4 Pend Options for Incomplete Semaphore Testing Operations ...................... 122

Table 13-5 Semaphore Events ........................................................................................ 126

Table 13-6 Semaphore Class Services ........................................................................... 127

Table 14-1 Memory Pool Types ...................................................................................... 130

Table 14-2 Memory Pool States ...................................................................................... 130

Table 14-3 Memory Pool Properties Descriptions ........................................................... 131

Table 14-4 Pend Options for Incomplete RAM Block Allocation Requests ..................... 138

Table 14-5 Memory Pool State Transition Events ........................................................... 141

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 15 of 155

Table 14-6 Memory Pool Class Services ........................................................................ 143

Table 15-1 Mutex States ................................................................................................. 144

Table 15-2 Mutex Properties Descriptions ...................................................................... 145

Table 15-3 Pend Options for Incomplete Mutex Acquisition Operations ......................... 147

Table 15-4 Mutex Class Services .................................................................................... 148

Table 16-1 Special Services ............................................................................................ 150

Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 16 of 155

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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 17 of 155

Chapter 1 How to Use This Guide

Scope of this Guide This document is intended to explain how the Novos Round Robin Scheduling (RRS) environment works and how it is organized to help you achieve a successful application development. It assumes the reader has a basic knowledge about developing embedded systems in general and the use of a Round Robin cooperative task scheduling in particular. In addition, it also assumes the reader understands how Foreground/Background systems generally work. It is not meant to be a tutorial on how to design or implement embedded applications based on such organizations or whether the Novos RRS environment is best for your application.

Because this document does not deal with the details of individual Novos RRS environment services, there is limited information about them herein except where they serve illustrative purposes. However, there is an accompanying manual, The Novos Round Robin Scheduling Environment Services Reference Guide, available for a small fee, which provides detailed usage information on all services in the Novos RRS environment. In combination with this guide, you should have an in-depth knowledge about successfully employing the Novos RRS 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 Round Robin Scheduling environment, your use of this publication and the related source code is limited to your personal use only.

Chapter 1: Novos RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 18 of 155

The Company has invested considerable time and expense in order to provide the source code for the Novos Round Robin 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 Round Robin 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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 19 of 155

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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 20 of 155

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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 21 of 155

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 RRS 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 RRS environment, including its input parameters, outputs, errors and completion codes is available in the aforementioned publication Novos Round Robin 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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 22 of 155

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 RRS 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 RRS 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 RRS 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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 23 of 155

Figure 2-1 Novos RRS 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 RRS Environment User Guide

Copyright © 2016 Embedded Environments Co.- All Rights Reserved Page 24 of 155

The default definition of LEVELS_8 for the Novos RRS 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;