RTEMS C User Documentation Release 4.11.2 ©Copyright 2016, RTEMS Project (Built 10Th July 2017)
Total Page:16
File Type:pdf, Size:1020Kb
RTEMS C User Documentation Release 4.11.2 ©Copyright 2016, RTEMS Project (built 10th July 2017) CONTENTS I RTEMS C User’s Guide1 1 Preface 3 2 Overview 7 2.1 Introduction......................................8 2.2 Real-time Application Systems............................9 2.3 Real-time Executive.................................. 10 2.4 RTEMS Application Architecture........................... 11 2.5 RTEMS Internal Architecture............................. 12 2.6 User Customization and Extensibility......................... 14 2.7 Portability....................................... 15 2.8 Memory Requirements................................. 16 2.9 Audience........................................ 17 2.10 Conventions...................................... 18 2.11 Manual Organization................................. 19 3 Key Concepts 23 3.1 Introduction...................................... 24 3.2 Objects......................................... 25 3.2.1 Object Names................................. 25 3.2.2 Object IDs................................... 25 3.2.2.1 Thirty-Two Object ID Format.................... 26 3.2.2.2 Sixteen Bit Object ID Format.................... 26 3.2.3 Object ID Description............................. 26 3.3 Communication and Synchronization........................ 28 3.4 Time.......................................... 29 3.5 Memory Management................................. 30 4 RTEMS Data Types 31 4.1 Introduction...................................... 32 4.2 List of Data Types................................... 33 5 Scheduling Concepts 37 5.1 Introduction...................................... 38 5.2 Scheduling Algorithms................................ 39 5.2.1 Priority Scheduling.............................. 39 5.2.2 Deterministic Priority Scheduler....................... 40 5.2.3 Simple Priority Scheduler.......................... 40 i 5.2.4 Simple SMP Priority Scheduler....................... 40 5.2.5 Earliest Deadline First Scheduler...................... 40 5.2.6 Constant Bandwidth Server Scheduling (CBS)............... 41 5.3 Scheduling Modification Mechanisms........................ 42 5.3.1 Task Priority and Scheduling......................... 42 5.3.2 Preemption.................................. 42 5.3.3 Timeslicing.................................. 42 5.3.4 Manual Round-Robin............................. 43 5.4 Dispatching Tasks................................... 44 5.5 Task State Transitions................................. 45 6 Initialization Manager 49 6.1 Introduction...................................... 50 6.2 Background....................................... 51 6.2.1 Initialization Tasks.............................. 51 6.2.2 System Initialization............................. 51 6.2.3 The Idle Task................................. 51 6.2.4 Initialization Manager Failure........................ 51 6.3 Operations....................................... 53 6.3.1 Initializing RTEMS.............................. 53 6.3.2 Shutting Down RTEMS............................ 54 6.4 Directives........................................ 55 6.4.1 INITIALIZE_EXECUTIVE - Initialize RTEMS................. 56 6.4.2 SHUTDOWN_EXECUTIVE - Shutdown RTEMS............... 57 7 Task Manager 59 7.1 Introduction...................................... 60 7.2 Background....................................... 61 7.2.1 Task Definition................................ 61 7.2.2 Task Control Block.............................. 61 7.2.3 Task States................................... 61 7.2.4 Task Priority.................................. 62 7.2.5 Task Mode................................... 62 7.2.6 Accessing Task Arguments.......................... 63 7.2.7 Floating Point Considerations........................ 63 7.2.8 Per Task Variables............................... 64 7.2.9 Building a Task Attribute Set......................... 64 7.2.10 Building a Mode and Mask.......................... 65 7.3 Operations....................................... 66 7.3.1 Creating Tasks................................. 66 7.3.2 Obtaining Task IDs.............................. 66 7.3.3 Starting and Restarting Tasks........................ 66 7.3.4 Suspending and Resuming Tasks....................... 66 7.3.5 Delaying the Currently Executing Task................... 67 7.3.6 Changing Task Priority............................ 67 7.3.7 Changing Task Mode............................. 67 7.3.8 Notepad Locations.............................. 67 7.3.9 Task Deletion................................. 67 7.3.10 Transition Advice for Obsolete Directives.................. 68 7.3.10.1 Notepads............................... 68 7.4 Directives........................................ 69 7.4.1 TASK_CREATE - Create a task........................ 70 ii 7.4.2 TASK_IDENT - Get ID of a task........................ 72 7.4.3 TASK_SELF - Obtain ID of caller....................... 73 7.4.4 TASK_START - Start a task.......................... 74 7.4.5 TASK_RESTART - Restart a task....................... 75 7.4.6 TASK_DELETE - Delete a task........................ 76 7.4.7 TASK_SUSPEND - Suspend a task...................... 77 7.4.8 TASK_RESUME - Resume a task....................... 78 7.4.9 TASK_IS_SUSPENDED - Determine if a task is Suspended......... 79 7.4.10 TASK_SET_PRIORITY - Set task priority................... 80 7.4.11 TASK_MODE - Change the current task mode............... 81 7.4.12 TASK_GET_NOTE - Get task notepad entry................. 82 7.4.13 TASK_SET_NOTE - Set task notepad entry................. 83 7.4.14 TASK_WAKE_AFTER - Wake up after interval................ 84 7.4.15 TASK_WAKE_WHEN - Wake up when specified............... 85 7.4.16 ITERATE_OVER_ALL_THREADS - Iterate Over Tasks............ 86 7.4.17 TASK_VARIABLE_ADD - Associate per task variable............ 87 7.4.18 TASK_VARIABLE_GET - Obtain value of a per task variable........ 88 7.4.19 TASK_VARIABLE_DELETE - Remove per task variable........... 89 8 Interrupt Manager 91 8.1 Introduction...................................... 92 8.2 Background....................................... 93 8.2.1 Processing an Interrupt............................ 93 8.2.2 RTEMS Interrupt Levels........................... 94 8.2.3 Disabling of Interrupts by RTEMS...................... 94 8.3 Operations....................................... 95 8.3.1 Establishing an ISR.............................. 95 8.3.2 Directives Allowed from an ISR....................... 95 8.4 Directives........................................ 98 8.4.1 INTERRUPT_CATCH - Establish an ISR................... 99 8.4.2 INTERRUPT_DISABLE - Disable Interrupts................. 100 8.4.3 INTERRUPT_ENABLE - Enable Interrupts.................. 101 8.4.4 INTERRUPT_FLASH - Flash Interrupts................... 102 8.4.5 INTERRUPT_LOCAL_DISABLE - Disable Interrupts on Current Processor 103 8.4.6 INTERRUPT_LOCAL_ENABLE - Enable Interrupts on Current Processor. 104 8.4.7 INTERRUPT_LOCK_INITIALIZE - Initialize an ISR Lock.......... 105 8.4.8 INTERRUPT_LOCK_ACQUIRE - Acquire an ISR Lock........... 106 8.4.9 INTERRUPT_LOCK_RELEASE - Release an ISR Lock............ 107 8.4.10 INTERRUPT_LOCK_ACQUIRE_ISR - Acquire an ISR Lock from ISR.... 108 8.4.11 INTERRUPT_LOCK_RELEASE_ISR - Release an ISR Lock from ISR.... 109 8.4.12 INTERRUPT_IS_IN_PROGRESS - Is an ISR in Progress.......... 110 9 Clock Manager 111 9.1 Introduction...................................... 112 9.2 Background....................................... 113 9.2.1 Required Support............................... 113 9.2.2 Time and Date Data Structures....................... 113 9.2.3 Clock Tick and Timeslicing.......................... 113 9.2.4 Delays..................................... 114 9.2.5 Timeouts.................................... 114 9.3 Operations....................................... 115 9.3.1 Announcing a Tick.............................. 115 iii 9.3.2 Setting the Time............................... 115 9.3.3 Obtaining the Time.............................. 115 9.4 Directives........................................ 116 9.4.1 CLOCK_SET - Set date and time....................... 117 9.4.2 CLOCK_GET - Get date and time information............... 118 9.4.3 CLOCK_GET_TOD - Get date and time in TOD format........... 119 9.4.4 CLOCK_GET_TOD_TIMEVAL - Get date and time in timeval format... 120 9.4.5 CLOCK_GET_SECONDS_SINCE_EPOCH - Get seconds since epoch.... 121 9.4.6 CLOCK_GET_TICKS_PER_SECOND - Get ticks per second......... 122 9.4.7 CLOCK_GET_TICKS_SINCE_BOOT - Get current ticks counter value... 123 9.4.8 CLOCK_TICK_LATER - Get tick value in the future............. 124 9.4.9 CLOCK_TICK_LATER_USEC - Get tick value in the future in microseconds 125 9.4.10 CLOCK_TICK_BEFORE - Is tick value is before a point in time...... 126 9.4.11 CLOCK_GET_UPTIME - Get the time since boot.............. 127 9.4.12 CLOCK_GET_UPTIME_TIMEVAL - Get the time since boot in timeval for- mat....................................... 128 9.4.13 CLOCK_GET_UPTIME_SECONDS - Get the seconds since boot...... 129 9.4.14 CLOCK_GET_UPTIME_NANOSECONDS - Get the nanoseconds since boot 130 10 Timer Manager 131 10.1 Introduction...................................... 132 10.2 Background....................................... 133 10.2.1 Required Support............................... 133 10.2.2 Timers..................................... 133 10.2.3 Timer Server................................. 133 10.2.4 Timer Service Routines............................ 133 10.3 Operations....................................... 134 10.3.1 Creating a Timer..............................