novos pps environment user guide · • novos fb, novos foreground/background, • novos efb, novos...

25
Novos PPS Environment User Guide Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 1 of 164 ------------------------------------------------ -

Upload: others

Post on 16-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

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

------------------------------------------------

-

Peter
Sample
Page 2: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 2 of 164

Copyrights Ownership of and all copyrights to this document and the Novos™ software environment as it relates to this document are held and/or reserved by Embedded Environments Co. (the “Company”). 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 the Company.

The Company further 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 you of such revisions or changes.

If you are not already familiar with its terms and conditions of use, please read the complete text of the Novos Documentation License, which is available at the Company website, www.ee-novos.com.

.

Disclaimers THIS DOCUMENTATION IS PROVIDED "AS-IS" AND WITHOUT ANY WARRANTY, INCLUDING BUT NOT LIMITED TO ANY EXPRESSED OR IMPLIED WARRANTY OF NON-INFRINGEMENT, SATISFACTORY QUALITY, MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY WHATSOEVER, INCLUDING DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM LOSS OF USE, DATA OR PROFITS OR BUSINESS INTERRUPTION, WHETHER IN AN ACTION OF CONTRACT, STRICT LIABILITY OR TORT, INCLUDING NEGLIGENCE, ARISING FROM OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS DOCUMENTATION.

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.

Page 3: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 3 of 164

Modification History

Version #

Date Author Revised Sections

2.01 22-Mar-2017 ATB Initial release

Page 4: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 4 of 164

Table of Contents Copyrights ............................................................................................................................. 2

Disclaimers ........................................................................................................................... 2

Trademarks ........................................................................................................................... 2

Modification History ............................................................................................................... 3

Table of Contents .................................................................................................................. 4

List of Examples .................................................................................................................. 13

List of Figures ..................................................................................................................... 14

List of Tables ...................................................................................................................... 15

Foreword ............................................................................................................................. 17

Chapter 1 How to Use This Guide ................................................................................... 18

Scope of this Guide ......................................................................................................... 18

Novos Usage ................................................................................................................... 18

Commercial Usage ....................................................................................................... 19

Errors and Inaccuracies ............................................................................................... 19

Conventions Used in This Guide ..................................................................................... 19

Cautions, Tips and Notes ............................................................................................. 19

Font and Capitalization Usage ..................................................................................... 20

Chapter 2 Novos Environments for Embedded Systems ................................................. 21

Source Code ................................................................................................................... 21

Common Code and Headers ........................................................................................ 22

Novos Environment APIs ............................................................................................. 22

Port-Specific Code and Headers .................................................................................. 22

Core Functions ............................................................................................................. 23

Configuring ...................................................................................................................... 23

System Processing Priority Queue Size ....................................................................... 23

Enumerated Values of DIH Priorities ............................................................................ 25

Enumerated Values of FG Task Priorities .................................................................... 26

Stack Alignment ........................................................................................................... 27

Parametric Diagnostics ................................................................................................ 27

Terminal Error Return Mode ......................................................................................... 27

Compiling ........................................................................................................................ 28

Object Classes ................................................................................................................ 28

Class Properties ........................................................................................................... 28

Objects ............................................................................................................................ 29

Object Properties ......................................................................................................... 29

Page 5: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 5 of 164

Object Identifiers .......................................................................................................... 29

Creating Objects .......................................................................................................... 29

Allocating RAM for an Object .................................................................................... 30

Object Header .......................................................................................................... 30

Terminal Errors ................................................................................................................ 31

Terminal Error Packet .................................................................................................. 32

Terminal Error Handler ................................................................................................. 32

Exiting the Terminal Error Handler ............................................................................ 32

User-Defined Terminal Error Handler ....................................................................... 33

Application Program Interface (API)................................................................................. 33

The Service Name ....................................................................................................... 33

Service Completion Code ............................................................................................. 33

Usage Target ................................................................................................................... 34

