No 4 Guide
No 4 Guide
“NORTi Version 4”, a product that is confidently supplied to you by MiSPO Co., Ltd., is
the real-time OS based on the μITRON specifications as exhibited by TRON association.
This product has implemented all the system calls in the μITRON 4.0 specifications
(except the definition of the CPU sample handler). Furthermore, it is compatible with
system calls of NORTi3 (μITRON3.0 specification), so that the previous version of
software components can be utilized without any modification.
NORTi is a compact and development friendly OS designed exclusively for Embedded
Systems. Just similar to compiler library, NORTi OS functions are operational after
linking NORTi libraries with user application program.
NORTi includes the TCP/IP protocol stack conforming to “ITRON TCP/IP API
specification” and is suitable for operations with Embedded Systems. Using NORTi, the
correspondence is very fast for embedded systems development using network
connection with indispensable technology.
For your system developments, please use the highly efficient and compact NORTi OS,
which comes with all source code as standard attachment without any royalty charges.
Disclaimer
Although the contents of this document are intended to describe the correct operation, MiSPO
Co., Ltd. does not guaranty the complete error free operation. MiSPO Co., Ltd. assumes no
liability for any errors or insufficient contents in this document.
MISPO Co., Ltd. reserves the right to change the contents of this document without prior notice.
Trademarks
NORTi® is the registered trademark of MiSPO Co., Ltd. Other brands and product names
specified in this document are trademarks or registered trademarks of the respective company.
μITRON is the abbreviated name of Micro Industrial TRON.
TRON is the abbreviated name of The Realtime Operating system Nucleus.
Index
Preface
About This Documentation .................................................................................................................. 1
Reference ............................................................................................................................................ 1
Index
1. Basic Particulars
1.1 Features......................................................................................................................................... 1
High Speed Response ..................................................................................................................... 1
Compact Size................................................................................................................................... 1
Kernel Designed with C source code............................................................................................... 1
Conformity to both μITRON4.0 and μITRON3.0 Specifications ...................................................... 1
Full Set of μITRON........................................................................................................................... 1
Corresponds to verities of processors, Compilers and Debuggers ................................................. 1
1.2 Task States .................................................................................................................................... 2
Ready to Run State (READY).......................................................................................................... 3
Run State (RUNNING)..................................................................................................................... 3
Wait State (WAITING)...................................................................................................................... 3
Suspend State (SUSPENDED) ....................................................................................................... 3
Suspended Wait State (WAITING-SUSPENDED) .......................................................................... 4
Dormant State (DORMANT) ............................................................................................................ 4
Non-Existent State (NON-EXISTENT)............................................................................................. 4
Task Switching Instances ................................................................................................................ 4
Differences from NORTi3................................................................................................................. 5
1.3 Terminology ................................................................................................................................... 6
Object and ID ................................................................................................................................... 6
Context............................................................................................................................................. 6
Task Independent Context............................................................................................................... 6
Dispatch ........................................................................................................................................... 6
Synchronization / Communication Functions................................................................................... 7
Queue .............................................................................................................................................. 7
Queuing............................................................................................................................................ 7
Polling and Timeout ......................................................................................................................... 8
Parameter and Return-Parameter ................................................................................................... 8
System Call and Service Call........................................................................................................... 8
Exclusive Control ............................................................................................................................. 8
Idle Task........................................................................................................................................... 8
Static Error and Dynamic Error ........................................................................................................ 9
Context Error.................................................................................................................................... 9
Static API and Dynamic API ............................................................................................................ 9
1.4 Common Conventions ................................................................................................................. 10
System call name........................................................................................................................... 10
Data type name.............................................................................................................................. 10
Argument name ............................................................................................................................. 10
Index 1
Handling zeros and negative numbers .......................................................................................... 10
1.5 Data Types (for 32-bit CPU) ........................................................................................................ 11
General purpose data type ............................................................................................................ 11
ITRON dependent data types ........................................................................................................ 11
Time related data types ................................................................................................................. 12
Differences from NORTi3............................................................................................................... 12
1.6 Data Types (for 16-bit CPU) ........................................................................................................ 13
General purpose data types .......................................................................................................... 13
ITRON-dependent data types........................................................................................................ 13
Time related data types ................................................................................................................. 14
Differences from NORTi3............................................................................................................... 14
2. Introduction
2.1 Installation.................................................................................................................................... 16
Include files .................................................................................................................................... 16
Library ............................................................................................................................................ 17
Source files .................................................................................................................................... 17
Sample ........................................................................................................................................... 17
2.2 Kernel configuration ..................................................................................................................... 18
Default configuration values........................................................................................................... 18
Customization of configuration ...................................................................................................... 18
Timer queue size ........................................................................................................................... 19
Interrupt handler stack size............................................................................................................ 19
Timer event handler stack size ...................................................................................................... 20
System memory and management block sizes ............................................................................. 20
Memory size of a memory-pool ..................................................................................................... 21
Size of a stack memory.................................................................................................................. 21
About dynamic memory management ........................................................................................... 22
Interrupt-inhibit level of a kernel..................................................................................................... 22
ID Definition ................................................................................................................................... 23
Automatic assignment of ID ........................................................................................................... 23
2.3 Example of creation of user program........................................................................................... 24
Example of compilation.................................................................................................................. 25
3. Task and Handler Description
3.1 Task description........................................................................................................................... 26
Task description method................................................................................................................ 26
Example of task description ........................................................................................................... 26
Interrupt mask state ....................................................................................................................... 27
Task Exception handler routine ..................................................................................................... 27
3.2 Interrupt service routine and interrupt handler description .......................................................... 28
Overview ........................................................................................................................................ 28
Interrupt service routine definition method..................................................................................... 28
Interrupt mask state ....................................................................................................................... 28
Interrupt handler definition method ................................................................................................ 28
Sample description of interrupt handler ......................................................................................... 29
ent_int system call ......................................................................................................................... 29
Unnecessary instructions before ent_int........................................................................................ 29
Index 2
Prohibition of auto variables........................................................................................................... 30
Suppression of inline expansion .................................................................................................... 30
Description by partial assembly code ............................................................................................ 30
Interrupt mask state ....................................................................................................................... 30
3.3 Timer event handler description .................................................................................................. 31
Overview ........................................................................................................................................ 31
Timer event handler definition method .......................................................................................... 31
Interrupt mask state ....................................................................................................................... 31
Additional note ............................................................................................................................... 32
3.4 Initialization handler ..................................................................................................................... 33
Start-up routine .............................................................................................................................. 33
main function.................................................................................................................................. 33
System initialization ....................................................................................................................... 33
I/O initialization............................................................................................................................... 33
Object creation............................................................................................................................... 34
Task start ....................................................................................................................................... 34
Cyclic timer interrupt start .............................................................................................................. 34
System start ................................................................................................................................... 34
Example description of initialization handler.................................................................................. 35
4. Function Overview
4.1 Task management functions........................................................................................................ 36
Overview ........................................................................................................................................ 36
Differences with NORTi3 ............................................................................................................... 36
Task management block................................................................................................................ 36
Scheduling and ready queue ......................................................................................................... 37
4.2 Task dependent synchronization functions ................................................................................. 38
Overview ........................................................................................................................................ 38
Differences with NORTi3 ............................................................................................................... 38
Waiting and releasing .................................................................................................................... 38
Suspend and resume..................................................................................................................... 38
Suspended waiting......................................................................................................................... 39
4.3 Task exception handling functions............................................................................................... 40
Overview ........................................................................................................................................ 40
Differences from NORTi3............................................................................................................... 40
Start and end of exception handling routine .................................................................................. 40
Exception factor ............................................................................................................................. 40
4.4 Synchronization / communication function (Semaphore) ............................................................ 41
Overview ........................................................................................................................................ 41
Differences from NORTi3............................................................................................................... 41
Semaphore waiting queue ............................................................................................................. 41
Semaphore count value ................................................................................................................. 42
4.5 Synchronization / communication function (Event flag)............................................................... 43
Overview ........................................................................................................................................ 43
Differences from NORTi3............................................................................................................... 43
Event flag waiting queue................................................................................................................ 43
Waiting mode ................................................................................................................................. 44
Index 3
Clear order ..................................................................................................................................... 44
4.6 Synchronization / communication function (Data Queue) ........................................................... 45
Overview ........................................................................................................................................ 45
Differences from NORTi3............................................................................................................... 45
Queuing.......................................................................................................................................... 45
Data order ...................................................................................................................................... 45
4.7 Synchronization / communication function (Mail box) ................................................................. 46
Overview ........................................................................................................................................ 46
Differences from NORTi3............................................................................................................... 46
Message queuing........................................................................................................................... 46
Message queue ............................................................................................................................. 47
Message packet domain ................................................................................................................ 47
4.8 Extended synchronization / communication function (Mutex) ..................................................... 48
Overview ........................................................................................................................................ 48
Differences from NORTi3............................................................................................................... 48
Priority inversion ............................................................................................................................ 48
4.9 Extended synchronization / communication function (Message buffer) ...................................... 49
Overview ........................................................................................................................................ 49
Differences from NORTi3............................................................................................................... 49
Message queue ............................................................................................................................. 49
Message reception waiting queue ................................................................................................. 49
Message transmission waiting queue............................................................................................ 50
Ring buffer section ......................................................................................................................... 50
Ring buffer of size 0 ....................................................................................................................... 51
4.10 Extended synchronization/communication function (rendezvous port) ..................................... 52
Overview ........................................................................................................................................ 52
Differences from NORTi3............................................................................................................... 52
Fundamental flow for rendezvous port operation .......................................................................... 52
Rendezvous transfer...................................................................................................................... 53
Conditions for rendezvous operation ............................................................................................. 53
Message......................................................................................................................................... 54
Rendezvous reception waiting queue............................................................................................ 54
Rendezvous call waiting queue ..................................................................................................... 54
4.11 Interrupt management function.................................................................................................. 55
Overview ........................................................................................................................................ 55
Differences from NORTi3............................................................................................................... 55
Definition of interrupt handler and interrupt service routine........................................................... 55
Prohibiting and permitting individual interrupt................................................................................ 55
Start of Interrupt handler ................................................................................................................ 55
Start of interrupt service routine..................................................................................................... 56
RISC processor interrupt ............................................................................................................... 56
Interrupt routine of priority higher than kernel................................................................................ 56
4.12 Memory pool management function .......................................................................................... 57
Overview ........................................................................................................................................ 57
Differences from NORTi3............................................................................................................... 57
Memory block waiting queue ......................................................................................................... 57
Index 4
Combination with sending and receiving messages...................................................................... 58
Variable length and fixed length .................................................................................................... 58
Multiple memory pools ................................................................................................................... 58
4.13 Time management functions ..................................................................................................... 59
Overview ........................................................................................................................................ 59
Differences from NORTi3............................................................................................................... 59
System time and system clock ...................................................................................................... 59
Cyclic handler ................................................................................................................................ 60
Alarm handler................................................................................................................................. 60
Overrun handler ............................................................................................................................. 60
4.14 Extended service call management function ............................................................................. 61
Overview ........................................................................................................................................ 61
Differences from NORTi3............................................................................................................... 61
Extended service call routine description ...................................................................................... 61
4.15 System state management function .......................................................................................... 62
Overview ........................................................................................................................................ 62
Differences from NORTi3............................................................................................................... 62
Control of the order of task execution............................................................................................ 62
4.16 System configuration management functions............................................................................ 63
Differences from NORTi3............................................................................................................... 63
Un-supported functions.................................................................................................................. 63
5. System Call Description
5.1 Task management functions........................................................................................................ 64
cre_tsk............................................................................................................................................ 64
acre_tsk.......................................................................................................................................... 66
del_tsk............................................................................................................................................ 67
act_tsk............................................................................................................................................ 68
iact_tsk ........................................................................................................................................... 68
can_act........................................................................................................................................... 70
sta_tsk............................................................................................................................................ 71
ext_tsk............................................................................................................................................ 72
exd_tsk........................................................................................................................................... 73
ter_tsk ............................................................................................................................................ 74
chg_pri ........................................................................................................................................... 75
get_pri ............................................................................................................................................ 77
ref_tsk ............................................................................................................................................ 78
ref_tst ............................................................................................................................................. 80
5.2 Task associated synchronization functions ................................................................................. 81
sus_tsk ........................................................................................................................................... 81
rsm_tsk........................................................................................................................................... 82
frsm_tsk.......................................................................................................................................... 83
slp_tsk ............................................................................................................................................ 84
tslp_tsk ........................................................................................................................................... 85
wup_tsk .......................................................................................................................................... 87
iwup_tsk ......................................................................................................................................... 87
can_wup......................................................................................................................................... 89
Index 5
vcan_wup ....................................................................................................................................... 90
rel_wai............................................................................................................................................ 91
irel_wai ........................................................................................................................................... 91
dly_tsk ............................................................................................................................................ 92
5.3 Task exception handling functions............................................................................................... 93
def_tex ........................................................................................................................................... 93
ras_tex ........................................................................................................................................... 95
iras_tex........................................................................................................................................... 95
dis_tex............................................................................................................................................ 96
ena_tex .......................................................................................................................................... 97
sns_tex........................................................................................................................................... 98
ref_tex ............................................................................................................................................ 99
5.4 Synchronization / communication functions (Semaphore) ........................................................ 100
cre_sem ....................................................................................................................................... 100
acre_sem ..................................................................................................................................... 102
del_sem........................................................................................................................................ 103
sig_sem........................................................................................................................................ 104
isig_sem ....................................................................................................................................... 104
wai_sem ....................................................................................................................................... 105
pol_sem........................................................................................................................................ 106
twai_sem ...................................................................................................................................... 107
ref_sem ........................................................................................................................................ 108
5.5 Synchronization / communication functions (Event flag) ........................................................... 109
cre_flg .......................................................................................................................................... 109
acre_flg ........................................................................................................................................ 111
del_flg........................................................................................................................................... 112
set_flg........................................................................................................................................... 113
iset_flg.......................................................................................................................................... 113
clr_flg............................................................................................................................................ 115
wai_flg .......................................................................................................................................... 116
pol_flg........................................................................................................................................... 118
twai_flg ......................................................................................................................................... 119
ref_flg ........................................................................................................................................... 121
5.6 Synchronization / communication functions (Data queue) ........................................................ 122
cre_dtq ......................................................................................................................................... 122
acre_dtq ....................................................................................................................................... 124
del_dtq ......................................................................................................................................... 125
snd_dtq ........................................................................................................................................ 126
psnd_dtq ...................................................................................................................................... 127
ipsnd_dtq ..................................................................................................................................... 127
tsnd_dtq ....................................................................................................................................... 129
fsnd_dtq ....................................................................................................................................... 131
ifsnd_dtq....................................................................................................................................... 131
rcv_dtq ......................................................................................................................................... 132
prcv_dtq ....................................................................................................................................... 133
trcv_dtq ........................................................................................................................................ 134
ref_dtq .......................................................................................................................................... 135
Index 6
5.7 Synchronization / communication functions (Mail Box) ............................................................. 136
cre_mbx ....................................................................................................................................... 136
acre_mbx ..................................................................................................................................... 138
del_mbx........................................................................................................................................ 139
snd_mbx....................................................................................................................................... 140
rcv_mbx........................................................................................................................................ 143
prcv_mbx...................................................................................................................................... 144
trcv_mbx....................................................................................................................................... 145
ref_mbx ........................................................................................................................................ 147
5.8 Extended synchronization / communication functions (Mutex) ................................................. 148
cre_mtx ........................................................................................................................................ 148
acre_mtx ...................................................................................................................................... 150
del_mtx......................................................................................................................................... 151
unl_mtx......................................................................................................................................... 152
loc_mtx......................................................................................................................................... 153
ploc_mtx....................................................................................................................................... 154
tloc_mtx........................................................................................................................................ 155
ref_mtx ......................................................................................................................................... 156
5.9 Extended synchronization / communication functions (Message buffer) .................................. 157
cre_mbf ........................................................................................................................................ 157
acre_mbf ...................................................................................................................................... 159
del_mbf ........................................................................................................................................ 160
snd_mbf ....................................................................................................................................... 161
psnd_mbf ..................................................................................................................................... 163
tsnd_mbf ...................................................................................................................................... 164
rcv_mbf ........................................................................................................................................ 166
prcv_mbf ...................................................................................................................................... 167
trcv_mbf ....................................................................................................................................... 168
ref_mbf ......................................................................................................................................... 170
5.10 Extended synchronization / communication functions (Rendezvous port) .............................. 171
cre_por ......................................................................................................................................... 171
acre_por ....................................................................................................................................... 173
del_por ......................................................................................................................................... 174
cal_por ......................................................................................................................................... 175
tcal_por ........................................................................................................................................ 177
acp_por ........................................................................................................................................ 178
pacp_por ...................................................................................................................................... 180
tacp_por ....................................................................................................................................... 181
fwd_por ........................................................................................................................................ 182
rpl_rdv .......................................................................................................................................... 184
ref_por.......................................................................................................................................... 185
ref_rdv .......................................................................................................................................... 186
5.11 Interrupt management functions .............................................................................................. 187
def_inh ......................................................................................................................................... 187
ent_int .......................................................................................................................................... 188
ret_int ........................................................................................................................................... 189
chg_ims........................................................................................................................................ 190
Index 7
get_ims......................................................................................................................................... 191
vdis_psw ...................................................................................................................................... 192
vset_psw ...................................................................................................................................... 193
cre_isr .......................................................................................................................................... 194
acre_isr ........................................................................................................................................ 196
del_isr........................................................................................................................................... 197
ref_isr ........................................................................................................................................... 197
5.12 Memory pool management functions (Variable length) ........................................................... 198
cre_mpl ........................................................................................................................................ 198
acre_mpl ...................................................................................................................................... 200
del_mpl......................................................................................................................................... 201
get_mpl ........................................................................................................................................ 202
pget_mpl ...................................................................................................................................... 204
tget_mpl ....................................................................................................................................... 205
rel_mpl ......................................................................................................................................... 206
ref_mpl ......................................................................................................................................... 207
5.13 Memory pool management functions (Fixed length) ............................................................... 208
cre_mpf ........................................................................................................................................ 208
acre_mpf ...................................................................................................................................... 210
del_mpf ........................................................................................................................................ 211
get_mpf ........................................................................................................................................ 212
pget_mpf ...................................................................................................................................... 213
tget_mpf ....................................................................................................................................... 214
rel_mpf ......................................................................................................................................... 215
ref_mpf ......................................................................................................................................... 216
5.14 Time management functions ................................................................................................... 217
set_tim.......................................................................................................................................... 217
get_tim ......................................................................................................................................... 218
cre_cyc......................................................................................................................................... 219
acre_cyc....................................................................................................................................... 221
del_cyc ......................................................................................................................................... 222
sta_cyc ......................................................................................................................................... 223
stp_cyc ......................................................................................................................................... 223
ref_cyc.......................................................................................................................................... 224
cre_alm ........................................................................................................................................ 225
acre_alm ...................................................................................................................................... 226
del_alm......................................................................................................................................... 227
sta_alm......................................................................................................................................... 228
stp_alm......................................................................................................................................... 228
ref_alm ......................................................................................................................................... 229
isig_tim ......................................................................................................................................... 230
def_ovr ......................................................................................................................................... 231
sta_ovr ......................................................................................................................................... 233
stp_ovr ......................................................................................................................................... 233
ref_ovr .......................................................................................................................................... 234
5.15 Service call management functions ......................................................................................... 235
def_svc......................................................................................................................................... 235
Index 8
cal_svc ......................................................................................................................................... 237
5.16 System state management functions....................................................................................... 238
rot_rdq.......................................................................................................................................... 238
irot_rdq ......................................................................................................................................... 238
get_tid .......................................................................................................................................... 239
iget_tid.......................................................................................................................................... 239
vget_tid......................................................................................................................................... 240
loc_cpu......................................................................................................................................... 241
iloc_cpu ........................................................................................................................................ 241
unl_cpu......................................................................................................................................... 242
iunl_cpu........................................................................................................................................ 242
dis_dsp......................................................................................................................................... 243
ena_dsp ....................................................................................................................................... 244
sns_ctx ......................................................................................................................................... 244
sns_loc ......................................................................................................................................... 245
sns_dsp........................................................................................................................................ 246
sns_dpn........................................................................................................................................ 246
ref_sys.......................................................................................................................................... 247
5.17 System configuration management functions.......................................................................... 248
ref_ver .......................................................................................................................................... 248
ref_cfg .......................................................................................................................................... 249
6. Exclusive System Calls
6.1 NORTi Exclusive System management functions ..................................................................... 250
sysini ............................................................................................................................................ 250
syssta ........................................................................................................................................... 251
intsta............................................................................................................................................. 252
intext............................................................................................................................................. 252
intini.............................................................................................................................................. 253
7. List
7.1 Error code list............................................................................................................................. 254
7.2 System call list ........................................................................................................................... 255
Task management functions........................................................................................................ 255
Task associated synchronization................................................................................................. 256
Task exception handling .............................................................................................................. 257
Synchronization and Communication (Semaphore) .................................................................... 258
Synchronization and Communication (Event flag)....................................................................... 259
Synchronization and Communication (Data queue) .................................................................... 260
Synchronization and Communication (Mail box) ......................................................................... 261
Extended Synchronization and Communication (Mutex)............................................................. 262
Extended Synchronization and Communication (Message buffer).............................................. 263
Extended Synchronization and Communication (Rendezvous port) ........................................... 264
Fixed length memory pool management ..................................................................................... 265
Variable length memory pool management ................................................................................. 266
Time management (System time)................................................................................................ 267
Time management (Cyclic handler)............................................................................................. 268
Time management (Alarm handler) ............................................................................................. 269
Index 9
Time management (Overrun handler) ......................................................................................... 270
System state management .......................................................................................................... 271
Interrupt management.................................................................................................................. 272
Service call management functions ............................................................................................. 273
System configuration management ............................................................................................. 274
7.3 Static API list.............................................................................................................................. 275
7.4 Packet structure object list......................................................................................................... 276
Task generation information packet............................................................................................. 276
Task state packet......................................................................................................................... 276
Task state easy reference packet................................................................................................ 276
Task exception handler generation information packet ............................................................... 276
Task exception handler state packet ........................................................................................... 277
Semaphore generation information packet.................................................................................. 277
Semaphore state packet .............................................................................................................. 277
Event flag generation information packet .................................................................................... 277
Event flag state packet................................................................................................................. 277
Data queue state packet .............................................................................................................. 278
Mailbox generation information packet ........................................................................................ 278
Mutex generation information packet........................................................................................... 278
Mutex state packet....................................................................................................................... 278
Message buffer generation information packet ........................................................................... 278
Message buffer state packet........................................................................................................ 279
The rendezvous port generation information packet ................................................................... 279
The rendezvous port state packet ............................................................................................... 279
Rendezvous port state packet ..................................................................................................... 279
Interrupt handler definition information packet............................................................................. 279
Interrupt service routine generation information packet .............................................................. 279
Interrupt service routine state packet........................................................................................... 280
Variable length memory pool generation information packet ...................................................... 280
Variable length memory pool state reference packet .................................................................. 280
Fixed length memory pool generation information packet........................................................... 280
Fixed length memory pool state reference packet....................................................................... 280
Cyclic handler generation information packet.............................................................................. 280
Cyclic handler state reference packet.......................................................................................... 281
Alarm handler generation information packet .............................................................................. 281
Alarm handler state reference packet.......................................................................................... 281
Overrun handler generation information packet .......................................................................... 281
Overrun handler state reference packet ...................................................................................... 281
Version information packet .......................................................................................................... 281
System state reference packet .................................................................................................... 282
Configuration information packet ................................................................................................. 282
Extended service call definition information................................................................................. 282
7.5 Constant list ............................................................................................................................... 283
7.6 NORTi3 compatible mode ......................................................................................................... 286
Index
Index 10
Index 11
1. Basic Particulars NORTi Version 4 User's Guide
1. Basic Particulars
1.1 Features
High Speed Response
NORTi is preemptive multitasking RTOS. Scheduling is carried out based on the priority of the
events and highest priority task is immediately activated. All kernel source code is fully tested.
CPU performance is pulled to the maximum extent. Interrupt of priority higher than kernel level
can be processed with interrupt inhibit time conventionally reduced to half. Furthermore, the
interrupt routine with priority higher than OS can be carried with unlimited value of
interrupt-prohibition time.
Compact Size
Kernel size is effectively optimized since all management block variables (i.e. TCB etc) are
inside kernel. All variables are optimized for size by 1 byte margin in order to effectively use
precious RAM area.
1 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
industry, it can be used without any change even if the target system differs. Moreover in order
to provide support to wide range of development environment tools, continuous effective
correspondence is performed in association with almost all development toolmakers.
WAIT
state
Suspend Resume
sus_tsk rsm_tsk
frsm_tsk
WAITING-
SUSPENDED
state
SUSPENDED
Resume
state
rsm tsk
Starting Forced
sta_tsk / act_tsk termination
DORMANT ter_tsk
Forced termination
state
ter_tsk
Deletion del_tsk
Creation cre_tsk
NON-EXISTENT
End / deletion
state
exd_tsk
2 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
3 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
(1) During execution of a task if the task of the higher priority is started, or if the system call is
issued so as to cancel the WAIT state of the higher priority.
(2) From a non-task context (Interrupt handler / Interrupt service routine / Timer event handler),
if a task with priority higher than the running task is started, or if a system call is published to
cancel the wait state of higher priority task.
(3) If the wait-state of the higher priority task is cancelled by the timeout event.
(4) If the task under execution went into wait-state by itself, or if the priority is lowered, or if is
terminated.
In other words, all system calls does not necessarily cause task switching. Even if the task of
lower priority is started or is released from wait-state, task switching does not occur. Task
switching operation will be waiting until the operated task is higher priority as in (4) above.
Although the case of similar priority is same as the case of low priority, the task switching
between same priorities can occur by using rot_rdq and chg_pri system calls, where task under
execution moves to the end of execution queue.
4 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
5 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
1.3 Terminology
Object and ID
Generally objects are the targets of system call operations. The numbers, which are used to
identify and distinguish objects, are called IDs. These IDs are user specified numbers. A part
which is internal to Kernel and which cannot be directly specified by user is called an Object
number.
Objects with ID number include tasks, semaphores, event flags, a mailboxes, message buffers,
rendezvous ports, fixed-length / variable-length memory pools, data queue, mutex, cyclic
handlers, alarm handlers and interrupt service routines. The objects identified by object
numbers are interrupt-handlers, rendezvous ports and statically generated interrupt service
routines.
Context
The entire execution environment of the task at a given point of time is called the “context” of
that task. In concrete terms, this can be understood as registers of the CPU. Context is a
generic name of things saved or restored when tasks are switched.
Under multitasking, using DSP and floating-point arithmetic requires the registers to switch their
contexts. If NORTi does not support this switching operation, a floating-point unit needs to be
exclusively controlled.
Dispatch
Selection and change of an execution task is called Dispatch. Some system calls generates
dispatch and some do not generate dispatch. Task will not change if the priority of the task from
which dispatch generating system call is issued, is lower than the priority of the current
RUNNING task. In addition, if the system call, which generates the dispatch, is issued from the
non-task context, dispatch is carried out collectively after returning to task context. This is called
the delayed context.
6 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
Queue
Tasks are queued (put in a waiting line) in the order of arrival when multiple tasks make their
requests to the same object. Queues are created when waiting for semaphores, waiting for
event flags, waiting for message from mailboxes, waiting for transmission / reception of
messages from message buffers, ports waiting for rendezvous call / reception, waiting for
memory block acquisition from fixed-length / variable-length memory pools, waiting for
reception / transmission of data queues and waiting for mutex acquisition.
Tasks are basically queued on the FIFO (First in First Out) basis. However in case of
semaphore, mailbox, message buffer (reception side), fixed-length / variable-length memory
pool and mutex, it is possible to set the queue in the order of task or message priority.
Queuing
Queuing means a reservation of a request from a task without considering the state erroneous
where the request cannot be received by other task.
Requests for waking up tasks and messages at the mailbox / message buffer and data queue
are queued. Requests for waking up tasks are implemented by counting requests. Messages
for mailboxes are queued by linear linked lists with pointers. Messages for message buffers and
data queuing are queued by a ring buffer.
In case of event flag and task exception, instead of queuing, the event by OR operation and
suspension of cause of exception is carried out. In this case, only the existence of the event is
recorded, the counting is not recorded.
7 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
Exclusive Control
Multitasking may allow multiple tasks to access an object that is not to be accessed
simultaneously. However, there are many objects that cannot be used concurrently. Example:
non-reentrant functions and commonly shared data. Exclusive control manages these object
resources in such a way that they cannot be used concurrently. Semaphores or mutex are
generally used for the exclusive control management.
However exclusive control is unnecessary if tasks priorities are the same or if the competing
tasks are not switched while accessing shared resources. Unifying priorities effectively prevents
the use of exclusive control. In some case, it is better to raise the priority of competing section
temporarily. For example semaphores have a problem with priority reversal i.e. tasks with high
priority must wait for semaphores return of low priority task. The so-called momentary
dispatch-disabled / prohibited interrupt disabled state makes exclusive control easy if the
interrupt is short. In case of mutex, there is an option of raising the priority whenever required.
However, if the section, which should carry out exclusive control, is short then it is easy to carry
out exclusive control by temporary ban on dispatch or temporary ban on interruption.
Idle Task
An idle task executes when no other tasks are running. Although there is an idle task
implemented in the kernel, if a user creates a task as an infinite loop operation and with lowest
priority, it will serve as an idle task.
Though an idle task does not do anything, it plays an important role. In event driven
multitasking system, if an execution order does not turn to an idle task, then it indicates that
either some task is consuming CPU power wastefully or CPU performance is not up to system
requirement.
8 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
Context Error
There are some system calls, which cannot be issued from a non-task context (timer handler or
interrupt handler). Violation of this rule returns a context error from system calls. Since this is a
static error, libraries in which static parameters are not checked do not detect context errors.
9 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
Argument name
Following convention is used for naming input arguments to system calls.
10 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
11 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
12 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
13 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
14 Rev. 1.01
1. Basic Particulars NORTi Version 4 User's Guide
(Blank space)
15 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
2. Introduction
2.1 Installation
NORTi installation standard folder composition is explained in the following text.
XXX is the processor series name (Example: SH, H8S, H83 etc.), BBB is the evaluation board
name (Example: MS7709A etc.) and YYY is the name of corresponded compiler in short
(Example: SHC, GHS, GCC etc.).
The portion described as xxx in the file name is processor/device dependent. Extensions are
typical examples and actually depend on the compiler. Refer to the supplementary
documentation or README text for up-to-date information about the folder contents. Please do
not inter-mix the files with same name. The same name may exist for the files of different
versions, files of different processor and the files of NORTi3 Standard / Extended / Network.
Include files
Following header files are stored in INC folder.
#include "kernel.h" in all source files using NORTi. It describes all definitions and declarations
necessary for using NORTi functions such as data types, common constants and function
prototypes. Since itron.h is included in kernel.h, it is not necessary to #include itron.h in user’s
source files.
“nocfg4.h” defines the default constants for the configuration of the maximum number of tasks
and the variable itself used in the kernel. When configurator is not used, #include "nocfg4.h" in
only one file of the user programs.
16 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
When using configurator constant other than the default, define it before #include. When the
configurator is used, it is included in the kernel_cfg.c created by the configurator. Therefore it is
unnecessary to #include directly from the user program.
nosys4.h describes all internal definitions of the kernel. It is included in nocfg4.h and usually it
is unnecessary to carry out #include directly from user's programs. The part, which changes
with the corresponding processor, is defined in n4rxxx.h. It is included from nosys4.h and is
unnecessary to carry out #include directly from user's programs.
Library
The Kernel library module file along with the makefile to generate it is stored in LIB folder.
A library without parameter check is a library in which static eror check of a parameter is
omitted for the sake of processing speed improvement. If an error code is not set to SYSER
variable unique to NORTi, then it is okay to switch to library without parameter check.
Source files
The SRC directory contains all source files of the kernel.
Depending on the compiler / assembler, the assembler source file may have extension other than asm.
Sample
The cyclic timers interrupt handler and interrupt management function modules, which are
dependent on the hardware, should be fundamentally created by the user. For designing
these modules, please refer to following source / header files provided as a sample.
Apart from this, header files defining the corresponding processor's built-in I/O, start-up routine
samples, main source sample, and make files are also included.
17 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
When using the software components such as network, the ID number used by the user program
and the ID number used in the software component should not mismatch. In such cases, it is
possible to automatically allocate the ID numbers by using the configurator. Please refer to the
configurator manual that is attached. The kernel configuration for system without the configurator
is explained in the following text.
Task ID 8
Timer handler number upper limit 1
Each of the Other ID’s 8
Task Priority upper limit 8
Interrupt handler stack size 4 times the size of T_CTX (*1)
Timer handler stack size 4 times the size of T_CTX
System memory size 0(using stack memory)
Memory Size of memory pool 0(using stack memory)
Stack memory size 0(using default stack) (*2)
(*1) T_CTX is defined in n4rxxx.h and the size is the same as that of the sum total of the total CPU registers size except
a stack pointer (SP).
(*2) A default stack usually points at the start address of the stack section specified by the linker to the address set up
by SP at the time of reset.
Customization of configuration
Upper / lower limits of the IDs and numbers are as follows:
Task ID / Timer event handler ID 1 to 253(*3)
Other object IDs 1 to 999(*4)
Task priority 1 to 31
(*3) This ID is managed by 1 byte and 255 and 254 are used for special processing inside.
(*4) In addition, although ID is unrestricted as a matter of fact to a memory bound because of management by int, the
guarantee is taken as to 3 digit figures.
For the upper limit of the task priority, specify smallest possible value. With higher number of
maximum priority, the time to choose the highest priority task is also higher. Besides, the
internal data size, which controls waiting queues in the priority order, increases one byte per
priority.
For definitions other than task priority definitions, there is no speed overhead due to excessive
18 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
upper limit. However since one pointer is internally defined for each ID, systems of a smaller
RAM capacity should adopt minimum definition values as illustrated below.
19 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
[1] [2]
40 40 x Number of tasks
12 12 x Number of semaphores
16 12 x Number of mutex
12 8 x Number of event flags
12 12 x Number of mailbox
24 24 x Number of message buffers
28 28 x Number of data queue
12 12 x Number of rendezvous ports
20 16 x Number of Variable length memory pools
20 18 x Number of Fixed length memory pools
32 28 x Number of Cyclic handlers
12 12 x Number of alarm handlers
8 8 x Number of extended service calls
20 18 x Number of interrupt service routines
16 14 x Number of Task exception handler routines
[1] In the case of pointer 32-bit, INT type integer 32-bit (SH, 68K, V800, PowerPC, ARM, MIPS etc.)
[2] In the case of pointer 32-bit, INT type integer 16-bit (H8S, H8/300H, 8086, etc.)
The size of (1 byte x task priority upper limit TPRI_MAX) is added to the management block of
an object created by specifying the task priority wait. If the sum total size is not multiple of int
20 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
size, it is realigned. When the object creation information exists in RAM instead of ROM, the
object creation information is copied to the system memory.
The amount of system memory used is decided by number of objects created simultaneously.
Although 8 is specified as the upper limit of the object number, if it does not generate
simultaneously, it is not necessary to secure 8 objects. Defining 0 in SYSMSZ makes the
system memory allocated from the "stack memory." Hence in most of the cases SYSMSZ
definition is unnecessary.
Define a total value of the stack size required for an application task plus a stack size required
for the interrupt handler/timer handler. The system memory when STKMSZ=0 and the memory
pool memory when MPLMSZ=0 are also allocated from this stack memory. The default value is
0. In this case, the stack memory of OS is the standard stack area decided by the initial stack
pointer value setup by linker and the startup routine.
In addition, even when STKMSZ is other than 0, in order to allocate stack to main function,
timer handler uses default stack area of the processing system.
21 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
:
#define KNL_LEVEL 6 Kernel interrupt-inhibit level
:
#include "nocfg4.h"
22 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
ID Definition
The μITRON 4.0 specification requires the ID’s to be predetermined. You can #include the
header files that #define all the IDs from the source files of the user program.
In case when configurator is used, static API of a configuration file generates kernel_id.h
automatically.
If ID is defined as a global variable, all files need not be re-compiled when ID value is changed.
Automatic assignment of ID
You may receive unused ID number as a return value when you create objects by acre_xxx
system call. For this you do not have to define ID numbers beforehand. It is advisable to refer to
ID numbers as a global variable, as shown in (Example 2).
Empty identification number is checked in descending order. This improvement easily avoids a
conflict between automatically assigned ID numbers and ID numbers defined in ascending
order.
23 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
#include "kernel.h"
#include "nocfg4.h"
24 Rev. 1.01
2. Introduction NORTi Version 4 User's Guide
Example of compilation
A general example of compiling / linking sample.c in the previous page is given below.
Vecxxx.asm and init.c describes the interrupt vector definition and the startup routine. File
name of the startup routine changes depending on the compiler or may be included in the
standard library of C. n4ixxx.c and n4exxx.lib are a cyclic timer interrupt handler description file
and a kernel library respectively. standard.lib indicates standard library of C and the file name
may change as per the corresponding compiler.
>asm vecxxx.asm
>cc init.c
>cc sample.c
>cc n4ixxx.c
>link vecxxx.obj init.obj sample.obj n4ixxx.obj n4exxx.lib standard.lib
Above example shows that user need not understand any special procedure to create
multi-tasking programs.
25 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
26 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
27 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
In the interrupt handler, the storing and restoring of registers (ent_int and ret_int in case of
NORTi) need to be described by user. On the other hand, in case of interrupt service routine,
since the interrupt handler section inside OS is processed initially, user need not describe the
storing / restoring of registers i.e. it can be considered as an ordinary C function. This structure
of interrupt service routine is introduced from μITRON4.0 specification.
Since the interrupt handler and interrupt service routine are executed in the interrupt state, only
minimal processes should be carried out. After this, a task waiting for an interrupt is woken up
and practical interrupt handling is carried out. As a matter of fact, waiting system calls are not
allowed in interrupt handlers. Moreover system calls requiring dynamic memory management
(creation / deletion of object and variable length memory pool etc.) cannot be issued, either.
28 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
• The function must begin with ent_int and must end with ret_int system calls. (the interrupt
handler of priority higher than kernel interrupt prohibition level is removed)
INTHDR inthdr1(void)
{
ent_int();
:
:
ret_int();
}
In ent_int, all registers are saved and a stack pointer is also switched over to the exclusive
stack area for interrupt handlers. Thus, it is not necessary to add the amount of area used by
interrupt handlers to each task stack.
For processors with many registers, all registers are not saved in ent_int. Only the registers,
which the compilers use without saving, are saved. The other registers are saved only when it
is decided that a dispatch occurs in the ret_int system call at the end of interrupt. This shortens
the processing time of an interrupt handler when there is no dispatch or nested interrupts.
Unnecessary instructions generated at the start of functions may vary depending on the
contents of the interrupt handlers, the version of the compiler or the compilation conditions. Be
sure to output assembly listing files to confirm that no unnecessary instructions are generated.
In some case, RISC processors cannot save registers with just ent_int and the Interrupt
function is used in this. In this case it is usual to issue register save instructions before ent_int.
29 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
If interrupt handler functions carry out complex processes then an unexpected instructions may
be generated before ent_int. In such cases, you may call the function from the interrupt handler
and carry out the actual process there.
When the CPU has level interrupt function, the level of the after returning from ent_int() is the
same as the hardware. Multiplexing of interrupts happens if interrupt with a higher priority
occur.
30 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
Timer handlers are executed as task independent sections with higher priority than tasks.
Therefore accurate time management is possible by using timer handler. Also, management
blocks and stacks require less memory than tasks. However, waiting system calls cannot be
issued in timer handlers.
Consider the description of the overrun handler in the same manner as the ordinary interrupt
routine. Please describe an Overrun handler as the following C function.
31 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
Additional note
Since the priority of timer handlers is next to that of interrupt handlers, please minimize the
processing of timer handlers and enable the compiler optimization. Unlike an interrupt handler,
auto variables can be used without limitation.
32 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
Start-up routine
In some other μITRON specified OS, a dedicated start-up routine is provided and the
initialization necessary for multi tasking is carried out. After this, there is a way, which starts the
main function as a task.
On the other hand, NORTi does not provide any special start-up routine. All the functions till the
main function are executed in the same way as an ordinary program.
main function
In NORTi, main function is used as the multitasking initialization handler. In the main function,
system initialization (sysini), I/O initialization, one or more task creation (cre_tsk) and one or
more task start (sta_tsk) if necessary, the creation of objects (cre_xxx) such as semaphore, an
event flags, starting of cyclic timer interrupt start (intsta) and system start (syssta) are
performed. When a configurator is used, configurator in a kernel_cfg.c file creates the main
function.
System initialization
At the start of the main function, execute the sysini function to initialize the kernel. From sysini,
an intini function is called to initialize the interrupt controller interface depending on the
hardware. The standard intini function is included in n4ixxx.c. However, if it is not suitable to the
user system, please create it separately.
I/O initialization
When an I/O is to be initialized before multi-task operation, use the main function to initialize it.
In case the configurator is used, user function that is registered as ATT_INI static function is
called.
33 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
Object creation
Creation of objects such as task, semaphore, or event flag can be done not only from the main
function but also from within a task.
Task start
You can start all the tasks to be started in the main function. You can start only one task (that is,
main task), and then the remaining tasks can be started from within that task. The task to be
started should be created beforehand.
In case of configurator, task starting specifies TA_ACT as the task attribute of CRE_TSK static
API.
The modules related to model-dependent cyclic timer interrupt and interrupt management are
not included in the library. Compile an accessory n4ixxx.c and link it. If the attached n4ixxx.c
does not match, the user should create n4ixxx.c.
When configurator is used, cyclic timer is treated as software part. Please refer to the
configurator manual for more details such as start timing etc.
System start
A multi-task operation finally starts when you execute syssta function. The syssta function
makes an infinite loop internally and does not return to the main function. (This section is
NORTi's default idle task.)
However, if an error occurs in cre_tsk or sta_tsk before executing the syssta function, control
returns to the main function without starting the multi-task operation.
34 Rev. 1.01
3. Task and Handler Description NORTi Version 4 User's Guide
#include "kernel.h"
/*Configuration */
/* ID definitions */
#define ID_MainTsk 1
#define ID_KeyTsk 2
#define ID_ComSem 1
#define ID_KeyFlg 1
void main(void)
{
sysini(); /* System initialization */
cre_tsk(ID_MainTsk,&ctsk1); /* Task1 creation */
cre_tsk(ID_KeyTsk,&ctsk2); /* Task2 creation */
cre_sem(ID_ConSem,&csem1); /* Semaphore creation */
cre_flg(ID_KeyFlg,&cflg1); /* Event flag creation */
sta_tsk(ID_MainTsk,0); /* Start main task */
intsta(); /* Start periodic timer interrupt */
syssta(); /* Start multitasking */
}
35 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
4. Function Overview
4.1 Task management functions
Overview
Executing the cre_tsk system call creates tasks. Tasks are started by sta_tsk or act_tsk. When
act_tsk is used, if the specified task is already in the ready state, the start request is queued.
Executing ext_tsk or ter_tsk terminates tasks. Ext_tsk terminates the task itself and ter_tsk
terminates other tasks. When the start request terminates the queuing task, it restarts instantly.
Can_act is used to cancel the queuing of start request. By using disable dispatch dis_dsp and
enable dispatch ena_dsp, tasks are switched only once after several system calls are issued.
By chg_pri changing priority and rot_rdq rotating ready queue, you can control the order in
which tasks are executed. In addition, the following system calls are classified into task
management functions. Rel_wai forces other waiting tasks to be released. Get_tid gets the ID
of a task itself. Ref_tsk references a task’s status.
The μITRON specification does not provide a way for users to access TCB and other control
blocks directly. Though, in NORTi you can access TCB directly by #including “nosys4.h”. The
structures of the TCB and others are subject to change by upgraded versions.
36 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
The data structure, which controls the order of execution, is called the ready queue. Tasks are
linked to the ready queue in the order of priority. If their priorities are same tasks are linked in
the order of FIFO. The READY task with the highest priority is a task in the RUN state (task A in
the following chart).
When this task enters the WAIT, SUSPEND or DORMANT state, it is released from the ready
queue and the task with the second priority (task B in the following chart) enters the RUNNING
state.
First READY
task-H
Queues for waiting objects with task priority are implemented in the same way as in the ready
queue.
37 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
In addition to slp_tsk and tslp_tsk, other system calls like wai_flg, wai_sem and rcv_msg can
transfer tasks to the WAIT state. As opposed to the task in these waiting state, issuing rel_wai
instead of wup_tsk, forcibly releases the wait.
The task in the suspended state can be resumed by rsm_tsk or frsm_tsk system calls. The
queing treatment is the difference between rsm_tsk and frsm_tsk. In case of frsm_tsk system
call, all queings are cancelled and task execution is resumed forcibally. However in case of
rsm_tsk, queing is decremented by 1.
38 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Suspended waiting
If a sus_tsk system call is issued while task is in waiting state, it will shift to the double waiting
state WAITING-SUSPENDED.
39 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
To support task exception-handling function, the system calls to define task exception handling
routine (def_tex), call to request task exception (ras_tex), call which prohibits exception
handling (dis_tex), call which checks for the prohibition state (sns_tex) and the system call
which refers to the exception handling state.
In case a large address jump is carried using longjmp instead of return from the exception
handler routine, it will continue in the exception handling state and does not return to the
exception-handling permission state. Moreover the information before starting the
exception-handling routine is lost. For example, when WAITING is carried out by rcv_mbf, the
information from the received message is lost. When using longjmp, please terminate the task.
Exception factor
When the time of the exception factor is non-zero, it is considered as exception handler
demand. If there is an exception demand in an exception handling prohibition state, an
exception demand will be suspended until the exception handling is enabled again. The
exception factor is defined by TEXPTN type variable. If the same exception is demanded
multiple times, a task exception handler routine cannot recognize the number of times the
demand had occurred.
40 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
For creating semaphores, the cre_sem and acre_sem system calls are provided. In contrast
with the sig_sem system call for returning resources, the wai_sem system call waits for the
acquisition of resources, the pol_sem system call executing polling without waiting, and the
twai_sem system call waits with a time-out. Besides these, the ref_sem system call references
the conditions of a semaphore.
Semaphore
+
Task-X Task-X Task-Y Task-Z
Return Request
41 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
42 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Event flags are created and deleted with the cre_flg, acre_flg and del_flg system calls.
Contrary to the set_flg system call for setting up event flags, the wai_flg system call waits for
the existence of event flags, the pol_flg system call executing polling without waiting, and the
twai_flg system call waits with a time-out. Besides these, the clr_flg system call clears an
event flag and ref_flg references the conditions of an event flag.
However, when the waiting of multiple tasks is cancelled simultaneously, since the system
processing time is not minimized, it is recommended for not to use waiting for multiple tasks
whenever possible.
43 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Waiting mode
Wait conditions can be specified by bit patterns AND and OR, as multi-bit flag groups are used
in an event flag. In waiting AND, the waiting condition waits for all bits specified by a
parameter to be set up on event flag. In waiting OR mode, the waiting condition waits for either
of the specified bits to be set up on event flag.
Clear order
In the wai_flg, pol_flg and twai_flg system calls, when an event flag has been created, it can be
automatically cleared according to the parameter specifications.
When the clear specification is given during creation, it is cleared as usual. Clear is carried out
for all bits.
44 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
The creation / deletion of data queue are carried out by cre_dtq, acre_dtq and del_dtq. In
addition there are system calls to transmit data (snd_dtq), to transmit data by polling way
(psnd_dtq), to transmit data with timeout (tsnd_dtq), to wait and receive new message (rcv_dtq),
system call to poll and receive new message without waiting (prcv_dtq) and a system call to
receive message with timeout (trcv_dtq). Moreover there is fsnd_dtq system call that transmits
data forcibily. In addition, ref_dtq system call is available which refers to the data queue state.
Queuing
Data queue is made up of sending queue, receiving queue and ring buffer. If the buffer is full
while sending data, the corresponding task is connected to the send-waiting queue until the
data is removed from the buffer. If the buffer is empty while receiving, the receiver task is
connected to the receiving queue until the data is transmitted.
The ring buffer size can be set to 0. In this case, the send tasks and receive tasks wait for each
other and can be synchronized.
The transmitting queue can specify the task priority or FIFO. The receiving queue is usually
formed in the order of arrival.
Data order
Data cannot be assigned priority. However, by using fsnd_dtq, data can be received prior to
data sent by snd_dtq. When it is sent by fsnd_dtq, if the buffer is full, the data in the beginning
of the buffer is erased and this data is stored there.
45 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
The cre_mbx, acre_mbx and del_mbx system calls are used for creation and dletion of
mailboxes. In addition there is system call to transmit message (snd_mbx), call to wait and
receive message (rcv_mbx), call to poll and receive the new message (prcv_mbx), call to
receive the new message with timeout (trcv_mbx), and a system call to refer to the state of the
mailbox (ref_mbx).
Message queuing
Multiple tasks can wait for the same mailbox. When a FIFO mode is specified at the time of
mailbox creation, the queuing is built to serve on the first come first out basis. When the priority
mode is specified at the time of mailbox creation, queuing is built as per the task priority (FIFO
order among the task with same priority level).
Though both task waiting messages and queued messages are in the chart, they do not exist at
the same time.
46 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Message queue
Messages can be sent at any time irrespective of the existence of the receiving task. The top
part of the message packet is used as the pointer indicating the next message. Thus, data area
on the ROM cannot be used as a message packet.
At the time of mailbox creation, when the FIFO is specified as the queuing method, a message
queue is built in the order of arrival.
At the time of mailbox creation, when the priority is specified as the queuing method, a
message queue is built in the order of priority. (When the priority is same, queue is built in the
order of arrival.) Therefore, the required memory size will increase if the level of priorities is
more. The memory size can be known by the TSZ_MPRIHD macro definition.
mprihdsz = TSZ_MPRIHD(8);
The mailbox does not know the message packet size. In other words, the message length is not
restricted. However, when it is combined with the fixed-length memory pool, the message
packet size is fixed naturally.
47 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Creation and deletion of mutex can be performed using cre_mtx, acre_mtx or del_mtx system
calls. In addition there are system calls such as unl_mtx to release the resource, loc_mtx to wait
and acquire the resources, ploc_mtx to acquire resource by polling without waiting, tloc_mtx
call to acquire by timeout without waiting and ref_mtx call to refer to the state of the mutex.
Priority inversion
When a low priority task locks the resource, a task with a high priority tends to use the already
locaked resources and it may go to WAITING state. At this time, if the task of the priority in
between goes to the RUNNING state, then this task indirectly preempts the execution of the
high priority task. This is called priority inversion. If a priority inversion happens, operation of the
system designed based on the scheduling of priority cannot be guarantied.
In mutex, in order to avoid the priority inversion, the priority inheritance protocol and maximum
priority task are supported.
In the priority inheritance protocol, the priority of the locked task is temporarily made the same
as the highest priority task among the task waiting for lock release. By this way the intervention
of the task with the middle priority is avoided. System is heavily loaded in order to change
priority dynamically. Since priority inversion happens when doing changes, cautions are
required especially when a task under lock is waiting for another mutex.
In the priority ceiling protocol, the priority of the locked task is changed to the previously
decided priority independent of the existence of the waiting task. Although the system is not
heavily loaded as compared to the priority inheritance protocol, the priority inversion occurs
even when there is no waiting task.
After lock release, the temporarily changed priority will return to the base priority.
48 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Message buffers are created and deleted with the cre_mbf, acre_mbf and del_mbf system calls.
The snd_mbf system call for sending messages, the psnd_mbf, which returns immediately
without waiting in case there is no space in the buffer, the tsnd_mbf which waits with time out
when there is no space in the buffer. The rcv_mbf system call waits for the receipt of messages,
the prcv_mbf system call executes polling without waiting, and the trcv_mbf system call waits
with a time-out. Besides these, the ref_mbf system call references the conditions of message
buffers.
Message queue
Message data is copied into a ring buffer inside the message buffer. Similar to mailbox, it is not
necessary to acquire the message packet domain ROM memory pool. Moreover, the message
header section used by the OS is also not necessary.
Any message size is acceptable as long as it does not exceed the maximum length specified at
message buffer creation in the receiving side. It is necessary to provide a buffer that can
receive a message of the maximum length. Only FIFO controls the message line, which has
been queued. There is no function to attach priority to the message.
49 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Message Buffer
Queue of tasks waiting for messages
Message Buffer
Ring Buffer Full
Queue of task waiting to send message
TSZ_MBF(msgcnt, msgsz)
When msgsz is one, that is when the message buffer is created with message having maximum
length of 1 byte, the addition of the header, which indicates message size, is abbreviated.
Because of this function, the entire area of the ring buffer is effectively used for data in the
sending and receiving of 1 byte messages.
50 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
51 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Creation and deletion of rendezvous port can be done by cre_por, acre_por and del_por
system calls. There is a management function cal_por for rendezvous call, acp_por for
rendezvous reception and rpl_rdv for rendezvous reply. pacp_por is a system call to do polling
mode reception. Moreover, there is tcal_por/tacp_por for rendezvous call & reception in timeout
mode. In addition, there are fwd_por to forward the received rendezvous to another port,
ref_por to get the port state reference and ref_dev to refer to the state of rendezvous.
cal_por acp_por
(1) acp_por cal_por (2)
(3) (3)
rpl_rdv rpl_rdv
(4) (4)
52 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
When task-A issues rendezvous call cal_por, and if task-X has not yet executed rendezvous
acceptance acp_por, then task-A enters the rendezvous calling wait state (1).
Conversely, when task-X is executing the rendezvous acp_por, and if task-A has not yet issued
rendezvous calling cal_por, then task-X enters the wait state (2) to receive rendezvous.
When both calling and accepting are ready, task-A enters the wait state (3) for rendezvous
termination. Task-X continues execution and at the point when the rendezvous reply rpl_rdv
has been executed, task-A waiting is released (4) and the rendezvous is terminated.
Rendezvous transfer
The received rendezvous can be forwarded to another port by using fwd_por.
The following graph shows an example in which, task-P receives and answers the rendezvous
port transfer from task-X.
cal_por
acp_por acp_por
cal_por
fwd_por
fwd_por
acp_por
rpl_rdv rpl_rdv
53 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Message
At the time of rendezvous formation, a calling message is passed from the calling task to
receiver task. The reply message is passed from the receiver task to the calling task at the time
of rendezvous end.
Message is copied between the buffers prepared by respective task. Although the structure
resembles to the message buffer function, a message queue does not exist with the type of
synchronous method called rendezvous. In addition please note that, since the copy is
performed in the state of the interrupt prohibition state, the interrupt prohibition time will get
prolonged when a big size data is passed.
54 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
NORTi sets up an ent_int system call, as a unique specification. This is called at the entry of the
interrupt handler, so that interrupt handlers are all described in C. The ent_int system call not
only saves all registers but also changes stack pointers to stack ranges dedicated for interrupt
handlers.
55 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
However, by the interruption routine of high priority, a system call cannot be published from a
kernel. Instead of register bank copy and restoration at the entry and exit of interrupt in ent_int()
and ret_int(), please perform the interrupt function offered by compiler or code it using the
assembly.
56 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Memory pool functions are similar to malloc / free functions in standard C libraries. Memory
pool functions differ from malloc/free functions, as the former possess functions appropriate to
multi-tasking, such as releasing waits for memory acquisition of other tasks when memory is
released.
Memory pools with fixed length are created with cre_mpf and acre_mpf. Contrasting with the
rel_mpf system call that returns a memory block, the get_mpf system call waits for acquisition
of a memory block, the pget_mpf system call polls without waiting, and the tget_mpf system call
waits with a time-out. Besides these, the ref_mpf system call references the conditions of
fixed-length memory pools.
Extended information was deleted from the creation information data structure.
Extended information was removed from the reference information from ref_mpl and ref_mpf.
57 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Memory Pool
Processing of task waiting for memory block
Though the chart above shows both the tasks waiting for memory block and memory block itself,
they do not exist at the same time in the fixed-length memory pool.
In case of the variable length memory pool, when 1 memory block is acquired, int size memory
is used to maintain memory pool size information. With fixed length memory pool there is no
useless memory consumption.
For example, assume that task A, task B, and task C operate in cooperation with message
transmission/reception in which memory pools are combined. As a flow of processing, assume
that task A sends a command message to task B, and that the task B that has received it also
sends the command message to task C, then the task C that has received it sends back a reply
message to task B. If task C is slow in processing, messages from task A to B are consecutively
queued, and at last the memory block has all been used up. It causes task C that has
terminated processing to be incapable of acquiring a memory block to return a reply message.
Further, task B waiting for the reply stops permanently.
On the other hand, dividing the memory pools for each application allows positive use of an
empty memory pool. Thus the number of processes being queued can be controlled.
58 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
System time can be changed using the set_tim system call and after that the count rises with
every periodic interrupt. This system time value can be read by get_tim. System time is
undefined until it is set by set_tim.
Since a timer event handlers are started with the system clock as the base, even if the system
time is changed, it does not affect the previously set up timer event operations.
The timer interrupt cycle is set as the unit of the time so as to avoid unnecessary overhead of
multiplication and division inside the system call.
59 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Cyclic handler
A cyclic handler is a time event handler, which is activated periodically at the specified time.
Using cyclic handler it is possible to sample data that demands interval time accuracy, or
implementation of round-robin type scheduling ring by using rot_rdq etc.
A cyclic handler is created using cre_cyc or acre_cyc and can be deleted using del_cyc system
call. In addition, there is ref_cyc system call which referes to the cyclic handler state, the
system calls sta_cyc to start and stp_cyc to stop the cyclic handler.
Alarm handler
This time event handler is executed only once after the specified time is expired.
An alarm handler can be registered by cre_alm or acre_alm system call and can be cancelled
by del_alm. The activation time of the alarm handler is not set at the time of creation. The alarm
handler activation time is set by sta_alm service call and it can be stopped by stp_alm service
call. Setup cancellation is not done although it is cancelled automatically when an alarm
handler is started. To find out the state of the alarm handler, ref_alm system call is available.
Overrun handler
Overrun handler is a time event handler, which is activated when a task is executed for a time
longer than the set time. System clock is used to monitor the task processing time. For this
reason, the overrun handler time monitoring is not accurate when a set time is below system
clock interval time or when it is not perfect multiple of system clock interval time. Overrun
handler is useful to monitor the task that may go into infinite loop depending on the processing
conditions.
Only one overrun handler can be defined to whole system using def_ovr system call. When
sta_ovr system call is invoked to start the overrun handler, a system time is setup for the
specified task. Stp_over system call is used to stop/cancel the overrun handler. It is possible to
setup overrun handler for two or more tasks. The operational state of the overrun handler and
the remaining processor time can be referred from ref_ovr system call.
60 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Registration / release of the extended service call can be done with def_svc. Extended service
call calls the routine registered by cal_svc.
Please describe the service call routine in C language as shown above. 0 ~ 6 parameters can
be specified with the service call routine.
61 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
When a get_tid is called from the non-task context, instead of FALSE, ID of RUNNING task is
returned.
CPU lock state and dispatch prohibition state are made independent.
62 Rev. 1.01
4. Function Overview NORTi Version 4 User's Guide
Un-supported functions
CPU exception handler definition function (def_exc) is not supported in NORTi.
※ From the next page onwards error types are classified as below.
In the system call description in next chapter, the * and ** mark indicators are defined as below.
63 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
cre_tsk
Description The cre_tsk system call creates tasks specified by tskid. That is, it dynamically
allocates a task management block (TCB) from system memory. In addition, it
dynamically allocates the stack area from stack memory when the stack domain start
address of the task generation information packet is NULL. As a result of creation, the
object task transfers from the NON-EXISTENT state to the DORMANT state.
The value of exinf is passed to the task as the task parameter when task is started by
act_tsk. In addition, exinf value is also passed to an overrun handler. exinf can be
referred by ref_tsk system call.
Please specify tskatr as TA_HLNG that shows that task is described in high-level
language. Moreover, please specify TA_ACT when a state transition from DORMANT
state to READY state is required after task creation.
Please specify name as the task name character string. OS does not use name as an
object or for debugger. Please specify “” or NULL as default specification. You may omit
name when T_CTSK object structure is defined with an initial value.
When a stack memory domain is reserved in the user program, please set stack head
address to stk and set the stack size to stksz parameters.
64 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
Notes As the task generation information packet is not copied to the task management block,
you must keep it even after this system call has been issued. Please define it as a const
variable and place it in the ROM domain. If it is placed in domain other than ROM, then a
copy of task generation information packet is created in the system memory in order to
prevent abnormal operations due to changes or damage during program execution.
TASK task1(void)
{
ER ercd;
:
ercd = cre_tsk(ID_task2, &ctsk2);
:
}
65 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
acre_tsk
Description The acre_tsk system call allocates highest ID from the non-generated task Ids. When no
task ID is allocated, the system call returns an E_NOID error. Otherwise, this is the same
as cre_tsk.
Example ID ID_task2;
const T_CTSK ctsk2 = {TA_HLNG, NULL, task2, 8, 512, NULL};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_tsk(&ctsk2);
if(ercd > 0)
ID_task2 = ercd;
:
}
66 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
del_tsk
Description The del_tsk system call deletes tasks specified by tskid. It releases the stack range for
this task back to stack memory and releases the task control block (TCB) back to system
memory. As a result of deletion, the object task transfers from the DORMANT state to the
NON-EXISTENT state. Please use exd_tsk to delete self-task, as the task itself cannot
specify this system call.
Note Resources other than mutex that an object task acquires (such as memory blocks and
semaphores) are not released automatically. Users are responsible for releasing resources
before deleting tasks.
TASK task1(void)
{
:
del_tsk(ID_task2);
:
}
67 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
act_tsk
iact_tsk
Description This system call starts tasks specified by tskid. Iact_tsk is the macro re-definition of
act_tsk, for compatibility with μITRON specifications. The object task transfers from the
DORMANT state to the READY state (When this task has higher priority than the current
running task, it transfers to the RUNNING state). When the object task is not in the
DORMANT state, this system call queues start requests. The extended information
contained in the information for task creation, is passed to task handler at the time the task
starts.
If TSK_SELF is specified in tskid, it becomes the start request for the task itself and is
queued.
68 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
TASK task1(void)
{
:
cre_tsk(ID_task2, &ctsk2);
cre_tsk(ID_task3, &ctsk3);
:
act_tsk(ID_task2);
act_tsk(ID_task3);
:
}
69 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
can_act
Description This system call cancels the request to start a task specified by tskid and makes it 0.
Return When it is 0 or positive value, it indicates the number of start requests in the queue
(actcnt).
E_ID Task ID is outside valid range*
E_NOEXS Task do not exist
TASK task1(void)
{
cre_tsk(ID_task2, &ctsk2);
:
act_tsk(ID_task2);
:
can_act(ID_task2);
:
}
70 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
sta_tsk
Description The sta_tsk system call starts tasks specified by tskid and passes stacd (when stacd is not
used, 0 is passed). The object task transfers from the DORMANT state to the READY state
(when this task has higher priority than the currently running task, it transfers to the
RUNING state).
Start demands by this system call are not queued. Accordingly, when the object task is not
in the DORMANT state, an error is returned.
TASK task1(void)
{
:
sta_tsk(ID_task2, 1);
sta_tsk(ID_task3, 0);
:
}
71 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ext_tsk
Description By this system call, a task terminates by itself. If there is no start demand in queue, the task
transfers from the RUN state to the DORMANT state. When the start requests are in
queue, it task is restarted after reducing the queue count by 1. The internal state of the task
is initialized during restart. In other words, the task unlocks the mutex, cancels the overrun
handler registration, blocks the task-exeption handler and resets the values for priority,
wakeup requests, forced wakeup requests, suspend/resume factors and stack.
After restart, the task is connected to the tail of initial priority ready queue.
Any resources other than mutex that have been acquired by the task (such as memory
blocks and semaphores) are not released automatically. Users are responsible for
releasing resources before terminating the task.
Even if this function is not called clearly as above, it is automatically called by the return
from the main routine.
72 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
exd_tsk
Description By this system call, a self-task is terminated and then deleted. The call releases the stack
domain for this task back to stack memory and releases the task control block (TCB) back
to system memory. As a result of deletion, the task changes from the RUNNING state to
the NON-EXISTENT state. Any start request in the queue will be cancelled.
Any resources other than mutex that have been acquired by the task (such as memory
blocks and semaphores) are not released automatically. Users are responsible for
releasing resources before terminating the task.
73 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ter_tsk
Description The ter_tsk system call terminates the task specified by tskid. As a result of termination,
the object task transfers from the READY, WAITING or WAITING-SUSPEND state to the
DORMANT state. When the start requests are queued, it restarts. When the object task is
connected to a waiting queue, executing ter_tsk removes the object task from the queue.
Self-task ID cannot be specified to this system call.
Note Any resources other than mutex that have been acquired by the task (such as memory
blocks and semaphores) are not released automatically. Users are responsible for
releasing resources before terminating the task.
TASK task1(void)
{
:
ter_tsk(ID_task2);
:
}
74 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
chg_pri
Description The chg_pri system call uses tskpri values for the priority of the task specified by tskid.
The smaller the number, the higher the priority. There are three priorities i.e. initial priority,
base priority and current priority. Initial priority is the priority specified at the time of task
creation (itskpri) and is set as base priority value when task starts. And this is copied to
base priority when the task starts. Tasks are normally run by base priority but when mutex
is locked, the priorities change temporarily. This changed priority is the current priority.
When mutex is unlocked, the task priority goes back to base priority. Chg_pri changes that
base priority. Usually a task runs with a base priority, but priority may change temporarily
when a mutex is locked. The priority changed temporarily is the present priority. After
mutex is unlocked, the task priority changes back to the base priority.
When the object tasks are queued (ready queue, semaphore or memory pool waiting
queue etc.) in the order of priority, the queuing of waiting connections is rearranged by
change in the priority. The waiting connections in the queue are rearranged even when the
current priority is changed. Please note than when mutex is used, waiting connections in
the queue are exchanged dynamically.
When the priority of an object task in the READY state is made higher than the priority of a
host task, which issued this system call, then the task issuing this system call transfers
from the RUNNING state to the READY state and the object task transfers to the
RUNNING state.
When the priority of the self-task is made lower than other READY tasks, then the self-task
changes from the RUNNING state to the READY state and the task with the highest priority
among the other READY tasks will move to the RUNNING state.
When the same priority as that of the present task is specified, and if there exists other
tasks with same priority, the object task goes to the tail of the priority queue.
75 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
The priority changed by this system call is effective until tasks are terminated. When the
task restarts, the task priority returns to initial priority.
76 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
get_pri
Description This system call returns the current priority of the task specified by tskid.
A self-task can be specified with tskid = TSK_SEL.F.
77 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ref_tsk
The values specified by task generation returns to exinf, tskatr, task, itskpri, & stksz
parameters as it is.
78 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
When the task is in WAITING state, the following values are returned to the task state
parameter, tskwait.
TASK task1(void)
{
T_RTSK rtsk;
:
ref_tsk(ID_task2, &rtsk);
if(rtsk.tskstat == TTS_WAI)
:
}
79 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ref_tst
The parameters tskstat, tskwait returns the same contents as described in ref_tsk.
TASK task1(void)
{
T_RTSK rtst;
:
ref_tst(ID_task2, &rtst);
if (rtst.tskstat == TTS_WAI)
:
}
80 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
sus_tsk
Description The sus_tsk system call suspends the execution of tasks specified by tskid. When the
object task is in the READY state, the system call transfers it to the SUSPENDED state.
When the object task is in the WAITING state, the system call transfers it to the
WAITING-SUSPEND state. A self-task can be specified by tskid=TSK_SELF.
This suspended task can be released by the rsm_tsk or frsm_tsk system call. Task
suspend commands can be nested, i.e. when rsm_tsk is issued for the same number of
times as sus_tsk is issued, then a SUSPENDED state is released for the first time.
TASK task1(void)
{
:
sus_tsk(ID_task2);
:
}
81 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
rsm_tsk
Description The rsm_tsk system call releases the suspended execution of the task specified by tskid.
When the object task is in the SUSPENDED state, it transfers to the READY state (When
the object task has priority higher than the present running task, it transfers to the
RUNNING state). When the object task is in the WAIT-SUSPENDED state, it transfers to
the WAITING state.
Rsm_tsk system call releases single sus_tsk request. In other words, when sus_tsk is
issued more than once, the object task remains in the SUSPENDED state after rsm_tsk is
executed.
TASK task1(void)
{
:
sus_tsk(ID_task2);
:
rsm_tsk(ID_task2);
:
}
82 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
frsm_tsk
Description The frsm_tsk system call forcibly releases the suspended execution of the task specified
by tskid. When the object task is in the SUSPENDED state, it transfers to the READY state
(When the object task has priority higher than the present running task, it transfers to the
RUNNING state). When the object task is in the WAIT-SUSPENDED state, it transfers to
the WAITING state.
Frsm_tsk system call releases all suspend command from the queue. In other words, when
sus_tsk is issued more than once, the object task is released from SUSPENDED state
after frsm_tsk is executed once.
TASK task1(void)
{
:
sus_tsk(ID_task2);
sus_tsk(ID_task2);
:
frsm_tsk(ID_task2);
:
}
83 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
slp_tsk
Declaration ER slp_tsk(void);
Description A task transfers itself to the WAITING state. This WAITING state is released by issuing the
wup_tsk or rel_wai system call.
When wup_tsk is issued first i.e.when wake up request is queued, slp_tsk does not put the
task in wait state. In this case, system call decrements the wake up request count by 1 and
then the call returns with E_OK as normal termination return value. The ready queue for
the task does not change at this time.
TASK task1(void)
{
:
slp_tsk();
:
}
TASK task2(void)
{
:
wup_tsk(ID_task1);
:
}
84 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
tslp_tsk
Description A task transfers itself to the WAITING state. This WAITING state is released by issuing
the wup_tsk or rel_wai system call for this task, or after termination of time specified by
tmout.
When a wait is released by wup_tsk, the tslp_tsk system call returns E_OK as normal
termination. When wup_tsk is issued first and the wake up request is queued, slp_tsk does
not put the task in wait state. The wake up request count is reduced by 1 and the task
returns E_OK as normal termination. Ready queue of the task does not change at this
time.
When a task is released by rel_wai, the tslp_tsk system call returns an E_RLWAI error.
When a task is released by timeout of a specified time, this system call returns an
E_TMOUT error. Tmout is measured in units of the system clock interrupt cycle time.
When tmout is set to TMO_POL (=0) and when wakeup requests are queued, then this
system call returns immediately with an E_OK return value for normal. It returns an
E_TMOUT time-out error code if there is no wakeup request in queue. This system call
does not execute timeout by tmout=TMO_FEVR (= -1), i.e. in such case it operates in the
same way as slp_tsk.
Note1 By using NORTi’s unique MSEC macro, this system call can be described with waiting time
specified in milli second units i.e. tslp_tsk(100/MSEC);
The MSEC macro is defined in kernel.h as “#define10”. But when separate value need to
be applied as system clock, please define the value to all places before kernel.h is
included.
85 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
Note2 After issuing the system call with timeout, since the timing until the first cycle of interrupt
timer is attached, there is an error of –MSEC ~ 0 in timeout. For example, for MSEC=10,
when a timeout of 100msec is set, a timeout in real time will be in the range of 90msec ~
100msec. The timeout in µITRON4.0 is specified as the event when time more than the
specified timeout time is exceeded. In other words, as in above example a valid timeout is
in the range of 100~110msec. In case of NORTi, a valid timeout is in the range of
90~100msec.
Since the task, which performs time waiting, operates in synchronization with periodic
timer interrupt, the difference as shown below will occur.
For(;;){
TASK task1(void)
{
ER ercd;
:
ercd = tslp_tsk(100/MSEC);
if(ercd == E_TMOUT)
:
}
86 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
wup_tsk
iwup_tsk
Description The wup tsk system call releases a task placed in the WAITING state due slp_tsk or
tslp_tsk system call and change the state to READY state (When the task has priority
higher than the current running task, it goes to the RUNNING state, and when it is in the
WAITING-SUSPENDED state, it transfers to the SUSPENDED state). The object task is
specified by tskid. A self-task can be specified from the task-context.
This request for wakeup is queued, when the object task did not performed slp_tsk or
tslp_tsk and is not in the WAITING state. The queued request for wakeup becomes
effective later when the object task executes either the slp_tsk or tslp_tsk system call. Thus
when the wakeup requests are in queue, slp_tsk and tslp_tsk system call decrements
wakeup queue count by 1 and then return immediately to the calling function.
87 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
TASK task1(void)
{
:
slp_tsk();
:
}
TASK task2(void)
{
:
wup_tsk(ID_task1);
:
}
88 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
can_wup
Description This system call returns the number of wakeup request, which have been queued in a task
specified by tskid. At the same time it releases all wakeup requests from queue. A task
itself is specified by tskid=TSK_SELF.
When task wake up is carried out periodically, this system call can be used to judge
whether a process is completed within the interval time. When wupcnt is non-zero positive
value, then it indicates that the previous operation of wake up request has not been
completed within the specified time.
89 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
vcan_wup
Description vcan_wup system call clears the wakeup requests from the queue. This system call is
only for the self-task. This system call is unique to NORTi. If it is only about clearing the
wakeup request then this system call is faster than can_wup.
Return None
90 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
rel_wai
irel_wai
Description When a task specified by tskid is in the WAIT state, the rel_wai system call releases it
forcibly. An E_RLWAI error returns to the waiting task that was released. When the object
task is in the WAITING state, it transfers to the READY state (If the task has priority higher
than the present running task, it transfers to the RUNNING state). When the object task is
in the WAITING-SUSPENDED state, it transfers to the SUSPENDED state.
When the object task is in the other state i.e. when object task is not in wait state, the
object task generates an E_OBJ error. In this case, the state of the object task does not
change. In other words, this system call does not queue requests for releasing the wait
state.
TASK task1(void)
{
:
rel_wai(ID_task2);
:
}
91 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
dly_tsk
Description This call performs the simple time waiting for the task. Although this function is almost
same as tslp_tsk(TMO tmout) system call, the time waiting is not released by wup_tsk
system call. It is recommended to use dly_tsk instead of tslp_tsk, when task is performing
waiting only for time.
The data type of dlytim (delay time), i.e. RELTIM, is a long type similar to TMO of timeout.
Unit of delay time is the interval cycle of the system clock.
92 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
def_tex
Description This system call defines the task exception handling routine for the task specified by tskid.
When *pk_dtex is specified as NULL pointer, this system call will undefined the task
exception handler for the task specified by tskid. Moreover, re-definition is possible if
another definition information packet is specified. In re-definition, the exception handling
request and exception handling permission / prohibition state is inherited. A self-task is
specified when tskid=TSK_SELF.
Following is the structure of the task exception handler definition information packet.
Although OS do not notice contents of texatr, in order to maintain compatibility with other
OS conforming to µITRON specification, please set TA_HLNG to texatr. When a definition
information packet is placed in memory domain other than ROM, a definition information
packet is copied to a system memory.
93 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
TASK task1(void)
{
:
def_tex(ID_task1, &dtex);
:
}
94 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ras_tex
iras_tex
Description Exception handling factor specified by rasptn is demanded for the task specified by tskid.
When an object task is in the waiting state, the exception factor is suspended and the
Exception Handling is not permitted until the object task is in the RUNNING state. A
self-task can be specified as an object task when tskid = TSK_SELF.
TASK task1(void)
{
:
ras_tex(ID_task1, 1);
:
ras_tex(ID_task1, 2);
:
}
95 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
dis_tex
Declaration ER dis_tex(void);
Description In a task context, this system call moves the invoking task to the task exception disabled
state. When issued from the non-task context such as timer handler, the call returns with
E_CTX error code.
96 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ena_tex
Declaration ER ena_tex(void);
Description This system call enables task exception handling when invoked from self-task in task
context or from the task in the interrupt handler that is in execution state. This system call
returns E_CTX error when called from the timer handler.
If there is a pending exception code then the exception handling routine will be performed
when the corresponding task changes into RUNNING state.
97 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
sns_tex
Description This system call returns TRUE if the self-task or the invoked task is in the task exception
handling disabled state, and returns FALSE if the task exception handling is enabled.
TRUE is returned if there is no task in the RUNNING state.
98 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
ref_tex
Description The task exception handling state of the task specified by tskid is returned to *pk_rtex.
TASK task1(void)
{
T_RTEX rtex;
:
ref_tex(ID_task2, &rtex);
if (rtex.pndptn != 0)
:
}
99 Rev. 1.01
5. System Call Description NORTi Version 4 User's Guide
cre_sem
Description The semaphore object is created with an object ID semid. The semaphore management
block memory is dynamically assigned from the system memory. In addition, the
semaphore count is set to the initial value specified by isemcnt of semaphore generation
information data.
When a semaphore generation information packet is placed in memory domain other than
ROM (i.e. when a const data type is not attached), the generation information packet data
is copied to the system memory.
Please set maxsem to the number of enabled semaphore resources. The upper limit value
that can be set is defined in TMAX_MAXSEM
Since name is an object for debugger correspondence, please specify “” or NULL when not
used. When this structure object is defined with initial value, you may omit name.
TASK task1(void)
{
ER ercd;
:
ercd = cre_sem(ID_sem1, &csem1);
:
}
acre_sem
Description This function searches the highest ID from the unassigned semaphore Ids. When no
semaphore ID is allocated, the system call returns an E_NOID error. Otherwise, this is
the same as cre_sem.
Example ID ID_sem1;
const T_CSEM csem1 = {TA_TFIFO, 0, 1};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_sem(&csem1);
if(ercd > 0)
ID_sem1 = ercd;
:
}
del_sem
Description This function delets the Semaphore specified by semid, and the semaphore management
block memory is released to system memory.
When there is a task waiting for this semaphore, the waiting of the task is cancelled.
E_DLT error (since the semaphore is deleted) will be returned by the task which was
waiting for this semaphore.
TASK task1(void)
{
:
del_sem(ID_sem1);
:
}
sig_sem
isig_sem
Description This system call increases the semaphore count by one (returning resources), when there
are no tasks waiting for semaphores specified by semid. Error E_QOVR is returned when
the semaphore count exceeds the maximum value specified at the time of semaphore
creation.
When tasks are waiting for this semaphore, the sig_sem system call releases the heading
task in the queue from waiting, i.e. this system call transfers the task from the WAITING
state to the READY state. (When this task has higher priority than the current RUNNING
task, this system call transfers it to the RUNNING state, and when it is in the
WAITING-SUSPENDED state, the system call transfers it to the SUSPENDED state).
wai_sem
Description When the semaphore count specified by semid is more than 1, this system call decreases
the semaphore count by 1 (acquiring resources) and returns immediately.
When the semaphore count is 0, the task which issed this system call is queued for waiting
this semaphore. In this case, the semaphore count remains 0.
TASK task1(void)
{
:
wai_sem(ID_sem1);
:
sig_sem(ID_sem1);
:
}
pol_sem
Description When the semaphore count specified by semid is more than 1, this system call decreases
the semaphore count by 1 (acquiring resources) and returns immediately.
When the semaphore count is 0, the system call does not enter the WAIT state and returns
at once with an E_TMOUT error.
twai_sem
Description When the semaphore count specified by semid is more than 1, this system call decreases
the semaphore count by 1 (acquiring resources) and returns immediately. When the
semaphore count is 0, the task which issed this system call is queued for waiting this
semaphore. In this case, the semaphore count remains 0.
After the time specified by tmout passes, an E_TMOUT time-out error returns. The
twai_sem system call does not execute waits by tmout=TMO_POL (=0). It runs in the same
way as pol_sem. It does not execute time-outs by tmout=TMO_FEVR (=-1) It runs in the
same way as wai_sem.
TASK task1(void)
{
ER ercd;
:
ercd = twai_sem(ID_sem1, 100/MSEC);
if (ercd == E_OK)
:
}
ref_sem
Description This system call returns the state of the semaphore specified by semid to *pk_rsem data
pointer.
When there is a waiting task, wtskid returns the ID of the heading task in the waiting queue.
Wtskid = TSK_NONE, when there is no waiting task.
TASK task1(void)
{
T_RSEM rsem;
:
ref_sem(ID_sem1, &rsem);
if (rsem.wtsk != FALSE)
:
}
cre_flg
Description The cre_flg system call creates an event flag specified by flgid. It dynamically allocates an
event flag management control block from system memory. In addition, the initial value
specified by event flag creation information, i.e. iflgptn, is set as a bit pattern for that event
flag.
When the event flag generation information packet is not placed in ROM domain, i.e. when
information packet is not const data type, the information definition packet is copied to the
system memory.
The structure of the event flag generation information packet is as shown below.
TBIT_FLGPTN macro defines the number of flag bits that can be used.
Following are the valid input values for flgatr i.e. event flag attribute.
The tasks waiting in queue are not necessarily released in the order of waiting queue. The
tasks are released from waiting when it matches the corresponding flag bit pattern. When
TA_CLR is not specified, two or more task may be simultaneously released from waiting.
When TA_CLR is specified, since the flag clears as soon as the first task is released from
waiting, multiple tasks are not released simultaneously.
TASK task1(void)
{
ER ercd;
:
ercd =cre_flg(ID_flg1, &cflg1);
:
}
acre_flg
Description This system call assigns the highest value of ID searched among the non-generated event
flags. When no event flag ID is allocated, the system call returns an E_NOID error.
Otherwise, this is the same as cre_flg.
Return When it is non-zero positive value, the return value indicates the event flag ID.
E_NOID Insufficient ID for Event flag.
E_CTX The command issued from an interrupt handler*
E_SYS Insufficient memory for the management block**
Example ID ID_flg1;
const T_CFLG cflg1 = {TA_WMUL, 0};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_flg(&cflg1);
if(ercd > 0)
ID_flg1 = ercd;
:
}
del_flg
Description This system call deletes an event flag specified by flgid. It releases an event flag
management block back to system memory.
When a task is waiting for this event flag, the del_flg system call cancels the task waiting.
An E_DLT error will be returned by the wait-cancelled task, indicating that the event flag
was deleted during waiting.
TASK task1(void)
{
:
del_flg(ID_flg1);
:
}
set_flg
iset_flg
Description This system call sets up bits, indicated by setptn, for an event flag specified by flgid. In
other words, a logical OR is taken with the value of setptn to the value of the present event
flag (flgptn |= setptn).
As a result of changing the value of the event flag, the tasks that were waiting for the event
flag are releases from waiting if the wait-release conditions are matched. This system call
transfers the task from the WAITING state to the READY state (When the task has higher
priority than the current running task, the system call transfers it to the RUNNING state and
when in the WAITING-SUSPEND state, the set_flg system call transfers it to the
SUSPENDED state).
When TA_CLR is specified during event flag creation, and if there is a task that has been
released from waiting, then the event flag is cleared as soon as the first task is released
from waiting.
When TA_CLR is not specified and waiting for multiple tasks is allowed, with single set_flg,
multiple tasks may get released simultaneously. Depending on the relation between waiptn
and wfmode in wai_flg, existence of TA_CLR in generation information, it is not necessary
that the top-most task from the queue get wait released. Also, if there are tasks with clear
specification waiting in the queue and these are released from waiting, then the
subsequent waiting tasks lined up behind will not be released as they will refer to the
cleared event flags.
TASK task1(void)
{
:
set_flg(ID_flg1, BIT0);
:
}
clr_flg
Description This system call clears the bits, which are 0 by clrptn, for an event flag specified by flgid.
Logical AND is taken with clrptn value and the current value of event flag.
(flgptn &= clrptn)
By clr_flg system call, the task waiting for the event flag are not released from waiting.
TASK task1(void)
{
:
clr_flg(ID_flg1, ~BIT0);
:
}
wai_flg
Description According to the wait conditions indicated by waiptn and wfmode, this system call waits
for an event flag specified by flgid is set.
Please put the following values in wfmode to specify waiting mode.
When TWF_ORW is specified, the system call waits for either of the bits specified by
waiptn to be set. When TWF_ANDW is specified, it waits for all the bits specified by
waiptn to be set. When there is only one bit=1 in waiptn, TWF_ANDW and TWF_ORW
have the same results.
When TWF_CLR is specified, if the conditions are satisfied and the task is released from
waiting, then the wai_flg system call clears all bits for the event flag. But when TA_CLR is
specified by the creation information as the flag attribute, all bits are cleared even if
TWF_CLR is not specified.
An event flag value for wait release, is returned to *p_flgptn. When clearing is specified,
the value before being cleared is passed to *p_flgptn. When the event flag conditions are
already matched, the above operation is carried out without entering the wait state.
TASK task1(void)
{
FLGPTN ptn;
:
wai_flg(ID_flg1, BIT0, TWF_ANDW, &ptn);
:
}
pol_flg
Description According to the wait conditions indicated by waiptn and wfmode, this system call waits for
an event flag specified by flgid is set. The function terminates normally when the wait
conditions have already been satisfied, or else function returns with E_TMOUT error value.
An event flag value for wait release, is returned to *p_flgptn. When clearing is specified, the
value before being cleared is passed to *p_flgptn.
TASK task1(void)
{
FLGPTN ptn;
:
if(pol_flg(ID_flg1, 0xffff, TWF_ORW|TWF_CLR, &ptn) == E_OK)
:
}
twai_flg
Declaration ER twai_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn, TMO tmout);
flgid Event flag ID
waiptn Waiting bit pattern
wfmode Waiting mode
p_flgptn Pointer to the location which stores the bit pattern for wait release.
Tmout Timeout value
Description According to the wait conditions indicated by waiptn and wfmode, this system call waits for
an event flag specified by flgid is set. When the wait conditions have already been
satisfied, the system call does not enter the WAITING state and it terminates normally.
When the time specified by tmout passes, the call resturns with E_TMOUT time-out error.
The twai_flg system call does not execute waits for tmout=TMO_POL (=0), i.e. it executes
in the same way as pol_flg. For tmout=TMO_FEVR (=-1), this system call does not execute
timeout, i.e. it executes the same way as wai_flg.
TASK task1(void)
{
FLGPTN ptn;
ER ercd;
:
ercd = twai_flg(ID_flg1, 0xffff, TWF_ANDW|TWF_CLR, &ptn, 1000/MSEC);
if(ercd == E_TMOUT)
:
}
ref_flg
Description This system call returns the state of the event flag specified by flgid to *pk_rflg.
When the waiting task exists, the ID of the heading task in the waiting queue is returned in
wtskid. When there is no waiting task, wtskid=TSK_NONE.
TASK task1(void)
{
T_RFLG rflg;
:
ref_flg(ID_flg1, &rflg);
if (rflg.flgptn != 0)
:
}
cre_dtq
Description The cre_dtq system call creates a data queue specified by dtqid. The sata queue
management block is dynamically allocated from system memory.
When a data queue creation information packet is placed in memory domain other than
ROM (i.e. when a const data type is not attached), the creation information packet data is
copied to the system memory.
Please put following values to data queue attribute parameter, i.e. dtqatr.
TA_TFIFO Transmission waiting queue for Data queue is in the order of arrival (FIFO)
TA_TPRI Transmission waiting queue for Data queue is in the order of task priority
The reception-waiting queue for Data queue is always in the order of arrival (FIFO). The
transmission order becomes same as the data oder. However, when forced sending
(fsnd_dtq, ifsnd_dtq) is used, the forcibly sent data may be received first.
Please set the queueing data count (number of bytes) in dtqcnt, and set the data buffer
start address in dtq. The size of memory required for data number n, can be found using
TSZ_DTQ(n) macro. If NULL is set in dtq, the data buffer will be allocated from system
memory. If 0 is set in dtqcnt, the data between tasks can be directly passed and
synchronized without using the buffer.
TASK task1(void)
{
ER ercd;
:
ercd = cre_dtq(ID_dtq1, &cdtq1);
:
}
acre_dtq
Description This system call assigns the highest ID value searched among the non-generated data
queue ID values. In case of failure to search the data queue ID, this system call returns
with E_NOID error code. Except above differences, this system call is same as cre_dtq
Return When this call is successful, the positive return value is the allocated data queue ID.
E_NOID Insufficient ID for Data Queue
E_CTX The command issued from an interrupt handler*
E_SYS Insufficient system memory for management block**
Example ID ID_dtq1;
const T_CDTQ cdtq1 = {TA_TPRI, 30, NULL};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_dtq(&cdtq1);
if(rcd > 0)
ID_dtq1 = ercd;
:
}
del_dtq
Description The del_dtq system call deletes a data queue specified by dtqid. The data queue
management block is released to the system memory. The data buffer will also be released
in case OS allocated the data buffer. The data inside the buffer is cancelled.
When any task is waiting for this data queue, this system call releases that task waiting.
The released task returns with E_DLT error code indicating that the data queue was
deleted while the task was waiting.
TASK task1(void)
{
:
del_dtq(ID_dtq1);
:
}
snd_dtq
Description This system call sends data to a data queue specified by dtqid.
When there are tasks waiting for this data queue, this system call will release the top most
waiting task in the queue, i.e. the task is changed from the WAITING state to the READY
state (when the waiting task priority higher than the current running task, it is changed to
the RUNNING state, and when in the WAITING-SUSPENDED state, it changes to
SUSPENDED state).
When no task is waiting to receive, the data is put in the end of the data buffer. When there
is no empty space in the data buffer, the task is connected to the send-waiting queue.
TASK task1(void)
{
VP_INT data
:
data = (VP_INT) 1;
snd_dtq(ID_dtq1, data);
:
}
psnd_dtq
ipsnd_dtq
Description This system call sends data to a data queue specified by dtqid.
When there are tasks waiting for this data queue, this system call will release the top most
waiting task in the queue, i.e. the task is changed from the WAITING state to the READY
state (when the waiting task priority higher than the current running task, it is changed to
the RUNNING state, and when in the WAITING-SUSPENDED state, it changes to
SUSPENDED state).
When no task is waiting to receive, the data is put in the end of the data buffer. When there
is no empty space in the data buffer, this system call immediately returns back with
E_TMOUT error code. Moreover, when data buffer size is 0 and if there is no waiting task
to receive data, then this call returns with E_TMOUT error.
TASK task1(void)
{
VP_INT data;
ER ercd;
:
data = (VP_INT) 1;
ercd = psnd_dtq(ID_dtq1, data);
if(ercd == E_OK)
:
:
}
tsnd_dtq
Description This system call sends data to a data queue specified by dtqid.
When there are tasks waiting for this data queue, this system call will release the top most
waiting task in the queue, i.e. the task is changed from the WAITING state to the READY
state (when the waiting task priority higher than the current running task, it is changed to
the RUNNING state, and when in the WAITING-SUSPENDED state, it changes to
SUSPENDED state).
When no task is waiting to receive, the data is put in the end of the data buffer. When there
is no empty space in the data buffer, the task is connected to the send-waiting queue.
If there is no empty space in data buffer within the time specified by tmout, this system call
returns an E_TMOUT time-out error. When this system call is issued with
tmout=TMO_POL (=0), the call executes similar to psnd_dtq, i.e. it does not perform
waiting to send data. For tmout=TMO_FEVR (=-1), this system call runs same as snd_dtq,
i.e. there is no timeout.
TASK task1(void)
{
VP_INT data;
ER ercd;
:
data = (VP_INT) 1;
ercd = tsnd_dtq(ID_dtq1, data, 1000/MSEC);
if (ercd != E_TMOUT)
:
:
}
fsnd_dtq
ifsnd_dtq
Description This system call forcibly sends data to a data queue specified by dtqid.
When there are tasks waiting for this data queue, this system call will pass the data and
release the top most waiting task in the queue, i.e. the task is changed from the WAITING
state to the READY state (when the waiting task priority higher than the current running
task, it is changed to the RUNNING state, and when in the WAITING-SUSPENDED state,
it changes to SUSPENDED state).
When no task is waiting to receive, the data is put in the end of the data buffer. When there
is no empty space in the data buffer, this system call will disacrd the data that is top in the
queue, and will replace that with the forced data. Data is put into the buffer even when
there is other waiting task for transmission.
When data buffer size is 0 and if there is no waiting task to receive data, then this call
returns with E_ILUSE error.
TASK task1(void)
{
VP_INT data;
:
data = (VP_INT) 1;
fsnd_dtq(ID_dtq1, data);
:
}
rcv_dtq
Description This system call receives a data from the first task in data queue specified by dtqid. When
there are tasks waiting to send, the data to be sent is put in the data queue and the
send-waiting task is released. When the data queue size is 0, data is received from the
heading task in send-waiting queue. The send-waiting task is released after data reception.
When there is no data or task waiting to send, the calling task is connected to the queue of
tasks waiting to receive.
TASK task1(void)
{
VP_INT data;
:
rcv_dtq(ID_dtq1, &data);
:
}
prcv_dtq
Description This system call receives a data from the first task in data queue specified by dtqid. When
there are tasks waiting to send, the data to be sent is put in the data queue and the
send-waiting task is released. When the data queue size is 0, data is received from the
heading task in send-waiting queue. The send-waiting task is released after data reception.
When there is no data or task waiting to send, this system call returns with E_TMOUT error
code.
TASK task1(void)
{
VP_INT data;
:
if(prcv_dtq(ID_dtq1, &data) == E_OK)
:
}
trcv_dtq
Description This system call receives a data from the first task in data queue specified by dtqid. When
there are tasks waiting to send, the data to be sent is put in the data queue and the
send-waiting task is released. When the data queue size is 0, data is received from the
heading task in send-waiting queue. The send-waiting task is released after data reception.
If no message is received within the time specified by tmout, this system call returns an
E_TMOUT time-out error. When this system call is issued with tmout=TMO_POL (=0), the
call executes similar to prcv_dtq, i.e. it does not perform waiting for data when there is no
data in queue. For tmout=TMO_FEVR (=-1), this system call runs same as rcv_dtq, i.e.
there is no timeout.
TASK task1(void)
{
VP_INT data;
ER ercd;
:
ercd = trcv_dtq(ID_dtq1, &data, 1000/MSEC);
if(ercd == E_TMOUT)
:
}
ref_dtq
Description This system call collects the state of the data queue specified by dtqid. The state reference
information is returned in *pk_rdtq structure.
When there is a waiting task, stskid & rtskidreturns the task ID number of the waiting task.
TSK_NONE is returned when there is no waiting task.
TASK task1(void)
{
T_RDTQ rdtq;
:
ref_dtq(ID_dtq1, &rdtq);
if(rdtq.sdtqcnt != 0)
:
}
cre_mbx
Description The cre_mbx system call creates a mailbox specified by mbxid. It dynamically allocates a
control block for the mailbox from system memory.
TA_TFIFO Mailbox reception waiting task processing in the order of arrival (FIFO).
TA_TPRI Mailbox reception waiting task processing is in the order of task priority.
TA_MFIFO Message queuing is in the order of arrival (FIFO).
TA_MPRI Message queuing is in the order of message priority.
When TA_MPRI is specified in mbxatr, a message queue is formed with the order of
message priority. The size of the message queue header can be defined by using
TSZ_MPRHD macro. When a queuing header is prepared in the user area, please ensure
the memory area of number of bytes defined by TSZ_MPRHD and specify the head
address as mprihd. When NULL is specified in mprihd, the queue header is allocated from
the system memory.
Set the maximum value of message priority in maxmpri. Be careful in setting maxmpri,
since large amount of memory is consumed for higher value of maxmpri. Similar to task
priority, lower value indicates the higher message priority and the priority decreases as the
value increases.
Since name is for debugger correspondence, please set “” or NULL when none is selected.
You may omit name when creation information structure object is defined with initial value.
TASK task1(void)
{
ER ercd;
:
ercd = cre_mbx(ID_mbx1, &cmbx1);
:
}
acre_mbx
Description This system call allocates the highest ID value searched from non-generated mailbox ID
values. System call will return with E_NOID error when a mailbox ID allocation fails.
Except above the other part is same as cre_mbx system call.
Example ID ID_mbx1;
const T_CMBX cmbx1 = {TA_TFIFO|TA_MFIFO, 1, NULL };
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_mbx(&cmbx1);
if(ercd > 0)
ID_mbx1 = ercd;
}
del_mbx
Description The del_mbx system call deletes a mailbox specified by mbxid. The memory allocated at
the time of mailbox creation i.e.management control block etc. is released back to the
system memory.
When a task is waiting for a message to be received by this mailbox, the system call
releases this task from waiting. The task, whose wait was released, returns an E_DLT error
indicating mailbox deletion.
A queued message if any will be lost. When the message is allocated dynamically from the
memory pool, before deleting the mail box please read the message using prcv_msg and
return it to a suitable memory pool. Since OS cannot automatically release all memory
resources allocated by user, the memory leak may occur.
TASK task1(void)
{
:
del_mbx(ID_mbx1);
:
}
snd_mbx
Description This system call sends a message indicated by pk_msg, to the mailbox specified by mbxid.
Only a pointer (value of pk_msg) is send, i.e. the contents of the message are not copied.
The OS is not concerned with message size.
When no task is waiting for this mailbox, the snd_msg system call connects the message
to the message queue for that mailbox and returns immediately.
When there are tasks waiting for this mailbox, the system call passes message to the top
most waiting task in the queue and releases the wait. This system call transfers the task
from the WAITING state to the READY state (when the waiting task priority higher than the
current running task, the snd_mbx system call transfers a task to the RUNNING state, and
when in the WAITING-SUSPENDED state, it changes to SUSPENDED state).
The T_MSG type structure defined as a standard message packet is shown below.
For queuing messages, the OS uses next from the message header part as a pointer. It is
the part after msgcont in message header where user can actually put the message. The
T_MSG type is a prototype declaration of the system call function and should not be used
by the user program. As in the user program define the message structure according to
use and pass to the system call with implicit casting as either (T_MSG*) or (T_MSG**).
When message priority is used, set INT msgpri in addition to next in the header structure
(please refer to Example2). Since the domain, which OS uses, is destroyed in case of
snd_mbx, please do perform multiplex transmission.
Note Though the standard length of message MSGS is 16bit, users can #define MSGS as a
separate value before #include "kernel.h" (See Example 1).
It is better to have user defined part in the message packet structure object after msgcont,
as per the actual user requirement (see Example2). msgpri definition can be omitted if the
message priority order is specified as the queueing order at the time of mailbox creation.
Since messages are queued without actually copying, please allocate each message a
separate domain (memory pool etc). When single global variable is used, multiplex
transmission problem can occur if two or more messages are queued.
Moreover, allocation of the automatic variables inside the function is prohibited to avoid
erroneous operation.
TASK task1(void)
{
T_MSG *msg;
:
get_mpf(ID_mpf, &msg); /* Get the message domain */
msg->msgcont[0] = 2;
msg->msgcont[1] = 0;
msg->msgcont[2] = 3;
msg->msgcont[3] = 0;
snd_mbx(ID_mbx, msg); /* Send the message to mailbox */
:
}
#define ID_mbx 1
#define ID_mpf 1
TASK task1(void)
{
T_MYMSG *msg;
:
get_mpf(ID_mpf, &msg); /* Message domain is obtained */
msg->msgpri = 1; /* Message priority (need not be defined when not using) */
msg->fncd = 2;
msg->data = 3;
snd_mbx(ID_mbx, (T_MSG *)msg); /* Message send to mailbox */
:
}
rcv_mbx
Description This system call receives a message from the mailbox specified by mbxid.The contents of
messages are not copied instead only the message pointer is passed to *ppk_msg.
When messages have already been queued, the system call puts a top message pointer
to ppk_msg and returns immediately. When no messages have arrived in the mailbox yet,
the task issuing this system call is connected to the queue waiting for the mailbox.
In case the message sending task has acquired message domain from memory pool, the
receiver side task should release the message memory to the same memory pool after
message reception is finished.
TASK task2(void)
{
T_MYMSG *msg;
:
rcv_mbx(ID_mbx1, (T_MSG**)&msg);
:
rel_mpf(ID_mpf1, (VP)msg); /* Message released to memory pool */
}
prcv_mbx
Description This system call receives a message from the mailbox specified by mbxid.The contents of
messages are not copied instead only the message pointer is passed to *ppk_msg.
When messages have already been queued, the system call puts a top message pointer to
ppk_msg and returns immediately. When no messages have arrived in the mailbox yet, the
call returns back with E_TMOUT error code without going into the WAITING state.
TASK task1(void)
{
T_MYMSG *msg;
ER ercd;
:
ercd = prcv_mbx(ID_mbx1, (T_MSG**)&msg);
if(ercd == E_OK)
:
}
trcv_mbx
Description This system call receives a message from the mailbox specified by mbxid.The contents of
messages are not copied instead only the message pointer is passed to *ppk_msg.
When messages have already been queued, the system call puts a top message pointer to
ppk_msg and returns immediately. When no messages have arrived in the mailbox yet, the
task issuing this system call is connected to the queue waiting for the mailbox.
If no message arrives within the time specified by tmout, the trcv_msg system call returns
with E_TMOUT timeout error. When this system call is issued with tmout=TMO_POL (=0),
the call executes similar to prcv_mbx, i.e. it does not perform waiting for message when
there is no message in queue. For tmout=TMO_FEVR (=-1), this system call runs same as
rcv_mbx, i.e. there is no timeout.
TASK task1(void)
{
T_MYMSG *msg;
ER ercd;
:
ercd = trcv_mbx(ID_mbx1, (T_MSG **)&msg, 1000/MSEC);
if(ercd == E_OK)
:
}
ref_mbx
Description This system call returns the state of the mailbox specified by mbxid, to *pk_rmbx.
The structure of the mailbox state packet is as shown below.
When there are tasks waiting in queue, tskid returns the ID number of the heading task.
When there are no waiting tasks, it returns TSK_NONE.
TASK task1(void)
{
T_RMBX rmbx;
:
ref_mbx(ID_mbx1, &rmbx);
if(rmbx.pk_msg != NULL)
:
}
cre_mtx
Description The cre_mtx system call creates a mutex specified by mtxid. It dynamically allocates a
mutex management block from system memory.
When a mutex creation information packet is placed in memory domain other than ROM
(i.e. when a const data type is not attached), the creation information packet data is copied
to the system memory.
Please put any of following values to Mutex attribute parameter i.e. mtxatr.
When TA_INHERIT is specified, the current priority of the task is handled using priority
inheritance protocol and priority inversion is prevented. While mutex is locked, if a high
priority task waiting to lock the mutex enters the WAITING state, then the priority of the
locked task becomes the same as the highest priority task waiting in the queue.
By doing this, a task with middle priority pre-empts the task that is locking mutex. It
indirectly prevents the blocking of the higher priority task waiting to lock the mutex.
When TA_CEILING is specified, the current priority of the task is handled using priority
ceiling protocol. In the priority ceiling protocol, ceilpri is used, which is specified in the
creation information. When the task locks the mutex specified by TA_CEILING, the current
priority of this task becomes the value specified by ceilpri. The priority value of the highest
priority task is set in ceilpri, among the tasks, which commonly shares the mutex. Thus the
same effect as priority inheritance protocol can be acquired.
Since name is for debugger correspondence, please set “” or NULL when none is selected.
You may omit name when creation information structure object is defined with initial value.
TASK task1(void)
{
ER ercd;
:
ercd = cre_mtx(ID_mtx1, &cmtx1);
:
}
acre_mtx
Description This system call allocates the highest ID value searched from non-generated mutex ID
values. System call will return with E_NOID error when a mutex ID allocation fails. Except
above the other part is same as cre_mtx system call.
Example ID ID_mtx1;
const T_CMTX cmtx1 = {TA_TFIFO, 0};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_mtx(&cmtx1);
if(ercd > 0)
ID_mtx1 = ercd;
:
}
del_mtx
Description The del_mtx system call deletes a mutex specified by mtxid. The mutex management
block is released back to the system memory.
When a task is waiting for this mutex, the system call releases this task from waiting. The
task, whose wait was released, returns an E_DLT error indicating that the mutex was
deletion while the task was waiting for it.
TASK task1(void)
{
:
del_mtx(ID_mtx1);
:
}
unl_mtx
Description This system call will unlock the mutex specified by mtxid.
If there are tasks waiting for this mutex, the heading task from the waiting queue is
released from WAITING state. This system call transfers the task from the WAITING state
to the READY state (when the waiting task priority higher than the current running task, this
system call transfers a task to the RUNNING state, and when in the
WAITING-SUSPENDED state, it changes to SUSPENDED state). The released task
may lock the mutex again.
It is not possible to unlock the mutex, which is not under lock by the issuing task.
loc_mtx
Description When the mutex specified by mtxid is not locked, this system call will lock the mutex. In
case the object mutex is already locked, the task calling this system call will be connected
to the queue waiting to lock the mutex.
When the calling task has already locked the mutex, i.e. when you do multiple locks, this
system call returns the E_ILUSE error. Moreover, E_ILUSE error is returned when a task,
having higher base priority than the ceiling priority, locks the TA_CEILING specified mutex.
TASK task1(void)
{
:
loc_mtx(ID_mtx1);
:
unl_mtx(ID_mtx1);
:
}
ploc_mtx
Description When the mutex specified by mtxid is not locked, this system call will lock the mutex. In
case the object mutex is already locked, this call will return back with E_TMOUT error.
Except this the other functionality is similar to loc_mtx system call.
tloc_mtx
Description When the mutex specified by mtxid is not locked, this system call will lock the mutex. In
case the object mutex is already locked, the task calling this system call will be connected
to the queue waiting to lock the mutex. If the mutex is not locked within the time specified
by tmout, then this system call will return back with timeout error, E_TMOUT. Except above
differences, other operation is same as loc_mtx system call.
When this system call is issued with tmout=TMO_POL (=0), the call executes similar to
ploc_mtx, i.e. it does not perform waiting. For tmout=TMO_FEVR (=-1), this system call
runs same as loc_mtx, i.e. there is no timeout.
TASK task1(void)
{
ER ercd;
:
ercd = tloc_mtx(ID_mtx1, 100/MSEC);
if(ercd == E_OK)
:
}
ref_mtx
Description This system call returns the state of the mutex specified by mbxid, to *pk_rmtx.
When there is a task, which had locked the object mutex, then that task ID value will be
returned in htskid. TSK_NONE will be returned when there is no such task.
ID number of the heading task in the mutex queue will be returned in wtskid. When there is
no waiting task, TSK_NONE is returned.
TASK task1(void)
{
T_RMTX rmtx;
:
ref_mtx(ID_mtx1, &rmtx);
:
}
cre_mbf
Description The cre_mbf system call creates a message buffer specified by mbfid. Message buffer
management block is dynamically allocated from system memory.
When a message buffer creation information packet is placed in memory domain other
than ROM (i.e. when a const data type is not attached), the creation information packet
data is copied to the system memory.
Please put any of following values to message buffer attribute parameter i.e. mbfatr.
When TA_TPRIR is not specified to mbfatr, the processing of receive-waiting task is in the
order of arrival.
When the ring buffer domain is secured by user program, please set the start address of
ring buffer to mbf. In this case, since the part of buffer will be used for message
management, all ring buffer domain cannot be used by user program.
The total size in order to store msgcnt number of messages of size msgsz bytes (msgsz >
1), can be obtained using TSZ_MBF(msgcnt, msgsz) macro definition. However, when the
message size is 1 byte (msgsz=1), the memory domain of size msgsz bytes is essential i.e.
thre is no overhead by OS.
When the mbf is NULL, the ring buffer memory of size defined by mbufsz, is dynamically
allocated from memory pool domain.
It is also possible to set mbfsz=0. In such a case, the ring buffer is not required. When
mbfsz=0, the tasks are synchronized to transfer the data directly.
Since name is for debugger correspondence, please set “” or NULL when none is selected.
You may omit name when creation information structure object is defined with initial value.
TASK task1(void)
{
ER ercd;
:
ercd = cre_mbf(ID_mbf1, &cmbf1);
:
}
acre_mbf
Description This system call allocates the highest ID value searched from non-generated message
buffer ID values. System call will return with E_NOID error when the ID allocation fails.
Except above the other part is same as cre_mbf system call.
Example ID ID_mbf1;
const T_CMBF cmbf1 = {TA_TFIFO, 32 ,512, NULL};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_mbf(&cmbf1);
if(ercd > 0)
ID_mbf1 = ercd;
}
del_mbf
Description The del_mbf system call deletes a message buffer specified by mbfid. The message buffer
management block is released to the system memory. The ring buffer domain will also be
released in case OS allocated the ring buffer.
When a task is waiting this message buffer for transmission or reception, the system call
releases this task from waiting. The task, whose wait was released, returns an E_DLT error
indicating that the message buffer was deletion while the task was waiting for it.
TASK task1(void)
{
:
del_mbf(ID_mbf1);
:
}
snd_mbf
Description This system call sends the message defined by msg & msgsz, to the message buffer
specified by mbfid.
When there is a task waiting for the message from this message buffer, the snd_mbf
system call copies the message to the receiving buffer of the heading task in the
receive-waiting queue, and then releases that task from waiting.
When no tasks are waiting for the message to be received from this message buffer, this
system calls copies the message to the ring buffer used by that message buffer. However,
if the ring buffer is full, the task that issued this system call enters the WAITING state and
waits for the message to be sent.
In order to perform queuing of messages of size msgsz in snd_mbf, psnd_mbf & tsnd_mbf
system calls, the ring buffer should have the minimum free space of size,
= msgsz + 2Bytes (The header part which shows message size).
However, when message maximum length, maxmsg, is specified as 1 byte, additional 2
byte header is unnecessary.
TASK task1(void)
{
H cmd = 0x0012;
:
snd_mbf(ID_mbf1, (VP)&cmd, sizeof cmd);
:
}
psnd_mbf
Description This system call sends the message defined by msg & msgsz, to the message buffer
specified by mbfid.
When there is a task waiting for the message from this message buffer, the snd_mbf
system call copies the message to the receiving buffer of the heading task in the
receive-waiting queue, and then releases that task from waiting.
When no tasks are waiting for the message to be received from this message buffer, this
system calls copies the message to the ring buffer used by that message buffer. However,
if the ring buffer is full, without entering the WAITING state, the call returns back with
E_TMOUT error.
TASK task1(void)
{
B msg[16] ;
:
strcpy(msg, "Hello");
if(psnd_mbf(ID_mbf2, (VP)msg, strlen(msg)) != E_OK)
:
}
tsnd_mbf
Description This system call sends the message defined by msg & msgsz, to the message buffer
specified by mbfid.
When there is a task waiting for the message from this message buffer, the snd_mbf
system call copies the message to the receiving buffer of the heading task in the
receive-waiting queue, and then releases that task from waiting.
When no tasks are waiting for the message to be received from this message buffer, this
system calls copies the message to the ring buffer used by that message buffer. However,
if the ring buffer is full, the task that issued this system call enters the WAITING state and
waits for the message to be sent.
If there is no free space even after the time specified by tmout is passed, then this system
call will return back with timeout error, E_TMOUT.
When this system call is issued with tmout=TMO_POL (=0), the call executes similar to
psnd_mbf, i.e. it does not perform waiting. For tmout=TMO_FEVR (=-1), this system call
runs same as snd_mbf, i.e. there is no timeout.
TASK task1(void)
{
B *res = "Hello";
ER ercd;
:
ercd = tsnd_mbf(ID_mbf2, (VP)res, 5, 1000/MSEC);
if(ercd = E_TMOUT)
:
}
rcv_mbf
Description The rcv_mbf system call receives a message, from the message buffer specified by mbfid.
The received message is copied to msg. This system call returns the size of the received
message.
The size of domain pointed by msg, need to be larger than the maximum length of
message (maxmsz), which was specified t the time of message buffer creation.
When message has not arrived in the message buffer, the task that has issued this system
call is connected to the queue of tasks waiting for the message to be received from this
message buffer.
Return When positive, this return value indicates received message byte count.
E_ID Message buffer ID is outside valid range*
E_NOEXS This message buffer is not created
E_CTX Issued from the non-task context, or waiting in dispatch prohibited state*
E_RLWAI Waiting state was released forcibly (rel_wai was issued while waiting)
E_DLT Message buffer was deleted while waiting for it
TASK task1(void)
{
H cmd;
ER dummy;
:
dummy = rcv_mbf(ID_mbf1, (VP)&cmd);
:
}
prcv_mbf
Description This system call receives a message, from the message buffer specified by mbfid. The
received message is copied to msg. This system call returns the size of the received
message.
The size of domain pointed by msg, need to be larger than the maximum length of
message (maxmsz), which was specified t the time of message buffer creation.
When message has not arrived in the message buffer, without entering the WAITING
state, this system call returns with E_TMOUT timeout error.
Return When positive, this return value indicates received message byte count.
E_ID Message buffer ID is outside valid range*
E_NOEXS This message buffer is not created
E_TMOUT Polling failure
TASK task1(void)
{
B buf[16] ;
ER size;
:
if(size = prcv_mbf(ID_mbf2, (VP)buf) > 0)
:
}
trcv_mbf
Description This system call receives a message, from the message buffer specified by mbfid. The
received message is copied to msg. This system call returns the size of the received
message. The size of domain pointed by msg, need to be larger than the maximum length
of message (maxmsz), which was specified t the time of message buffer creation.
When message has not arrived in the message buffer, the task that has issued this system
call is connected to the queue of tasks waiting for the message to be received from this
message buffer.
If the message is not received within the time specified by tmout, then this system call will
return back with timeout error, E_TMOUT.
When this system call is issued with tmout=TMO_POL (=0), the call executes similar to
prcv_mbf, i.e. it does not perform waiting. For tmout=TMO_FEVR (=-1), this system call
runs same as rcv_mbf, i.e. there is no timeout.
Return When positive, this return value indicates received message byte count.
E_ID Message buffer ID is outside valid range*
E_NOEXS This message buffer is not created
E_CTX Issued from the non-task context, or waiting in dispatch prohibited state*
E_RLWAI Waiting state was released forcibly (rel_wai was issued while waiting)
E_DLT Message buffer was deleted while waiting for it
E_TMOUT Timeout error
TASK task1(void)
{
B buf[16] ;
ER_UINT size;
:
size = trcv_mbf(ID_mbf2, (VP)buf, 1000/MSEC)
if (ercd == E_TMOUT)
:
}
ref_mbf
Description This system call returns the state of the message buffer specified by mbfid, to *pk_rmbf.
ID number of the heading task in the message buffer queue will be returned in stskid and
rtskid. When there is no waiting task, TSK_NONE is returned.
TASK task1(void)
{
T_RMBF rmbf;
:
ref_mbf(ID_mbf1, &rmbf);
if (rmbf.fmbufsz >= 32 + sizeof(int))
:
}
cre_por
Description The cre_por system call creates a rendezvous port specified by porid. Port management
block is dynamically allocated from system memory. When a message buffer creation
information packet is placed in memory domain other than ROM (i.e. when a const data
type is not attached), the creation information packet data is copied to the system memory.
Please set any of following values for rendezvous port attribute, i.e. poratr.
Rendezvous acceptance queuing is always in the FIFO order. Since the message is
copied when both calling side and the accepting side meet, in case of rendezvous, there is
no ring buffer to perform queuing of messages etc.
Since name is for debugger correspondence, please set “” or NULL when none is selected.
You may omit name when creation information structure object is defined with initial value.
TASK task1(void)
{
ER ercd;
:
ercd = cre_por(ID_por1, &cpor1);
:
}
acre_por
Description This system call allocates the highest ID value searched from non-generated rendezvous
port ID values. System call will return with E_NOID error when the ID allocation fails.
Except above the other part is same as cre_por system call.
Example ID ID_por1;
const T_CPOR cpor1 = {TA_TFIFO, 64, 32 };
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_por(&cpor1);
if(ercd > 0)
ID_por1 = ercd;
:
}
del_por
Description The del_por system call deletes a rendezvous port specified by porid. The rendezvous port
management block is released to the system memory.
When a task is waiting this rendezvous port for rendezvous call or rendezvous acceptance,
the system call releases this task from waiting. The task, whose wait was released,
returns an E_DLT error indicating that the rendezvous port was deletion while the task was
waiting for it.
When the rendezvous port is deleted, it does not affect the already created rendezvous
ports.
TASK task1(void)
{
:
del_por(ID_por1);
:
}
cal_por
Description After waiting for the accepting task, the cal_por system call will send the calling message
to the accepting task, using the rendezvous port specified by porid. Furthermore, this
system call will wait until the reply message is received from the accepting side task.
It is possible to select combination of calling-side and accepting side, using calptn bit
pattern. Rendezvous is established when the logical AND of, calptn of cal_por (this system
call issued from rendezvous calling task), and acpptn of the acp_por (system call issued by
accepting task), is a non-zero value.
When there is a task waiting for accepting rendezvous at this rendezvous port, this system
call will check if the rendezvous can be established with this accepting-waiting task. When
there are several tasks waiting for accepting rendezvous, this system call will check for the
possibility of rendezvous formation, one by one starting from the heading task in the
accept-waiting queue. When there is no waiting task for the rendezvous acceptance, or
when it is not possible to establish rendezvous with any of the task from accept-waiting
queue, then the calling side task which has issued this system call, is connected to the
rendezvous call waiting queue.
When the rendezvous is established, a calling message is copied to the buffer of accepting
task, and the accepting task is released from the waiting. The calling side task which
publishes this system call will enter the WAITING state, waiting for the rendezvous end.
Since the task is separated from the port, there is no queue formation while waiting for
rendezvous end.
The rendezvous is terminated when the reply message is received from the accepting task
(by using rpl_rdv system call). The reply message is copied to msg buffer.
When successful, this system call returns the size of the reply message as return value.
The memory area pointed by msg should be larger than the maxrmsz i.e. maximum length
of reply message specified at the time of rendezvous port creation.
Return When 0 or positive, the return value indicates the reply message size.
E_PAR Bit pattern of the rendezvous condition at the calling side, calptn is 0*
Message size is outside valid range(cmsgsz = 0, cmsgsz > maxcmsz)*
E_ID Rendezvous port ID is outside valid range*
E_NOEXS Rendezvous port is not created
E_CTX Issued from the non-task context, or waiting in dispatch prohibited state*
E_RLWAI Waiting state was released forcibly (rel_wai was issued while waiting)
E_DLT The rendezvous port was deleted while waiting for it
TASK task1(void)
{
B msg[16] ;
ER_UINT size;
:
strcpy(msg, "Hello");
size = cal_por(ID_por1, 0x0001, (VP)msg, strlen(msg));
if(size >= 0)
:
}
tcal_por
Declaration ER_UINT = tcal_por(ID porid, RDVPTN calptn, VP msg, UINT cmsgsz, TMO tmout);
porid Rendezvous port ID
calptn Bit pattern of the rendezvous condition at the calling side
msg Pointer to the location which stores the reply message
cmsgsz Size of the calling message (Byte count)
tmout Timeout value
If the rendezvous has not been terminated within the time specified by tmout, this system
call will return back with E_TMOUT error code.
When this system call is issued with tmout=TMO_POL (=0), i.e. with polling specification,
the call returns with E_PAR eror code. For tmout=TMO_FEVR (=-1), this system call runs
same as cal_por, i.e. there is no timeout.
Return When 0 or positive, the return value indicates the reply message size.
E_PAR Bit pattern of the rendezvous condition at the calling side, calptn is 0*
Message size is outside valid range(cmsgsz = 0, cmsgsz > maxcmsz)*
Polling mode specified*
E_ID Rendezvous port ID is outside valid range*
E_NOEXS Rendezvous port is not created
E_CTX Issued from the non-task context, or waiting in dispatch prohibited state*
E_RLWAI Waiting state was released forcibly (rel_wai was issued while waiting)
E_DLT The rendezvous port was deleted while waiting for it
E_TMOUT Timeout error
acp_por
Description When the waiting for the calling-task is over, the acp_por system call will accept the calling
message from the calling task, using the rendezvous port specified by porid.
It is possible to select combination of calling-side and accepting side, using acpptn bit
pattern. Rendezvous is established when the logical AND of, calptn of cal_por (this system
call issued from rendezvous calling task), and acpptn of the acp_por (system call issued by
accepting task), is a non-zero value.
When there is a task waiting for rendezvous call at this rendezvous port, this system call
will check if the rendezvous can be established with the call-waiting task. When there are
several tasks waiting for rendezvous call, this system call will check for the possibility of
rendezvous formation, one by one starting from the heading task in the call-waiting queue.
When there is no waiting task for the rendezvous call, or when it is not possible to establish
rendezvous with any of the task from call-waiting queue, then the accepting side task
which has issued this system call, is connected to the rendezvous accept-waiting queue.
When the rendezvous is established, the calling message is received and copied to msg.
The calling side task is changed to rendezvous end-waiting state from the call-waiting
state. After successful operation, this system call returns with calling-message size as the
function return value.
The memory area pointed by msg should be larger than the maximum length of the calling
message that was specified at the time of rendezvous port creation.
The rendezvous number, which can be used for fwd_por or rpl_por system calls later, is
returned in *p_rdvno. Calling-side task while waiting for rendezvous end is detached from
port. Hence instead of port number, the rendezvous number associated to the task (i.e.
*p_rdvno) need to be specified for fwd_por or rpl_por system calls.
Return When positive, the return value indicates the size of the calling message (Byte count)
E_PAR Bit pattern of the rendezvous condition at the accepting side, acpptn is 0*
E_ID Rendezvous port ID is outside valid range*
E_NOEXS Rendezvous port is not created
E_CTX Issued from the non-task context, or waiting in dispatch prohibited state*
E_RLWAI Waiting state was released forcibly (rel_wai was issued while waiting)
E_DLT The rendezvous port was deleted while waiting for it
TASK task1(void)
{
B msg[64] ;
ER_UINT size;
RDVNO rdvno;
:
strcpy(msg, "Welcome");
size = acp_por(ID_por1, 0xffff, &rdvno, (VP)msg);
if(memcmp(msg, "Hello", size) == 0)
{ strcpy(msg, "World");
rpl_rdv(rdvno, msg,strlen(msg));
}else
fwd_por(ID_por2, 0x0001, rdvno, msg, strlen(msg));
:
:
}
pacp_por
When there is no waiting task for rendezvous call and when rendezvous is not established
at the calling task, then instead of waiting in queue, this system call returns back with
E_TMOUT error.
Return When positive, the return value indicates the size of the calling message (Byte count)
E_PAR Bit pattern of the rendezvous condition at the accepting side, acpptn is 0*
E_ID Rendezvous port ID is outside valid range*
E_NOEXS Rendezvous port is not created
E_TMOUT Polling failure
tacp_por
Declaration ER_UINT = tacp_por(ID porid, RDVPTN acpptn, RDVNO *p_rdvno, VP msg, TMO tmout);
porid Rendezvous port ID
acpptn Bit pattern of the rendezvous condition at the accepting side
p_rdvno Pointer to the location where rendezvous number is stored
msg Pointer to the calling message
tmout Timeout value
When rendezvous is not established within the time specified by tmout, then this system
call returns back with E_TMOUT error.
When this system call is issued with tmout=TMO_POL (=0), the call executes similar to
pacp_por, i.e. it does not perform waiting. For tmout=TMO_FEVR (=-1), this system call
runs same as acp_por, i.e. there is no timeout.
Return When positive, the return value indicates the size of the calling message (Byte count)
E_PAR Bit pattern of the rendezvous condition at the accepting side, acpptn is 0*
E_ID Rendezvous port ID is outside valid range*
E_NOEXS Rendezvous port is not created
E_CTX Issued from the non-task context, or waiting in dispatch prohibited state*
E_RLWAI Waiting state was released forcibly (rel_wai was issued while waiting)
E_DLT The rendezvous port was deleted while waiting for it
E_TMOUT Timeout error
fwd_por
Declaration ER fwd_por(ID porid, RDVPTN calptn, RDVNO rdvno, VP msg, UINT cmsgsz);
porid ID of the Rendezvous port to which the rendezvous port is forwarded
calptn Bit pattern of the rendezvous condition at the calling side
rdvno Rendezvous number to be forwarded
msg Pointer to the calling message
cmsgsz Size of the calling message (Byte count)
Description The fwd_por system call forwards the rendezvous specified by rdvno, to other port
specified by porid (it is possible to specify self port ID), and allows other tasks to re-execute
the rendezvous acceptance.
The calling size task which was in the rendezvous end-waiting state can be made to
process the rendezvous call again from the port different than the port used last time for
calling. Moreover, the bit pattern used for the rendezvous formation is replaced with the
calptn bit pattern of this system call.
Using the port after forwarding, if there is a task waiting for the rendezvous acceptance,
this system call will check if the rendezvous can be established with the accepting-waiting
task. When there are several tasks waiting for rendezvous call, this system call will check
for the possibility of rendezvous formation, one by one starting from the heading task in the
accepting-waiting queue. When there is no waiting task for the rendezvous acceptance, or
when it is not possible to establish rendezvous with any of the task from accepting-waiting
queue, then the calling side task which is object for this system call, is connected to the
rendezvous calling-waiting queue.
When the rendezvous is established, the calling message is copied to the buffer of the
accepting-task. The accepting task is released from the accept-waiting state. The
calling-side task, which is object for forwarding the port, will again enter the rendezvous
end waiting state.
The task that issued this system call will not enter the WAITING state. This system call can
be published only after rendezvous acceptance. It is possible to further forward the
rendezvous to different port.
rpl_rdv
Description The rpl_rdv system call will send the reply message to the calling task for rendezvous
specified by rdvno. Moreover, this system call will terminate the rendezvous specified by
rdvno.
This system call transfers the rendezvous calling side task from the WAITING state to the
READY state (when the waiting task priority higher than the current running task, the
snd_mbx system call transfers a task to the RUNNING state, and when in the
WAITING-SUSPENDED state, it changes to SUSPENDED state). The task which issued
this system call will not enter the WAITING state.
This system call can be issued only after the acceptance of rendezvous.
ref_por
Description This system call returns the state of the rendezvous port specified by porid, to *pk_rpor.
When there is a task waiting for rendezvous port call or acceptance, then that task ID value
will be returned in ctskid and atskid. TSK_NONE will be returned when there is no waiting
task.
TASK task1(void)
{
T_RPOR rpor;
:
ref_por(ID_por1, &rpor);
if(rpor.atskid != TSK_NONE)
:
}
ref_rdv
Description This system call returns the state of the rendezvous specified by rdvno, to *pk_rrdv.
When there is a task waiting for rendezvous, then that task ID value will be returned in
wtskid. TSK_NONE will be returned when there is no waiting task.
def_inh
Description This system call will set the interrupt handler specified by inthdr, in the interrupt vector
table specified by inhno. For the processors in which the interrupt vector table is not
implemented, the inthdr is set to the interrupt handler table defined as the variable array.
The content of inhno may change with the type of processor (Interrupt vactor numbers are
same).
The structure of the interrupt handler information packet Is as shown below. Depending on
the type of processor, interrupt mask imask is added at the time of start of interrupt
handler.
Although value of inhatr is not referred in NORTi, in order to keep the compatibility with
other μITRON OS, please specify inhatr as TA_HLNG that shows that task is described in
high-level language.
Since it is dependent on the processor, the interrupt handler definition sample is separated
from kernel and is described in n4ixxx.c file. User need to customize def_inh so as to
match correctly with user’s system. As per μITRON specification, interrupt handler is
undefined when pk_dinh is specified as NULL. However, since such functionality is useless
in Embedded system, user may not define such functionality for def_inh.
This system call does not function when an interrupt vector table is defined in ROM
domain. Please define the interrupt handler address directly to the interrupt vector table.
ent_int
Description This system call saves the registers at the time of interrupt generation, and also changes
the stack pointer to the domain reserved for interrupt handler operations. This system call
must be called at the start of interrupt handler function.
Since the stack pointer is moved, auto variables cannot be defined at the entry of interrupt
handler. User may use static variables, or may call different function from interrupt handler
and use auto variables in that function.
Moreover, in some cases just before calling ent_int, there may be an assembly code
developed that destroys the register contents before they are saved inside ent_int. In such
cases, please control this code deployment by compiler optimization effect etc or by calling
a separate function from interrupt handler and by processing the actual handler operation
in the that function.
In the interrupt routine which does not include multitasking operation (having priority above
the priority of other interrupt handler that is involved in multitasking operation), it is okay
even when ent_int and ret_int (described next) system calls are not used. In that case,
please use either the compiler extended functions for the interrupt function, or please
perform the saving / restoring of registers by uniquely described assembly code.
Return None
INTHDR inthdr(void)
{
ent_int();
func();
ret_int();
}
ret_int
Description This system call terminates interrupt handlers. Be sure to call at the end of interrupt
handlers.
The system calls issued inside interrupt handlers to switch tasks is delayed till this ret_int is
issued (delayed dispatch).
chg_ims
Description This system call changes the interrupt mask of processors to the value specified by imask.
In case of the processors that possess only two conditions, interrupt prohibition and
interrupt permission, the former is specified by imask!=0 and the latter is specified by
imask=0.
In processors that possess level interrupt functions, the system call specifies the interrupt
mask level in imask (interrupts permitted with 0 and interrupts prohibited with 1 and more).
The chg_ims system call does not check the range of imask value.
In some system calls issued with interrupts prohibited, if switching tasks is necessary, it is
done when the interrupt is permitted after chg_ims(0) is issued (this is a delayed dispatch).
get_ims
Description The get_ims system call references the interrupt mask of the processors and returns it to
*p_imask.
In processors that possess only two conditions, interrupt prohibition and interrupt
permission, the former is indicated by *p_imask=1 and the latter is indicated by
*p_imask=0.
In processors that possess level interrupt functions, the interrupt mask level is indicated by
the value in *p_imask.
vdis_psw
Description The vdis_psw system call sets up the interrupt mask of processor’s status register in
interrupt prohibited conditions. In processors that possess level interrupt functions, this
system call sets it up to the highest interrupt level and prohibits all interrupts.
This system call returns the status register values for processors before this operation as
return values.
Note This is a NORTi unique system call. It is convenient to execute temporary interrupt
prohibitions combining with vset_psw. This system call can be issued also from an
interrupt routine with higher priority than the kernel.
void func(void)
{
UINT imask;
vset_psw
Description The vset_psw system call sets up the status registers in processors according to values
specified by psw. When the return value of the vdis_psw system call is set up to psw,
interrupt masks are completely restored.
This system call is different from chg_ims(0) as this system call does not execute even if
there is a delayed dispatch. Therefore no system calls that carry out task switching
should be issued between vdis_psw and vset_psw.
Return None
Note This is a system call unique to NORTi. This system call can operate not only interrupt
mask bits but also all bits of status registers. It can also be issued from an interrupt
routine with priority higher than kernel.
psw = vdis_psw();
:
vset_psw(psw | 0x8000);
:
}
cre_isr
Description The cre_isr system call sets the interrupt service routine specified by isr, to the interrupt
number specified by intno. For the processors in which the interrupt vector table is not
implemented, the isr is set to the interrupt handler table defined as the variable array. The
content of intno may change with the type of processor. Interrupt vector number and
interrupt factor number are common.
Although value of istatr is not referred in NORTi, in order to keep the compatibility with
other μITRON OS, please specify inhatr as TA_HLNG that shows that task is described in
high-level language.
Since it is dependent on the processor, the interrupt handler definition sample is separated
from kernel and is described in n4ixxx.c file. User need to customize def_inh so as to
match correctly with user’s system.
In case of interrupt service routine, it is not necessary for OS to call ent_int / ret_int in order
to perform enterance / exit processing from the interrupt handler. Since there is no
restriction in interrupt handler such as prohibition of auto variables etc, it can be described
as a general C function. However, it is not possible to use the interrupt service routine to
handle interrupt of priority higher than Kernel level.
In the attached samples, the interrupt handler number specified by def_inh is same as the
interrupt handler number specified ny cre_isr. Multiple interrupt service routines can be
attached to the same interrupt number.
acre_isr
Description This system call allocates the highest ID value searched from non-generated Interrupt
Service routine ID values. System call will return with E_NOID error when the ID allocation
fails. Except above the other part is same as cre_isr system call.
Example ID ID_isr1;
extern void sioist(VP_INT);
const T_CISR cisr1 = {TA_HLNG, NULL, INT_SIO1, sioisr, 0X07};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_isr(&cisr1);
if(ercd > 0)
ID_isr1 = ercd;
}
del_isr
ref_isr
Description This system call returns the state of the interrupt service routine specified by isrid, to
*pk_risr.
The structure of the interrupt service routine state packet is as shown below.
cre_mpl
Description The cre_mpl system call creates the variable-length memory pool specified by mplid. A
variable-length memory pool management block is dynamically allocated from the system
memory. When pk_cmpl ->mpl is NULL, only the size specified by pk_cmpl->mplsz bytes
is dynamically allocated from the memory reserved for the memory pool.
Following is the structure of the variable length memory pool creation information packet.
Please put the following value into mplatr, the variable length memory pool attribute.
When the memory pool domain is allocated by the user program, please set the block start
address and byte size in pk_cmpl-> mpl and pk_cmpl->mplsz respectively. Since there is
an overhead by OS, all of the memory size cannot be allocated to user program.
The macro function TSZ_MPL(bcnt, blksz) returns the total size required for allocation of
bcnt number of data blocks each of size blksz.
Since name is for debugger correspondence, please set “” or NULL when none is selected.
You may omit name when creation information structure object is defined with initial value.
Note1 Every single memory block acquisition, “sizeof(int *)” bytes only is used for OS
management purpose, i.e. 4 bytes for CPU which has data domain address space of 32bit
and 2 bytes for CPU which has data domain address space of 16bit. Therefore, please
consider above mentioned part for OS management for calculation of mplsz. In addition, in
order to maintain alignment with “sizeof(int *)” bytes, the domain could be excessive to the
size.
Note2 When memory pool acquision and release is called repeatedly, the memory pool memory
gets fragmenized i.e. the size of continuous free memory gets reduced. (There is no
function to defragment the memory pool.)
TASK task1(void)
{
ER ercd;
:
ercd = cre_mpl(ID_mpl1, &cmpl1);
:
}
acre_mpl
Description This system call allocates the highest ID value searched from non-generated
variable-length memory pool ID values. System call will return with E_NOID error when the
ID allocation fails. Except above the other part is same as cre_mpl system call.
Return A positive value indicates the allocated ID for variable length memory pool.
E_NOID Insufficient ID for variable length memory pool
E_CTX The command issued from an interrupt handler*
E_SYS Insufficient system memory for management block**
E_NOMEM Insufficient memory for memory pool**
Example ID ID_mpl1;
const T_CMPL cmpl1 = {TA_TFIFO, 1024, NULL };
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_mpl(&cmpl1);
if(ercd > 0)
ID_mpl1 = ercd;
:
}
del_mpl
Description The del_mpl system call deletes a variable-length memory pool specified by mplid. The
variable-length memory pool management block is released to the system memory. In
case if the OS did the allocation of memory pool domain, the memory pool domain is
released back to the memory-pool memory.
When a task is waiting this variable length memory pool for memory allocation, the system
call releases this task from waiting. The task, whose wait was released, returns an
E_DLT error indicating that the variable length memory pool was deletion while the task
was waiting for it.
TASK task1(void)
{
:
del_mpl(ID_mpl1);
:
}
get_mpl
Description The get_mpl system call acquires memory block of size blksz from the variable-length
memory pool specified by mplid and returns the pointer of that memory block to *p_blk.
Zero clearing of acquired memory block is not performed. The block data is undefined.
When the emprty block size in variable size memory pool is insufficient, then the task
which had issued this system call will be connected to the queue waiting for the variable
size memory pool.
The minimum value for the memory block size blksz is 1 byte. However for processor
which requires word (4 bytes) alignment, blfsz should be integer multiple of size of int (in
case of non-integer or fractional multiple ratio, it is realigned inside OS).
In order to acquire a memory block of size blksz, the variable length memory pool should
have continuous empty free space of “blksz + sizeof(int)” bytes.
The system does not processing priority for smaller size of the requested memory block.
TASK task1(void)
{
B *blk;
:
get_mpl(ID_mpl1, 256, (VP *)&blk);
blk[0] = 0;
blk[1] = 1;
:
}
pget_mpl
When there is insufficient memory block in variable size memory pool, then instead of
waiting in queue, this system call returns back with E_TMOUT error.
TASK task1(void)
{
B *blk;
ER ercd;
:
ercd = pget_mpl(ID_mpl1, 256, (VP *)&blk);
if (ercd == E_OK)
:
}
tget_mpl
When a memory block of required size is not acquired even after the time specified by
tmout has passed, a time-out error E_TMOUT is returned back.
When this system call is issued with tmout=TMO_POL (=0), the call executes similar to
pget_mpl, i.e. it does not perform waiting. For tmout=TMO_FEVR (=-1), this system call
runs same as get_mpl, i.e. there is no timeout.
TASK task1(void)
{
B *blk;
ER ercd;
:
ercd = tget_mpl(ID_mpl1, 256, (VP *)&blk, 100/MSEC);
if (ercd == E_OK)
:
}
rel_mpl
Description Memory block pointed by blk is returned to the variable-length memory pool specified by
mplid.
If there is a task, which is waiting for memory-block acquisition from this variable-length
memory pool, when the empty size of the memory pool as a result of the memory block
release, is higher than the size requested by heading task in waiting queue, then the
memory block is allocated to that task and is released from wait.
In some cases it is possible that by single call to this function, two or more tasks from
queue waiting for memory block acquisition are released. In such case, the memory blocks
are allocated sequentially starting from the top of the queue. The task issuing this system
call will not change to waiting state.
Always make sure that the memory pool is released back to the same source from where it
was acquired. Memory leak phenomenon may occur when the memory pool is not
released before termination of used objects such as task etc.
TASK task1(void)
{
B *blk;
:
get_mpl(ID_mpl1, 256, (VP *)&blk);
:
rel_mpl(ID_mpl1, (VP)blk);
:
}
ref_mpl
TASK task1(void)
{
T_RMPL rmpl;
:
ref_mpl(ID_mpl1, &rmpl);
if (rmpl.fmplsz >= 256 + sizeof(int))
:
}
cre_mpf
Description The cre_mpf system call creates the fixed-length memory pool specified by mpfid. A
fixed-length memory pool management block is dynamically allocated from the system
memory. When pk_cmpf ->mpf is NULL, only the size specified by blkcnt x blfsz bytes is
dynamically allocated from the memory reserved for the memory pool. When the memory
pool domain is allocated by the user program, please set the block start address in
pk_cmpf-> mpf.
Following is the structure of the fixed length memory pool creation information packet.
Following are the valid set values for mpfatr, i.e. fixed-length memory pool attribute.
TA_TFIFO Processing of the acquision waiting task is in the order of arrival (FIFO)
TA_TPRI Processing of the acquision waiting task is in the order of task priority
The minimum value of the memory block size, i.e. blksz, is more than the pointer size of
the processing system. Moreover, for processors that need word alignment, blfsz should
be integer multiple of size of int (in case of non-integer or fractional multiple ratio, it is
realigned inside OS).
The size of the memory pool, consumed by acquision of memory block of size blksz, is
equal to blksz. Hence there is no memory waste.
Since name is for debugger correspondence, please set “” or NULL when none is selected.
You may omit name when creation information structure object is defined with initial value.
TASK task1(void)
{
ER ercd;
:
ercd = cre_mpf(ID_mpf1, &cmpf1);
:
}
acre_mpf
Description This system call allocates the highest ID value searched from non-generated fixed-length
memory pool ID values. System call will return with E_NOID error when the ID allocation
fails. Except above the other part is same as cre_mpf system call.
Return A positive value indicates the allocated ID for fixed length memory pool.
E_NOID Insufficient ID for fixed length memory pool
E_CTX Command issued from an Interrupt handler *
E_SYS Insufficient system memory for management block**
E_NOMEM Insufficient memory for memory pool**
Example ID ID_mpf1;
const T_CMPF cmpf1 ={TA_TFIFO, 10, 256, NULL};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_mpf(&cmpf1);
if(ercd > 0)
ID_mpf1 = ercd;
:
}
del_mpf
Description The del_mpl system call deletes a fixed-length memory pool specified by mpfid. The
fixed-length memory pool management block is released to the system memory. In case if
the OS did the allocation of memory pool domain, the memory pool domain is released
back to the memory-pool memory.
When a task is waiting this fixed length memory pool for memory allocation, the system call
releases this task from waiting. The task, whose wait was released, returns an E_DLT
error indicating that the fixed-length memory pool was deletion while the task was waiting
for it.
TASK task1(void)
{
:
del_mpf(ID_mpf1);
:
}
get_mpf
Description The get_mpf system call acquires single memory block from the fixed-length memory pool
specified by mpfid and returns the pointer of that memory block to *p_blf. The size of the
memory block is fixed to blfsz, which was set at the time of fixed-length memory pool
creation. Zero clearing of acquired memory block is not performed. The block data is
undefined.
When there is no vacant block in fixed size memory pool, then the task which had issued
this system call will be connected to the queue waiting for the fixed size memory pool.
TASK task1(void)
{
B *blf;
:
get_mpf(ID_mpf1, (VP *)&blf);
blf[0] = 0;
blf[1] = 1;
:
}
pget_mpf
When there is no vacant block in fixed size memory pool, then instead of waiting in queue,
this system call returns back with E_TMOUT error.
TASK task1(void)
{
B *blf;
ER ercd;
:
ercd = pget_mpf(ID_mpf1, (VP *)&blf);
if(ercd == E_OK)
:
}
tget_mpf
When a memory block cannot be gained even after the time specified by tmout has
passed, a time-out error E_TMOUT is returned back.
When this system call is issued with tmout=TMO_POL (=0), the call executes similar to
pget_mpf, i.e. it does not perform waiting. For tmout=TMO_FEVR (=-1), this system call
runs same as get_mpf, i.e. there is no timeout.
TASK task1(void)
{
B *blf;
ER ercd;
:
ercd = tget_mpf(ID_mpf1, (VP *)&blf, 100/MSEC);
if(ercd == E_OK)
:
}
rel_mpf
Description Memory block pointed by blf is returned to the fixed-length memory pool specified by mpfid.
If there is a task, which is waiting for memory-block acquisition from this fixed-length
memory pool, a memory block will be allocated to the waiting task (top in waiting queue),
and waiting will be canceled.
Unlike variable-length memory block, the memory-block acquisition waiting of two or more
tasks by single return is not canceled.
The task, which published this system call, will not change to a waiting state. Please be
sure to return memory block to the original memory pool.
TASK task1(void)
{
B *blf;
:
get_mpf(ID_mpf1, (VP *)&blf);
:
rel_mpf(ID_mpf, (VP)blf);
:
}
ref_mpf
When a waiting task exists, ID of the first waiting task is returned. When there is no waiting
task, TSK_NONE is returned.
TASK task1(void)
{
T_RMPF rmpf;
:
ref_mpf(ID_mpf1, &rmpf);
if(rmpf.fblkcnt > 0)
:
}
set_tim
Description The set_tim system call changes the system clock executing time management to the
value specified by *p_systim.
typedef struct
{ H utime; Higher 16 bits
UW ltime; Lower 32 bits
}SYSTIM;
The system time set by set_tim is the count which increments every periodic interrupt.
Therefore the system clock is the data which is counting the number of periodic interrupts.
It is necessary to perform time conversion to a unit such as msec in user program.
As opposed to expressing the system clock as the absolute time which is cleared to 0 at
the time of system starting and then counting up, the system time is a relative time
initialized by set_tim. Since the time event handler takes the system clock as the standard
clock, it is not affected by set_tim.
get_tim
The structure of time packet is same as that of the set_tim system call.
typedef struct
{ H utime; Higher 16 bits
UW ltime; Lower 32 bits
}SYSTIM;
System time is the data is the count of cyclic interrupt. By the user side, it is necessary
to perform conversion with the unit of time, such as msec.
cre_cyc
Description The cre_cyc system call creates the periodic cyclic handler specified by cycid. A peridoc
cyclic handler management block is dynamically allocated from the system memory.
Following are the valid inputs for cycatr. Please specify only TA_HLNG attribute, when
TA_STA and TA_PHS are unnecessary.
TA_HLNG In order to maintain the compatibility with other μITRON based OS,
please set TA_HLNG, which shows that the handler is described with the
high-level language.
TA_STA Handler is in operational state when it is created
TA_PHS Activation phase of the handler is preserved
When the activation phase is not preserved, a cycle is initialized when the handler
operation is started. Therefore, the first cycle of handler always starts from the start of
handler operation. When the activation phase is preserved, after the creation of handler
the clocking is continued regardless of operational state of cyclic handler.
The value specified to exinf is passed as the first parameter at the time of handler
starting.
cychdr is the pointer to the function which is used as the periodic handler. Please
describe the periodic handler as the void type function.
cyctim is the interval time of the activation cycle. The system clock interrupt cycle is the
time unit for handler operation.
Please set cycphs as the time from start of handler operation and until it is activated for
first time. From the second cycle onwards, cyctim is the interval time.
Activation
Phase Activation Cycle Activation Cycle
Activation Cycle
TASK task1(void)
{
ER ercd;
:
ercd = cre_cyc(ID_cyc1, &ccyc1);
:
}
acre_cyc
Description The highest value from the non-generated cyclic handler ID is searched and assigned. An
E_NOID error is returned when the cyclic handler ID is not assigned. Other than this rest is
the same as cre_cyc.
Example ID ID_cyc1;
extern void cyc1(VP_INT);
const T_CCYC ccyc1 = {TA_HLNG|TA_STA, NULL, cyc1, 10, 5};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_cyc(&ccyc1);
if(ercd > 0)
ID_cyc1 = ercd;
:
}
del_cyc
Description The cyclic handler specified by cycid is deleted. A cyclic handler management block is
released to system memory.
Example ID ID_cyc1;
TASK task1(void)
{
ER ercd;
:
ercd = del_cyc(ID_cyc1);
:
}
sta_cyc
Description The sta_cyc system call brings the cyclic handler specified by cycid to the operation state.
When there is no TA_PHS specification, handler starts after starting cycle passes from a
sta_cyc call. When TA_PHS is specified, nothing is done if it is already in operating state.
When TA_PHS is specified and it is in stopped state, it is brought to the activation state
without changing the clock. When TA_PHS is specified, renewal of startup time is
performed irrespective of the ability to start.
stp_cyc
Description The stp_cyc system call brings the cyclic handler specified by cycid to the non-operational
state. If a handler that is already stopped is specified, then nothing is done.
When TA_PHS is specified during creation the renewal of the activation clock is continued.
ref_cyc
Description The state of the periodic handler specified by cycid is returned to *pk_rcyc.
TASK task1(void)
{
T_RCYC rcyc;
:
ref_cyc(ID_cyc, &rcyc);
if(rcyc.cycstat == TCYC_STA)
:
}
cre_alm
Description The alarm handler specified by almid is generated. An alarm handler management block is
dynamically assigned from system memory.
The structure of an alarm handler generation information packet is as follows.
typedef struct t_calm
{ ATR almatr; Alarm handler attribute
VP_INT exinf; Extended information
FP almhdr; The pointer to the function used as an alarm handler
}T_CALM;
almhdr is a pointer to the function used as an alarm handler. Please describe an alarm
handler as a void type function.
Although NORTi does not refer the value of almatr, in order to maintain the compatibility
with other μITRON based OS, Please set almatr to TA_HLNG, which shows that the
handler is described with the high-level language. The value of exinf is passed as the
second argument of an alarm handler.
TASK task1(void)
{
ER ercd;
:
ercd = cre_alm(ID_alm1, &calm1);
:
}
acre_alm
Description The highest value of non-generated alarm handler ID is searched and assigned. An
E_NOID error is returned when the alarm handler ID is not assigned. Other than this rest is
same as cre_alm.
Example ID ID_alm1;
extern void alm1(VP_INT);
const T_CALM calm1 = {TA_HLNG, NULL, alm1};
TASK task1(void)
{
ER_ID ercd;
:
ercd = acre_alm(&calm1);
if(ercd > 0)
ID_alm1 = ercd;
:
}
del_alm
Description The alarm handler specified by almid is deleted. An alarm handler management block is
released to system memory.
Example ID ID_alm1;
TASK task1(void)
{
ER ercd;
:
ercd = del_alm(ID_alm1);
:
}
sta_alm
Description The starting time of an alarm handler specified by almid is set as almtim, and operation is
started. Starting time is changed into a new value when the handler under operation is
specified.
The activation time is the time relative to time when sta_tim was called, taking the timer
interrupt interval as a time unit.
stp_alm
Description The starting time of an alarm handler specified by almid is canceled and changed into the
state where it is not operating. Nothing is done when the handler that has already stopped
is specified.
ref_alm
Description The state of the alarm handler specified by almid is returned to *pk_ralm.
TASK task1(void)
{
T_RALM ralm;
:
ref_alm(ID_alm1, &ralm);
if(ralm.lefttim > 100/MSEC)
:
}
isig_tim
Return none
def_ovr
Although NORTi does not refer the value of avcatr, in order to maintain the compatibility
with the μITRON of other companies, Please set avcatr to TA_HLNG, which shows that the
handler is described with the high-level language. The value of exinf is passed as the
second argument of an overrun handler.
ovrhdr is a pointer to the function used as an overrun handler. Please describe an overrun
handler as a void type function as follows.
Please specify the periodic interruption number, which an overrun handler uses as intno.
Generally, the periodic interruption number same as a system clock is used. Please
specify the function for clearing an interrupt as ovrclr. When the interrupt number of a
system clock is used, please specify NULL as ovrclr.
In order to use a different interrupt number from a system clock, it is necessary to create
the unique initialization routine and ovrclr function. The function registered into ovrclr is
called whenever interruption enters.
If NULL is specified as pk_dovr, an overrun handler definition will be canceled. An overrun
handler will be redefined if values other than NULL are again specified as pk_dovr in the
state of already giving the definition. When you use peculier interrupts, please cancel the
definition / redefine after forbidding interrupt.
TASK task1(void)
{
ER ercd;
:
ercd = def_ovr(&dovr);
:
}
sta_ovr
Description Processor time is set up by the task specified by tskid. It will be aimed at a self-task if
TSK_SELF is specified as tskid. Time unit is the interrupt cycle specified by def_ovr. An
overrun handler will be started if the time specified by ovrtim is used up.
Measuring of processor time is done by decrementing the processor time of the task, which
was performed at the time of interrupt, by 1. Hence, continued execution time, except in
the case of a very long task of a interrupt cycle, becomes the large error.
Processor time will be updated if sta_ovr is again performed by the task to which processor
time is already set.
stp_ovr
Description Operation of an overrun handler is stopped by the task specified by tskid. A setup of
processor time is canceled. A self-task can be specified by tskid = TSK_SELF.
ref_ovr
Description The state of the overrun handler of the task specified by tskid is returned to *pk_rovr. A
self-task can be specified by tskid = TSK_SELF.
The structure of an overrun handler state packet is as follows.
def_svc
Please set a positive value to fncd. Although NORTi does not refer the value of avcatr, in
order to maintain the compatibility with the μITRON of other companies, Please set avcatr
to TA_HLNG, which shows that the handler is described with the high-level language.
Please describe an extended service call routine as a C function in the following form.
TASK task1(void)
{
:
ercd = def_svc(svc_ter_tsk, &dsvc2);
:
}
cal_svc
Description par1-par6 are called for the service call routine specified by fncd as a parameter. A
parameter should describe only a required number.
TASK task1(void)
{
:
ercd = def_svc(svc_ter_tsk, &dsvc2);
:
ercd = cal_svc(svc_ter_tsk, Task2);
:
}
rot_rdq
irot_rdq
Description In the ready queue of the priority specified by tskpri, the task at the head position is
switched to the tail end. That is, execution of the task of the same priority is switched.
By tskpri = TPRI_SELF, the base priority of a self-task is made into an target priority. By
using this system call at a fixed interval from a cyclic handler, a round Robins scheduling
is realizable.
When the ready queue of the task which published this system call rotates, this task is
transited from a RUNNING state to a ready state, and the task which was waiting for an
execution order next transits it from a ready state to a RUNNING state. That is, rot_rdq
can be published in order to abandon the right of execution itself.
There is no error in case this system call is issued when there is no task in the ready
queue of the specified priority.
get_tid
iget_tid
Description The ID number of the task which issued this system call is returned to *p_tskid. When
called from the non-task context sections, such as an interrupt handler, ID of the task in a
present RUNNING state is returned. TSK_NONE is returned when there is no task with a
RUNNING state.
vget_tid
Declaration ID vget_tid(void);
Description The ID number of the task, which issued this system call, is returned as a function return
value. Others are the same as that of get_tid.
Return Task ID
loc_cpu
iloc_cpu
Declaration ER loc_cpu(void);
ER iloc_cpu(void);
Description A reception of interrupt and task switching are prohibited. This prohibition state can be
canceled by the unl_cpu system call. If this system call is issued when it is already in a
CPU lock state, it does not become an error.
However, since the nest management of loc_cpu~unl_cpu pair is not done, CPU lock
release will be done by single unl_cpu call, even if loc_cpu was issued multiple times.
Please do not publish this system call from an interrupt handler. In case when CPU lock
command is issued from non-task context other than interrupt handler, please release the
CPU lock state before return.
Note In the case of a processor with a level interrupt function, in NORTi, as a standard, the
interrupt inhibit level of the Kernel is not considered as highest. The interrupt mask set up
by loc_cpu, disables even the interrupt-inhibit level of a kernel. The interrupts with priority
higher than Kernel can be receieved.
unl_cpu
iunl_cpu
Declaration ER unl_cpu(void);
ER iunl_cpu(void);
Description The prohibition state set up by loc_cpu is canceled. However, interrupt reception and task
switching are not necessarily enabled. When loc_cpu was issued while dispatch was
prohibited, dispatch remains prohibited when CPU is unlocked. In this case, in order to
make dispatch possible, ena_dsp should be called.
When already in CPU lock released state, repeated use of this system call does not
become an error. Since the nest management of loc_cpu~unl_cpu pair is not done, CPU
lock release will be done by single unl_cpu call, even if loc_cpu was issued multiple times.
Although it is possible to call iunl_cpu from a timer event handler among non-task
contexts, please do not publish this system call from an interrupt handler. All interrupt
masks will be canceled. In case of the processor that supports level interrupt; when
unl_loc is called at the time of return from ent_int in the interrupt handler (interrupt service
routine in case of Interrupt Service Routine), the interrupt mask is cleared.
dis_dsp
Declaration ER dis_dsp(void);
Description The task switching is forbidden. Interrupt is not forbidden. After issuing this system call,
switching of tasks issued by other system calls is suspended. The switching of the
suspended task is performed when an ena_dsp system call is issued.
Notes During the bans on dispatch, if the wait generating system call is issued, it will become an
E_CTX error.
ena_dsp
Declaration ER ena_dsp(void);
Description The dispatch prohibition state set up by the dis_dsp system call is canceled. Even if
dis_dsp is called previously, it is not considered as an error. If there is a switching of the
task suspended in the state of dispatch prohibition, it will perform by this system call.
sns_ctx
Description It is TRUE when called from the non-task context section. FALSE is returned when called
from the task context section.
sns_loc
Description TRUE is returned in case the CPU is in locked state. In other case FALSE is returned.
sns_dsp
Description TRUE is returned if the system is in dispatch prohiition state. When the dispatch is
permitted, FALSE is returned.
sns_dpn
Description TRUE is returned if the CPU is in locked state or dispatch is banned. In other case FALSE
is returned.
ref_sys
TSS_TSK The task context section is under execution and dispatch is permitted.
TSS_DDSP The task context section is under execution and dispatch is forbidden.
TSS_LOC The task context section is under execution and interrupt, dispatch is
forbidden.
TSS_INDP The non-task context section is under execution.
ref_ver
ref_cfg
sysini
Declaration ER sysini(void);
Description The sysini system call initializes the kernel. This system call must be executed before all
other system calls. It is usually called at the top of main functions.
The initialization process executed in this case is the initial setting of internal kernel
variables and the calling of intini functions stated later. After the sysini system call is
executed, the process enters the interrupt-disabled state.
When the standard stack area that the compiler offers is used as a stack memory, that is,
configuration #define STKMSZ 0, the bottom of the stack will be allocated, based on a
stack pointer at the time of call to sysini.
When the configurator is used, it is automatically called from the main function generated
by configurator (kernel_cfg.c).
syssta
Declaration ER syssta(void);
Description The syssta system call transfers the system to the multi-task state, terminating the handler
for initialization. At least more than one task's creation and start have to be executed
before this system call is issued. This system call is usually called at the end of the main
functions.
In activated tasks, the task with the highest priority has control (for tasks with the same
priority, the task activated earlier) i.e. the first dispatch is executed. After this, the
interrupts, which were prohibited by sysini, are permitted.
When the error has occurred in task generation etc. before syssta execution, an error
returns without system start. The syssta call does not return in normal start.
When the configurator is used, it is automatically called from the main function generated
by configurator (kernel_cfg.c).
intsta
Declaration ER intsta(void);
Description Periodic timer interrupt for managing the time waiting of a task is started. Please call this
function just before a syssta system call. It is not necessary to perform intsta when not
using a system call or a timer event handler with a timeout.
As this system call depends on the target, it is defined in n4ixxx.c, different from the
kernel. Standard value for interrupt cycle is 10msec. User needs to create this function if it
is not defined in sample n4ixxx.c file. In such case user may change the function name.
When configurator is used, it is called automatically from main function defined in
configurator (kernel_cfg.c).
When you use periodic timer interrupt from the overrun handler, please call def_ovr after
periodic timer interrupt initialization.
intext
Description The intext system call stops the timer activated by intsta.
As this system call depends on the target, it is defined in n4ixxx.c, different from the
kernel. Please create this function if the attched n4ixxx.c file does not include this function.
When user defines this function, the name of this function can be changed. User need not
define this function if there is no need to stop the timer interrupt. (It is omitted in many of
the samples)
Return none
intini
Declaration ER intini(void);
Description The intini system call is called in the interrupt-disabled state from sysini. It initializes the
hardware, and so on.
As this system call depends on the target, it is defined in the attached n4ixxx.c, which is
supplied as a sample, different from the kernel. When a user creates this function, if there
is nothing specially to initialize, please do nothing but carry out the return with E_OK code.
7. List
7.1 Error code list
1 2 3
Task creation OOX
cre_tsk (tskid, pk_ctsk) ;
1 2 3
Waiting for wakeup OXX
slp_tsk();
Waiting for wakeup (timeout specified) OXX
tslp_tsk(tmout);
Task wakeup command OOO
wup_tsk(tskid);
Task wakeup command XOO
iwup_tsk(tskid);
Cancellation of task wakeup command OOO
can_wup(tskid);
Self-task wakeup command cancellation * OOO
vcan_wup(tskid);
Forced release of waiting task OOO
rel_wai(tskid);
Forced release of waiting task XOO
irel_wai(tskid);
Task suspend command OOO
sus_tsk(tskid);
Resume from suspended state OOO
rsm_tsk(tskid);
Forced resume from suspended state OOO
frsm_tsk(tskid);
Delay self-task OXX
dly_tsk(dlytim);
Notes,
NORTi original system call
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Definition of the task exception handling routine OOX
def_tex(tskid, pk_dtex);
Request task exception handling OOO
ras_tex(tskid, rasptn);
Request task exception handling XOO
iras_tex(tskid, rasptn);
Prohibit task exception handling OOO
dis_tex();
Enable task exception handling OOO
ena_tex();
Refer to task exception handling prohibition state OOO
sns_tex();
Refer to the state of the task exception handling OOO
ref_tex(tskid, pk_rtex);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Semaphore creation OOX
cre_sem(semid, pk_csem);
Semaphore creation (Automatic ID allocation) OOX
acre_sem(pk_csem);
Semaphore deletion OOX
del_sem(semid);
Semaphore resource release OOO
sig_sem(semid);
Semaphore resource release XOO
isig_sem(semid);
Semaphore resource acquisition OXX
wai_sem(semid);
Semaphore resource acquisition (polling) OOO
pol_sem(semid);
Semaphore resource acquisition (timeout available) OXX
twai_sem(semid, tmout);
Semaphore state reference OOO
ref_sem(semid, pk_rsem);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Event flag creation OOX
cre_flg(flgid, pk_cflg);
Event flag creation (automatic ID allocation) OOX
acre_flg(pk_cflg);
Event flag deletion OOX
del_flg(flgid);
Event flag set OOO
set_flg(flgid, setptn);
Event flag set XOO
iset_flg(flgid, setptn);
Event flag clear OOO
clr_flg(flgid, clrptn);
Waiting for event flag OXX
wai_flg(flgid, waiptn, wfmode, p_flgptn);
Waiting for event flag (polling mode) OOO
pol_flg(flgid, waiptn, wfmode, p_flgptn);
Waiting for event flag (timeout available) OXX
twai_flg(flgid, waiptn, wfmode,p_flgptn, tmout);
Refer to event flag state OOO
ref_flg(flgid, pk_rflg);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Data queue creation OOX
cre_dtq(dtqid, pk_cdtq);
Data queue creation (automatic ID allocation) OOX
acre_dtq(pk_cdtq);
Data queue deletion OOX
del_dtq(dtqid);
Send data queue OXX
snd_dtq(dtqid, data);
Send data queue (polling mode) OOO
psnd_dtq(dtqid, data);
Send data queue (polling mode) XOO
ipsnd_dtq(dtqid, data);
Send data queue (timeout available) OXX
tsnd_dtq(dtqid, data, tmout);
Forced transmission to data queue OOO
fsnd_dtq(dtqid, data);
Forced transmission to data queue XOO
ifsnd_dtq(dtqid, data);
Reception of data queue OXX
rcv_dtq(dtqid, p_data);
Reception of data queue (polling mode) OOO
prcv_dtq(dtqid, p_data);
Reception of data queue (timeout available) OXX
trcv_dtq(dtqid, p_data, tmout);
Refer to the state of data queue OOO
ref_dtq(dtqid, pk_rdtq);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Mailbox creation OOX
cre_mbx(mbxid, pk_cmbx);
Mailbox creation (automatic ID allocation) OOX
acre_mbx(pk_cmbx);
Mailbox deletion OOX
del_mbx(mbxid);
Send message to mailbox OOO
snd_mbx(mbxid, pk_msg);
Receive message from mailbox OXX
rcv_mbx(mbxid, ppk_msg);
Receive message from mailbox (polling mode) OOO
prcv_mbx(mbxid, ppk_msg);
Receive message from mailbox (timeout available) OXX
trcv_mbx(mbxid, ppk_msg, tmout);
Refer to the state of the mailbox OOO
ref_mbx(mbxid, pk_rmbx);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Mutex creation OOX
cre_mtx(mtxid, pk_cmtx);
Mutex creation (automatic ID allocation) OOX
acre_mtx(pk_cmtx);
Mutex deletion OOX
del_mtx(mtxid);
Lock the mutex OXX
loc_mtx(mtxid);
Lock the mutex (polling mode) OOO
ploc_mtx(mtxid);
Lock the mutex (timeout available) OXX
tloc_mtx(mtxid,tmout);
Unlock the mutex OOO
unl_mtx(mtxid);
Refer to the state of the mutex OOO
ref_mtx(mtxid, pk_rmtx);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Message buffer creation OOX
cre_mbf(mbfid, pk_cmbf);
Message buffer creation (automatic ID allocation) OOX
acre_mbf(pk_cmbf);
Message buffer deletion OOX
del_mbf(mbfid);
Send message to message buffer. OXX
Snd_mbf(mbfid, msg, msgsz);
Send message to message buffer (polling mode) OOO
psnd_mbf(mbfid, msg, msgsz);
Send message to message buffer (timeout available) OXX
tsnd_mbf(mbfid, msg, msgsz, tmout);
Receive message from message buffer. OXX
Rcv_mbf(mbfid, msg);
Receive message from message buffer (polling mode) OOO
prcv_mbf(mbfid, msg);
Receive message from message buffer (timeout available) OXX
trcv_mbf(mbfid, msg, tmout);
Refer to the state of the message buffer OOO
ref_mbf(mbfid, pk_rmbf);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Rendezvous port creation OOX
cre_por(porid, pk_cpor);
Rendezvous port creation (automatic ID allocation) OOX
acre_por(pk_cpor);
Rendezvous port deletion OOX
del_por(porid);
Call Rendezvous port OXX
cal_por(porid, calptn, msg, cmsgsz);
Call Rendezvous port (timeout available) OXX
tcal_por(porid, calptn, msg, cmsgsz, tmout);
Waiting for rendezvous port OXX
acp_por(porid, acpptn, p_rdvno, msg);
Waiting for rendezvous port (polling mode) OOO
pacp_por(porid, acpptn, p_rdvno, msg);
Waiting for rendezvous port (timeout available) OXX
tacp_por(porid, acpptn, p_rdvno, msg, tmout);
Transfer of rendezvous OOO
fwd_por(porid, calptn, rdvno, msg, cmsgsz);
End of rendezvous OOO
rpl_rdv(rdvno, msg, rmsgsz);
Refer to the state of rendezvous port. OOO
Ref_por(porid, pk_rpor);
Refer to the state of rendezvous. OOO
Ref_rdv(rdvno, pk_rrdv);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Fixed-length memory pool creation OOX
cre_mpf(mpfid, pk_cmpf);
Fixed-length memory pool creation (automatic ID allocation) OOX
acre_mpf(pk_cmpf);
Fixed-length memory pool deletion OOX
del_mpf(mpfid);
Fixed-length memory block acquisition OXX
get_mpf(mpfid, p_blk);
Fixed-length memory block acquisition (polling) OOO
pget_mpf(mpfid, p_blk);
Fixed-length memory block acquisition (timeout) OXX
tget_mpf(mpfid, p_blk, tmout);
Fixed-length memory block release OOO
rel_mpf(mpfid, blk);
Refer to the state of the fixed size memory pool. OOO
Ref_mpf(mpfid, pk_rmpf);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Variable-length memory pool creation OOX
cre_mpl(mplid, pk_cmpl);
Variable-length memory pool creation (automatic ID allocation) OOX
acre_mpl(pk_cmpl);
Variable-length memory pool delation OOX
del_mpl(mplid);
Acquisition of block from variable-length memory pool. OXX
Get_mpl(mplid, blksz, p_blk);
Acquisition of block from variable-length memory pool (polling mode) OOX
pget_mpl(mplid, blksz, p_blk);
Acquisition of block from variable-length memory pool (timeout available) OXX
tget_mpl(mplid, blksz, p_blk, tmout);
Variable-length memory pool release OOX
rel_mpl(mplid, blk);
Refer to the state of the variable length memory pool OOX
ref_mpl(mplid, pk_rmpl);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
A setup of the system time OOO
set_tim(p_tim);
Get the system time OOO
get_tim(p_tim);
Supply of a time tick X X O
isig_tim();
Supply of a time tick X X O
sig_tim();
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Cyclic handler creation OOX
cre_cyc(cycid, pk_ccyc);
Cyclic handler creation (automatic ID allocation) OOX
acre_cyc(pk_ccyc);
Cyclic handler deletion OOX
del_cyc(cycid);
Start the cyclic handler OOO
sta_cyc(cycid);
Stop the cyclic handler OOO
stp_cyc(cycid);
Refer to the state of the cyclic handler OOO
ref_cyc(cycid, pk_rcyc);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Alarm handler creation OOX
cre_alm(almid, pk_calm);
Alarm handler creation (automatic ID allocation) OOX
acre_alm(pk_calm);
Alarm handler deletion OOX
del_alm(almid);
Start of the alarm handler OOO
sta_alm(almid, almtim);
Stop the alarm handler OOO
stp_alm(almid);
Refer to the state of the alarm handler OOO
ref_alm(almid, pk_ralm);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Overrun handler definition OOX
def_ovr(pk_dovr);
Start of the overrun handler OOO
sta_ovr(tskid, ovrtim);
Stop the overrun handler OOO
stp_ovr(tskid);
Refer to the state of the overrun handler OOO
ref_ovr(tskid, pk_rovr);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
Interrupt management
1 2 3
Definition of the interrupt handler OOO
def_inh(inhno, pk_dinh);
Interrupt service routine creation OOX
cre_isr(isrid, pk_cisr);
Interrupt service routine creation (automatic ID allocation) OOX
acre_isr(pk_cisr);
Interrupt service routine deletion OOX
del_isr(isrid);
Refer to the interrupt service routine state. OOO
Ref_isr(isrid, pk_risr);
Prohibition of the interrupt. OOX
Dis_int(intno);
Enable the interrupt. OOX
Ena_int(intno);
Change of the interrupt mask. OOO
Chg_ims(imask);
Get the interrupt mask state. OOO
Get_ims(p_imask);
Start the interrupt handler * XXO
ient_int();
End the interrupt handler * XXO
iret_int();
Set the status register * OOO
vset_psw();
Set the interrupt mask state of the status register. * OOO
vdis_psw();
Notes,
System call exclusive to NORTi
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Extended service call definition OOX
def_svc(fncd, pk_dsvc);
Calling the service call. O ? ?
Cal_svc(fncd, par1, par2, …); (depend on the service call)
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
1 2 3
Refer to configuration information. OOO
Ref_cfg(pk_rcfg);
Refer to version information. OOO
Ref_ver(pk_rver);
Notes,
1 – Can Issue from task.
2 – Can issue from timer /event handler.
3 – Can issue from interrupt handler.
Timeout
TMO_POL 0 Polling (without waiting)
TMO_FEVR -1 Infinite waiting (without timeout)
Task ID
TSK_SELF 0 Specifies task itself
TSK_NONE 0 No task
Task priority
TPRI_INI 0 Priority during initialization
TPRI_SELF 0 Task own base priority
TMIN_TPRI 1 minimum value of the priority
TMAX_TPRI Maximum priority value (depends on the configuration value)
Task state
TTS_RUN 0x0001 Running state
TTS_RDY 0x0002 Ready state
TTS_WAI 0x0004 WAITING state
TTS_SUS 0x0008 SUSPENDED state
TTS_WAS 0x000c WAITING-SUSPENDED state
TTS_DMT 0x0010 DORMANT state
Message priority
TMIN_MPRI 1 Highest priority of message
Mutex attribute
TA_INHERIT 0x0002 Priority inheritance protocol
TA_CEILING 0x0003 Priority maximum limit protocol
System state
TSS_TSK 0 Task context part
TSS_DDSP 1 Task context part (Dispatch prohibition state)
TSS_LOC 3 Task context part (CPU lock state)
TSS_INDP 4 Non-task context part
Other constants
TRUE 1 Boolean true
FALSE 0 Boolean false
Index
cre_flg ......................................................... 109
A cre_isr ................................................... 55, 194
acp_por........................................................178 cre_mbf ....................................................... 157
acre_alm ................................................59, 226 cre_mbx ...................................................... 136
acre_cyc ................................................59, 221 cre_mpf ....................................................... 208
acre_dtq.......................................................124 cre_mpl ....................................................... 198
acre_flg ........................................................111 cre_mtx ....................................................... 148
acre_isr ..................................................55, 196 cre_por........................................................ 171
acre_mbf......................................................159 cre_sem ...................................................... 100
acre_mbx .....................................................138 cre_tsk .......................................................... 64
acre_mpf......................................................210
acre_mpl ......................................................200
D
acre_mtx ......................................................150 def_inh ........................................................ 187
acre_por.......................................................173 def_ovr .................................................. 59, 231
acre_sem .....................................................102 def_svc........................................................ 235
act_tsk ...........................................................68 def_tex .......................................................... 93
ATR..........................................................11, 13 del_alm ................................................. 59, 227
auto variable prohibition ................................30 del_cyc.................................................. 59, 222
del_dtq ........................................................ 125
B del_flg ......................................................... 112
B…...................................................11, 13, 165 del_isr ......................................................... 197
BOOL.................................................11, 13, 98 del_mbf ....................................................... 160
del_mbx ...................................................... 139
C del_mpf ....................................................... 211
cal_por .........................................................175 del_mpl ....................................................... 201
cal_svc.........................................................237 del_mtx ....................................................... 151
can_act ..........................................................70 del_por ........................................................ 174
can_wup ..................................................38, 89 del_sem ...................................................... 103
chg_ims .................................................55, 190 del_tsk........................................................... 67
chg_pri ...........................................................75 dis_dsp........................................................ 243
clr_flg ...........................................................115 dis_tex........................................................... 96
CPU lock release.........................................242 dly_tsk........................................................... 92
CPU lock......................................................241 DLYTIME ................................................ 11, 13
CPU lock state reference.............................245 DORMANT...................................................... 4
cre_alm ..................................................59, 225
cre_cyc ..................................................59, 219
E
cre_dtq.........................................................122 ena_dsp ...................................................... 244
287
Index NORTi Ver.4 User's Guide
H P
H.. ....................................................11, 13, 166 pacp_por ..................................................... 180
pget_mpf ..................................................... 213
I pget_mpl ..................................................... 204
I/O Initialization ..............................................33 ploc_mtx...................................................... 154
iact_tsk...........................................................68 pol_flg ......................................................... 118
ID .........................................................6, 11, 13 pol_sem ...................................................... 106
ID allocation (Automatic) ...............................23 prcv_dtq ...................................................... 133
ifsnd_dtq ......................................................131 prcv_mbf ..................................................... 167
iget_tid .........................................................239 prcv_mbx .................................................... 144
iloc_cpu........................................................241 PRI .......................................................... 11, 13
INHNO .....................................................11, 13 psnd_dtq ..................................................... 127
INT ...........................................................11, 13 psnd_mbf .................................................... 163
288
Index NORTi Ver.4 User's Guide
289
Index NORTi Ver.4 User's Guide
290
Index NORTi Ver.4 User's Guide
291
NORTi Version 4 User’s Guide
Kernel Edition
http://www.mispo.co.jp/
MISPO Co., Ltd. reserves the right to change the contents of this document without prior notice.