Chapter 3 The Novos Pre-emptive Priority Scheduling (PPS) Environment .................... 35

Introduction ...................................................................................................................... 35

Features .......................................................................................................................... 36

Planes of Operation ......................................................................................................... 37

Interrupt Plane ............................................................................................................. 37

Foreground Plane ........................................................................................................ 37

Background Plane ........................................................................................................ 37

Stacks ............................................................................................................................. 38

Stack Orientation ......................................................................................................... 38

Guard Words ................................................................................................................ 38

System Stack ............................................................................................................... 39

Background Stacks ...................................................................................................... 39

System Initialization ......................................................................................................... 39

System Properties ........................................................................................................ 40

System RAM ............................................................................................................ 40

User RAM ................................................................................................................. 40

System Stack............................................................................................................ 41

Idle Task Stack ......................................................................................................... 41

System Processing Priority Queue ........................................................................... 41

Classes ........................................................................................................................... 42

Foreground Execution Entities ......................................................................................... 43

Foreground Execution Support .................................................................................... 43

Foreground Entity Control Block ............................................................................... 44

Foreground Carrier Packet ....................................................................................... 44

Page 6: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 6 of 164

Deferred Interrupt Handler ........................................................................................... 45

Event Action Routine .................................................................................................... 46

Foreground Tasks ........................................................................................................ 46

Background Execution Entities (Tasks) ........................................................................... 46

Reusing User RAM .......................................................................................................... 47

Used RAM List ............................................................................................................. 47

Chapter 4 Interrupt Processing ....................................................................................... 49

Introduction ...................................................................................................................... 49

Interrupt Processing Sequence ........................................................................................ 49

Interrupt Vectors .......................................................................................................... 50

Starting an ISR ............................................................................................................. 50

Preserving the Interrupted CPU Context ................................................................... 51

Switching Stacks in an ISR ....................................................................................... 51

Immediate Interrupt Handling ....................................................................................... 51

Form of the IIH .......................................................................................................... 52

Scheduling the Deferred Interrupt Handler ................................................................ 52

Ending an ISR .............................................................................................................. 52

Deferred Interrupt Handler (DIH) .................................................................................. 52

Example ISR ................................................................................................................... 53

Chapter 5 Deferred Interrupt Handlers ............................................................................ 54

Introduction ...................................................................................................................... 54

States of a DIH ............................................................................................................. 54

Using Deferred Interrupt Handlers ................................................................................... 55

Definition of a DIH Object ............................................................................................. 55

DIH Properties .......................................................................................................... 55

Creating a DIH .......................................................................................................... 56

Referencing a DIH........................................................................................................ 57

DIH Services ................................................................................................................... 57

DIH Example ................................................................................................................... 57

Chapter 6 Event Action Routines .................................................................................... 58

Introduction ...................................................................................................................... 58

States of an EAR ......................................................................................................... 58

Using Event Action Routines ........................................................................................... 58

Definition of an EAR Object .......................................................................................... 59

EAR Properties ......................................................................................................... 59

Creating an EAR ....................................................................................................... 60

Referencing an EAR .................................................................................................... 60

Page 7: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 7 of 164

EAR-Event Association Options ............................................................................... 60

Multiple EARs Associated with an Event................................................................... 61

Execution of an EAR................................................................................................. 61

EAR Services .................................................................................................................. 62

EAR Example .................................................................................................................. 62

Chapter 7 Foreground Tasks .......................................................................................... 63

Introduction ...................................................................................................................... 63

Using FG Tasks ............................................................................................................... 63

Definition of a FG Task Object ..................................................................................... 64

FG Task Properties .................................................................................................. 65

Creating a FG Task .................................................................................................. 66

Referencing a FG Task ................................................................................................ 66

FG Task Services ............................................................................................................ 66

Chapter 8 Background Tasks .......................................................................................... 67

Introduction ...................................................................................................................... 67

Task Control Block ....................................................................................................... 67

The Idle Task ............................................................................................................... 68

Current Task ................................................................................................................ 68

Pre-emption ................................................................................................................. 68

Background Ready List ................................................................................................ 69

Task Scheduling .......................................................................................................... 71

What is a Task? ............................................................................................................... 71

Task Code Template .................................................................................................... 72

Infinite Life Model ..................................................................................................... 72

Finite Life Model ....................................................................................................... 73

Task Priority ................................................................................................................. 74

Background Task States .............................................................................................. 74

INITIALIZED State .................................................................................................... 74

READY State ............................................................................................................ 74

RUNNING State ....................................................................................................... 74

BLOCKED State ....................................................................................................... 75

CLOSED State ......................................................................................................... 75

Using Background Tasks ................................................................................................. 76

Definition of a Background Task ................................................................................... 76

Background Task Properties ..................................................................................... 76

Task Stack .............................................................................................................................. 77

Page 8: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 8 of 164

Time Quantum ...................................................................................................................... 77

Choosing a Time Quantum ................................................................................................ 78

Creating a Background Task .................................................................................... 78

Referencing a Background Task .................................................................................. 78

Referencing the Current Task ................................................................................... 79

Referencing the Idle Task ......................................................................................... 79

Background Task Events ............................................................................................. 79

Background Task Operations ....................................................................................... 80

Closing a Background Task ...................................................................................... 80

Terminating a Background Task ............................................................................... 80

Aborting a Background Task ..................................................................................... 81

Background Task Services .............................................................................................. 81

Chapter 9 Timebase Counter .......................................................................................... 83

Introduction ...................................................................................................................... 83

Timebase Counter States............................................................................................. 83

Using the Timebase Counter ........................................................................................... 84

Definition of the Timebase Counter .............................................................................. 84

Timebase Counter Properties ................................................................................... 84

Creating the Timebase Counter ................................................................................ 84

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

Referencing the Timebase Counter .............................................................................. 85

Timebase Counter Services ............................................................................................ 85

Chapter 10 Alarms .......................................................................................................... 86

Introduction ...................................................................................................................... 86

Alarm Types ................................................................................................................. 86

One-Shot Alarms ...................................................................................................... 86

Cyclic Alarms ............................................................................................................ 87

Alarm States .................................................................................................................... 87

Using Alarms ................................................................................................................... 88

Definition of an Alarm Object ........................................................................................ 88

Alarm Properties ....................................................................................................... 88

Creating an Alarm ..................................................................................................... 89

Closing an Alarm ...................................................................................................... 89

Referencing an Alarm .................................................................................................. 90

Conversion from Time to Ticks ..................................................................................... 90

Relative Time............................................................................................................ 90

Page 9: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 9 of 164

Alarm Period Ambiguity ............................................................................................ 92

Testing an Alarm .......................................................................................................... 93

Alarm Events ................................................................................................................ 94

Associating an Alarm Event with an EAR ..................................................................... 95

Alarm Services ................................................................................................................ 97

Chapter 11 Event Groups ............................................................................................... 98

Introduction ...................................................................................................................... 98

Event Group States ...................................................................................................... 98

Using Event Groups ........................................................................................................ 99

Definition of an Event Group Object ............................................................................. 99

Event Group Properties ............................................................................................ 99

Creating an Event Group ........................................................................................ 100

Closing an Event Group .......................................................................................... 100

Referencing an Event Group ...................................................................................... 100

Testing Event Group Flags ......................................................................................... 100

Boolean Operators ................................................................................................. 101

Testing from a Background Task ............................................................................ 102

Multiple Tests on an Event Group ........................................................................... 103

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

Event Group Events ................................................................................................... 104

Associating an Event Group Event with an EAR ........................................................ 105

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

Event Group Services .................................................................................................... 106

Chapter 12 Queues ....................................................................................................... 108

Introduction .................................................................................................................... 108

Queue Producer ......................................................................................................... 108

Multiple Producers .................................................................................................. 109

Queue Consumer ....................................................................................................... 109

Multiple Consumers ................................................................................................ 109

Data Transfer Modes ................................................................................................. 109

Order of Data Movement ............................................................................................ 110

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

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

Peeking in a Queue ................................................................................................ 110

Queue States ................................................................................................................ 110

Using Queues ................................................................................................................ 111

Page 10: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 10 of 164

Definition of a Queue Object ...................................................................................... 111

Queue Properties ................................................................................................... 111

Creating a Queue ................................................................................................... 112

Closing a Queue ..................................................................................................... 113

Referencing a Queue ................................................................................................. 113

Queue Operations ...................................................................................................... 113

Queue Operations in a Background Task ............................................................... 114

Queue Operations in a Foreground Entity ............................................................... 115

Queue Events ............................................................................................................ 115

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

Background Tasks .................................................................................................. 116

Foreground Tasks and the Idle Task ...................................................................... 118

Queue Services ............................................................................................................. 118

Chapter 13 Semaphores ............................................................................................... 119

Introduction .................................................................................................................... 119

Semaphore States ..................................................................................................... 120

Using Semaphores ........................................................................................................ 122

Definition of a Semaphore Object ............................................................................... 122

Semaphore Types .................................................................................................. 122

Semaphore Properties ............................................................................................ 122

Creating a Semaphore ............................................................................................ 123

Closing a Semaphore ............................................................................................. 123

Referencing a Semaphore ......................................................................................... 124

Semaphore Operations .............................................................................................. 124

Semaphore Operations in the Background ............................................................. 125

Posting a Signal ................................................................................................................... 125

Testing for a Posted Signal .................................................................................................. 126

Semaphore Operations in the Foreground .............................................................. 128

Semaphore Events..................................................................................................... 128

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

Semaphore Services ..................................................................................................... 131

Chapter 14 Memory Pools .............................................................................................. 132

Introduction .................................................................................................................... 132

Memory Pool Types ................................................................................................... 132

Memory Pool States ................................................................................................... 133

Using Memory Pools ..................................................................................................... 134

Page 11: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 11 of 164

Definition of a Memory Pool Object ............................................................................ 134

Memory Pool Properties ......................................................................................... 134

Creating a Memory Pool ......................................................................................... 135

HARD_FIXED Memory Pool ................................................................................................ 135

SOFT_FIXED Memory Pool .................................................................................................. 137

SOFT_DEMAND Memory Pool ............................................................................................ 137

Closing a Memory Pool ........................................................................................... 138

Referencing a Memory Pool ....................................................................................... 140

Memory Pool Operations............................................................................................ 140

Memory Pool Operations in the Background ........................................................... 141

Getting a RAM Block ........................................................................................................... 141

Empty Fixed Memory Pool .............................................................................................. 141

Empty SOFT_DEMAND Memory Pool............................................................................. 142

Freeing a RAM Block ........................................................................................................... 143

Memory Pool Operations in the Foreground ........................................................... 143

Memory Pool Events .................................................................................................. 144

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

Background Tasks .................................................................................................. 145

Foreground Tasks and the Idle Task ...................................................................... 145

Memory Pool Services ................................................................................................... 146

Chapter 15 Mutex Class ................................................................................................. 147

Introduction .................................................................................................................... 147

Mutex States .............................................................................................................. 147

Mutex and Semaphore Differences ............................................................................ 148

Nested Ownership .................................................................................................. 148

Priority Inversion Management ............................................................................... 148

Using Mutexes ............................................................................................................... 148

Definition of a Mutex Object ....................................................................................... 148

Mutex Properties .................................................................................................... 148

Creating a Mutex .................................................................................................... 149

Closing a Mutex ...................................................................................................... 149

Referencing a Mutex .................................................................................................. 150

Mutex Operations ....................................................................................................... 150

Acquiring a Mutex ................................................................................................... 151

Releasing a Mutex .................................................................................................. 151

Priority Inversion Handling ......................................................................................... 152

Page 12: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 12 of 164

Immediate Inheritance Protocol .............................................................................. 152

Basic Inheritance Protocol ...................................................................................... 153

Mutex Services .............................................................................................................. 153

Chapter 16 Special Services .......................................................................................... 155

Enabling/Disabling Task Scheduling .............................................................................. 155

Appendix A ISR Example ............................................................................................ 157

MSP430 Periodic Interrupt Driver with ISR .................................................................... 157

Appendix B Task Termination and Abortion .............................................................. 160

Introduction .................................................................................................................... 160

Task Termination ....................................................................................................... 160

Task Aborting ............................................................................................................. 160

Event Action Routines ................................................................................................ 161

ON_TERMINATE Event Action Routine.................................................................. 161

ON_ABORT Event Action Routine .......................................................................... 161

Example ........................................................................................................................ 161

Page 13: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 13 of 164

List of Examples Example 1-1 Code example ............................................................................................ 20

Example 2-1 Definition of Size of System Processing Priority Queue .............................. 23

Example 2-2 Default DIH Priority Definitions ................................................................... 25

Example 2-3 Default Foreground Task Priority Definitions .............................................. 26

Example 2-4 Stack Alignment Definition .......................................................................... 27

Example 2-5 Class Properties Structure .......................................................................... 28

Example 2-6 Object Header Structure ............................................................................. 30

Example 2-7 Terminal Error Packet ................................................................................ 32

Example 2-8 Novos Service Name Conventions ............................................................. 33

Example 3-1 System Properties Structure ....................................................................... 40

Example 3-2 Used Block Header Structure ..................................................................... 47

Example 5-1 Service to Schedule a DIH ......................................................................... 55

Example 5-2 Deferred Interrupt Handler Property Structure ............................................ 55

Example 5-2 Service Prototype to Create a DIH ............................................................. 56

Example 6-1 Event Action Routine Property Structure .................................................... 59

Example 6-2 Service Prototype to Create an EAR .......................................................... 60

Example 7-1 Foreground Task Property Structure .......................................................... 65

Example 7-2 Service Prototype to Create a Foreground Task ......................................... 66

Example 8-1 Task Code Prototype .................................................................................. 72

Example 8-2 Infinite Life Task Model .............................................................................. 72

Example 8-3 Finite Life Task Model (Using Conditional) ................................................. 73

Example 8-4 Finite Life Task Model (Using Count).......................................................... 73

Example 8-5 Background Task Properties Structure ....................................................... 76

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

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

Example 10-1 Alarm Properties ..................................................................................... 88

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

Example 10-3 Conversion of Time to Ticks.................................................................... 90

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

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

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

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

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

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

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

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

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

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

Example A-1 MSP430 Periodic Interrupt Driver with ISR ............................................... 157

Page 14: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 14 of 164

List of Figures Figure 2-1 Novos PPS Default SPPQ Organization ........................................................ 24

Figure 2-2 SPPQ Priority Level Mapping ......................................................................... 25

Figure 3-1 The Empty SPPQ .......................................................................................... 42

Figure 3-2 SPPQ with One FGE Scheduled .................................................................... 45

Figure 3-3 Used RAM List Organization .......................................................................... 48

Figure 7-1 Time Triggered Rate Monotonic Scheduling Example .................................... 64

Figure 8-1 Initial Background Ready List ......................................................................... 69

Figure 8-2 BRL with TASK_C Added .............................................................................. 70

Figure 8-3 Current Task and BRL Changes .................................................................... 70

Figure 8-4 Task State Transitions ................................................................................... 75

Figure 10-1 Alarm State Transitions .............................................................................. 88

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

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

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

Figure 10-4 Testing a Cyclic Alarm ................................................................................ 94

Figure 10-5a Alarm Response with PP Scheduling ......................................................... 95

Figure 10-5b Low Latency Response to Alarm Expiration Using an EAR ........................ 96

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

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

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

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

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

Figure 13-2a Response Time for High Priority Task to Semaphore Signal Post ............ 127

Figure 13-2b Response Time for Low Priority Task to Semaphore Signal Post ............. 128

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

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

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

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

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

Page 15: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 15 of 164

List of Tables Table 2-1 Novos Environment Names and Abbreviations .............................................. 22

Table 2-2 Descriptions of Object Header Properties ...................................................... 30

Table 3-1 Special Services allowed in the IIH ................................................................ 37

Table 3-2 Novos PPS Supported Classes ..................................................................... 43

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

Table 5-2 Novos PPS Services for DIH class ................................................................. 57

Table 6-1 EAR Property Descriptions ............................................................................ 59

Table 6-2 Options for Managing EAR and Event Associations ....................................... 61

Table 6-3 Novos PPS Services for EAR class ............................................................... 62

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

Table 7-2 Novos PPS Services for Foreground Task class ............................................ 66

Table 8-1 Background Task Properties Descriptions ..................................................... 77

Table 8-2 Task Events ................................................................................................... 79

Table 8-3 Background Task Class Services................................................................... 81

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

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

Table 10-1 Alarm States .................................................................................................. 87

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

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

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

Table 10-5 Alarm Services ............................................................................................... 97

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

Table 11-2 Event Group Properties Descriptions ........................................................... 100

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

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

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

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

Table 12-2 Queue States ............................................................................................... 111

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

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

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

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

Table 13-1 Semaphore States ....................................................................................... 120

Table 13-2 Semaphore Types ....................................................................................... 122

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

Table 13-4 Options for Incomplete Semaphore Testing Operations ............................... 125

Table 13-5 Semaphore Events ...................................................................................... 129

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

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

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

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

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

Page 16: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 16 of 164

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

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

Table 15-1 Mutex States ................................................................................................ 147

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

Table 15-3 Options for Incomplete Mutex Acquisition Operations .................................. 150

Table 15-4 Priority Inversion Handling Protocol Options ................................................ 152

Table 15-5 Semaphore Class Services .......................................................................... 153

Table 16-1 Special Services .......................................................................................... 155

Page 17: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 17 of 164

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 8-, 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

Page 18: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 1: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 18 of 164

Chapter 1 How to Use This Guide

Scope of this Guide This document is intended to explain how the Novos Pre-emptive Priority Scheduling (PPS) 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, how Foreground/Background systems work in general and the use of a Pre-emptive Priority task scheduler in particular. It also assumes the reader understands the cooperative task scheduling policies of First Come, First Served and Round Robin work as they are included in the Novos PPS environment. It is not meant to be a tutorial on how to design or implement embedded applications based on such organizations.

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 Pre-emptive Priority Scheduling Environment Services Reference Guide, available for a small fee, which provides detailed usage information on all services in the Novos PPS environment. In combination with this guide, you should have an in-depth knowledge about successfully employing the Novos PPS 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 Foreground/Background environment, your use of this publication and the related source code is limited to your personal use only.

Page 19: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 1: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 19 of 164

The Company has invested considerable time and expense in order to provide the source code for the Novos Pre-emptive Priority 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 Pre-emptive Priority 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.

Page 20: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 1: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 20 of 164

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 */

}

Page 21: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 2: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 21 of 164

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.

Page 22: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 2: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 22 of 164

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 PPS 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 PPS environment, including its input parameters, outputs, errors and completion codes is available in the aforementioned publication Novos Pre-emptive Priority 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

Page 23: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 2: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 23 of 164

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

Page 24: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 2: Novos PPS Environment User Guide

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

Figure 2-1 Novos PPS 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.

Page 25: Novos PPS Environment User Guide · • Novos FB, Novos Foreground/Background, • Novos EFB, Novos Extended Foreground/Background, • Novos FCFS, Novos First Come, First Served

Chapter 2: Novos PPS Environment User Guide

Copyright © 2017 Embedded Environments Co.- All Rights Reserved Page 25 of 164

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

Peter
Sample