summaryrefslogtreecommitdiff
path: root/docs/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html
blob: 810da535f98d1de6ffb995cf9b3be730774eace3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Thread Management</title>
<title>CMSIS-RTOS2: Thread Management</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="cmsis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="printComponentTabs.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 46px;">
  <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">CMSIS-RTOS2
   &#160;<span id="projectnumber">Version 2.1.3</span>
   </div>
   <div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<div id="CMSISnav" class="tabs1">
    <ul class="tablist">
      <script type="text/javascript">
		<!--
		writeComponentTabs.call(this);
		//-->
      </script>
	  </ul>
</div>
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
      <li><a href="modules.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__CMSIS__RTOS__ThreadMgmt.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#enumval-members">Enumerator</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Thread Management<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Define, create, and control thread functions.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structosThreadAttr__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a></td></tr>
<tr class="memdesc:structosThreadAttr__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attributes structure for thread.  <a href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">More...</a><br/></td></tr>
<tr class="separator:structosThreadAttr__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga249499c519f3f8eef5673009ab6cfcbe"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>&#160;&#160;&#160;0x00000001U</td></tr>
<tr class="memdesc:ga249499c519f3f8eef5673009ab6cfcbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Thread created in joinable mode.  <a href="#ga249499c519f3f8eef5673009ab6cfcbe">More...</a><br/></td></tr>
<tr class="separator:ga249499c519f3f8eef5673009ab6cfcbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9336c1073858d6b118e2e011636246f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>&#160;&#160;&#160;0x00000000U</td></tr>
<tr class="memdesc:gaa9336c1073858d6b118e2e011636246f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Thread created in detached mode (default)  <a href="#gaa9336c1073858d6b118e2e011636246f">More...</a><br/></td></tr>
<tr class="separator:gaa9336c1073858d6b118e2e011636246f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gadd51f99a6eb50b94eee75f27cae815eb"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a> )(void *argument)</td></tr>
<tr class="memdesc:gadd51f99a6eb50b94eee75f27cae815eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Entry point of a thread.  <a href="#gadd51f99a6eb50b94eee75f27cae815eb">More...</a><br/></td></tr>
<tr class="separator:gadd51f99a6eb50b94eee75f27cae815eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa6c32fe2a3e0a2e01f212d55b02e51c7"><td class="memItemLeft" align="right" valign="top">typedef void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></td></tr>
<tr class="separator:gaa6c32fe2a3e0a2e01f212d55b02e51c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gad3dc89e942e38d9f3af858a0269a820d"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> { <br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dae9d77830b6866e287417b6e1d983e971">osThreadInactive</a> = 0, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da59e286915944fe0e4d1ffdb1f2946f14">osThreadReady</a> = 1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dac4fe336e0790188fcf7d667372eca19d">osThreadRunning</a> = 2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968">osThreadBlocked</a> = 3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c">osThreadTerminated</a> = 4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a> = -1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c">osThreadReserved</a> = 0x7FFFFFFF
<br/>
 }</td></tr>
<tr class="memdesc:gad3dc89e942e38d9f3af858a0269a820d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Thread state.  <a href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">More...</a><br/></td></tr>
<tr class="separator:gad3dc89e942e38d9f3af858a0269a820d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad4e3e0971b41f2d17584a8c6837342ec"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> { <br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3">osPriorityNone</a> = 0, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad4e3e0971b41f2d17584a8c6837342ecacd5864eac01a6916a7c866bb51a6aac1">osPriorityIdle</a> = 1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4">osPriorityLow</a> = 8, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe">osPriorityLow1</a> = 8+1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507">osPriorityLow2</a> = 8+2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50">osPriorityLow3</a> = 8+3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81">osPriorityLow4</a> = 8+4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353">osPriorityLow5</a> = 8+5, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393">osPriorityLow6</a> = 8+6, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a">osPriorityLow7</a> = 8+7, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a> = 16, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5">osPriorityBelowNormal1</a> = 16+1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3">osPriorityBelowNormal2</a> = 16+2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf">osPriorityBelowNormal3</a> = 16+3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24">osPriorityBelowNormal4</a> = 16+4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e">osPriorityBelowNormal5</a> = 16+5, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05">osPriorityBelowNormal6</a> = 16+6, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b">osPriorityBelowNormal7</a> = 16+7, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1">osPriorityNormal</a> = 24, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c">osPriorityNormal1</a> = 24+1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205">osPriorityNormal2</a> = 24+2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91">osPriorityNormal3</a> = 24+3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d">osPriorityNormal4</a> = 24+4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab">osPriorityNormal5</a> = 24+5, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204">osPriorityNormal6</a> = 24+6, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b">osPriorityNormal7</a> = 24+7, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b">osPriorityAboveNormal</a> = 32, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998">osPriorityAboveNormal1</a> = 32+1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562">osPriorityAboveNormal2</a> = 32+2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013">osPriorityAboveNormal3</a> = 32+3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec">osPriorityAboveNormal4</a> = 32+4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c">osPriorityAboveNormal5</a> = 32+5, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207">osPriorityAboveNormal6</a> = 32+6, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d">osPriorityAboveNormal7</a> = 32+7, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a> = 40, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb">osPriorityHigh1</a> = 40+1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03">osPriorityHigh2</a> = 40+2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759">osPriorityHigh3</a> = 40+3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb">osPriorityHigh4</a> = 40+4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9">osPriorityHigh5</a> = 40+5, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc">osPriorityHigh6</a> = 40+6, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652">osPriorityHigh7</a> = 40+7, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af">osPriorityRealtime</a> = 48, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b">osPriorityRealtime1</a> = 48+1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff">osPriorityRealtime2</a> = 48+2, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa">osPriorityRealtime3</a> = 48+3, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70">osPriorityRealtime4</a> = 48+4, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df">osPriorityRealtime5</a> = 48+5, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194">osPriorityRealtime6</a> = 48+6, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b">osPriorityRealtime7</a> = 48+7, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad4e3e0971b41f2d17584a8c6837342eca4b4fa46c3ebaf4259662a0a0a3173b7f">osPriorityISR</a> = 56, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4">osPriorityError</a> = -1, 
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b">osPriorityReserved</a> = 0x7FFFFFFF
<br/>
 }</td></tr>
<tr class="memdesc:gad4e3e0971b41f2d17584a8c6837342ec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Priority values.  <a href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">More...</a><br/></td></tr>
<tr class="separator:gad4e3e0971b41f2d17584a8c6837342ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a> func, void *argument, const <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> *attr)</td></tr>
<tr class="memdesc:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a thread and add it to Active Threads.  <a href="#ga48d68b8666d99d28fa646ee1d2182b8f">More...</a><br/></td></tr>
<tr class="separator:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac3230f3a55a297514b013ebf38f27e0a"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gac3230f3a55a297514b013ebf38f27e0a">osThreadGetName</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gac3230f3a55a297514b013ebf38f27e0a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get name of a thread.  <a href="#gac3230f3a55a297514b013ebf38f27e0a">More...</a><br/></td></tr>
<tr class="separator:gac3230f3a55a297514b013ebf38f27e0a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8df03548e89fbc56402a5cd584a505da"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a> (void)</td></tr>
<tr class="memdesc:ga8df03548e89fbc56402a5cd584a505da"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the thread ID of the current running thread.  <a href="#ga8df03548e89fbc56402a5cd584a505da">More...</a><br/></td></tr>
<tr class="separator:ga8df03548e89fbc56402a5cd584a505da"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get current thread state of a thread.  <a href="#gacc0a98b42f0a5928e12dc91dc76866b9">More...</a><br/></td></tr>
<tr class="separator:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga861a420fb2d643115b06622903fb3bfb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id, <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> priority)</td></tr>
<tr class="memdesc:ga861a420fb2d643115b06622903fb3bfb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change priority of a thread.  <a href="#ga861a420fb2d643115b06622903fb3bfb">More...</a><br/></td></tr>
<tr class="separator:ga861a420fb2d643115b06622903fb3bfb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga0aeaf349604f456e68e78f9d3b42e44b">osThreadGetPriority</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get current priority of a thread.  <a href="#ga0aeaf349604f456e68e78f9d3b42e44b">More...</a><br/></td></tr>
<tr class="separator:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad01c7ec26535b1de6b018bb9466720e2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (void)</td></tr>
<tr class="memdesc:gad01c7ec26535b1de6b018bb9466720e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pass control to next thread that is in state <b>READY</b>.  <a href="#gad01c7ec26535b1de6b018bb9466720e2">More...</a><br/></td></tr>
<tr class="separator:gad01c7ec26535b1de6b018bb9466720e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="mdescLeft">&#160;</td><td class="mdescRight">Suspend execution of a thread.  <a href="#gaa9de419d0152bf77e9bbcd1f369fb990">More...</a><br/></td></tr>
<tr class="separator:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3dbad90eff394b02de76a452c84c5d80"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3dbad90eff394b02de76a452c84c5d80">osThreadResume</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga3dbad90eff394b02de76a452c84c5d80"><td class="mdescLeft">&#160;</td><td class="mdescRight">Resume execution of a thread.  <a href="#ga3dbad90eff394b02de76a452c84c5d80">More...</a><br/></td></tr>
<tr class="separator:ga3dbad90eff394b02de76a452c84c5d80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaaad14cd9547341ea8109dc4e8540f1dc">osThreadDetach</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Detach a thread (thread storage can be reclaimed when thread terminates).  <a href="#gaaad14cd9547341ea8109dc4e8540f1dc">More...</a><br/></td></tr>
<tr class="separator:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3fca90fb0679afeb968aa8c3d5874487"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga3fca90fb0679afeb968aa8c3d5874487"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for specified thread to terminate.  <a href="#ga3fca90fb0679afeb968aa8c3d5874487">More...</a><br/></td></tr>
<tr class="separator:ga3fca90fb0679afeb968aa8c3d5874487"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaddaa452dd7610e4096647a566d3556fc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a> (void)</td></tr>
<tr class="memdesc:gaddaa452dd7610e4096647a566d3556fc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Terminate execution of current running thread.  <a href="#gaddaa452dd7610e4096647a566d3556fc">More...</a><br/></td></tr>
<tr class="separator:gaddaa452dd7610e4096647a566d3556fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Terminate execution of a thread.  <a href="#ga2f8ba6dba6e9c065a6e236ffd410d74a">More...</a><br/></td></tr>
<tr class="separator:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab9f8bd715d671c6ee27644867bc1bf65"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gab9f8bd715d671c6ee27644867bc1bf65">osThreadGetStackSize</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gab9f8bd715d671c6ee27644867bc1bf65"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get stack size of a thread.  <a href="#gab9f8bd715d671c6ee27644867bc1bf65">More...</a><br/></td></tr>
<tr class="separator:gab9f8bd715d671c6ee27644867bc1bf65"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9c83bd5dd8de329701775d6ef7012720"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga9c83bd5dd8de329701775d6ef7012720">osThreadGetStackSpace</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga9c83bd5dd8de329701775d6ef7012720"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get available stack space of a thread based on stack watermark recording during execution.  <a href="#ga9c83bd5dd8de329701775d6ef7012720">More...</a><br/></td></tr>
<tr class="separator:ga9c83bd5dd8de329701775d6ef7012720"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga495b3f812224e7301f23a691793765db"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga495b3f812224e7301f23a691793765db">osThreadGetCount</a> (void)</td></tr>
<tr class="memdesc:ga495b3f812224e7301f23a691793765db"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of active threads.  <a href="#ga495b3f812224e7301f23a691793765db">More...</a><br/></td></tr>
<tr class="separator:ga495b3f812224e7301f23a691793765db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5606604d56e21ece1a654664be877439"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5606604d56e21ece1a654664be877439">osThreadEnumerate</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> *thread_array, uint32_t array_items)</td></tr>
<tr class="memdesc:ga5606604d56e21ece1a654664be877439"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enumerate active threads.  <a href="#ga5606604d56e21ece1a654664be877439">More...</a><br/></td></tr>
<tr class="separator:ga5606604d56e21ece1a654664be877439"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>The Thread Management function group allows defining, creating, and controlling thread functions in the system.</p>
<dl class="section note"><dt>Note</dt><dd>Thread management functions cannot be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><a class="anchor" id="ThreadStates"></a></p>
<h2>Thread states </h2>
<p>Threads can be in the following states:</p>
<ul>
<li><b>RUNNING:</b> The thread that is currently running is in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> state. Only one thread at a time can be in this state.</li>
<li><b>READY:</b> Threads which are ready to run are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state. Once the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread has terminated, or is <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a>, the next <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread with the highest priority becomes the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread.</li>
<li><b>BLOCKED:</b> Threads that are blocked either delayed, waiting for an event to occur or suspended are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state.</li>
<li><b>TERMINATED:</b> When <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> is called, threads are <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">TERMINATED</a> with resources not yet released (applies to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#joinable_threads">joinable threads).</a></li>
<li><b>INACTIVE:</b> Threads that are not created or have been terminated with all resources released are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">INACTIVE</a> state.</li>
</ul>
<div class="image">
<img src="ThreadStatus.png" alt="ThreadStatus.png"/>
<div class="caption">
Thread State and State Transitions</div></div>
<p>A CMSIS-RTOS assumes that threads are scheduled as shown in the figure <b>Thread State and State Transitions</b>. The thread states change as follows:</p>
<ul>
<li>A thread is created using the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>. This puts the thread into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> state (depending on the thread priority).</li>
<li>CMSIS-RTOS is preemptive. The active thread with the highest priority becomes the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread provided it does not wait for any event. The initial priority of a thread is defined with the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> but may be changed during execution using the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a>.</li>
<li>The <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread transfers into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state when it is delayed, waiting for an event or suspended.</li>
<li>Active threads can be terminated any time using the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a>. Threads can terminate also by just returning from the thread function. Threads that are terminated are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">INACTIVE</a> state and typically do not consume any dynamic memory resources.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>Refer to <a class="el" href="config_rtx5.html#threadConfig">Thread Configuration</a> for RTX5 configuration options.</dd></dl>
<p><a class="anchor" id="thread_examples"></a></p>
<h1>Thread Examples </h1>
<p>The following examples show various scenarios to create threads:</p>
<p><b>Example 1 - Create a simple thread</b></p>
<p>Create a thread out of the function thread1 using all default values for thread attributes and memory from the <a class="el" href="theory_of_operation.html#GlobalMemoryPool">Global Memory Pool</a>.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line">  <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>();</div>
<div class="line">  ;</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, NULL);     <span class="comment">// Create thread with default settings</span></div>
<div class="line">  ;</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>(); </div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 2 - Create thread with stack non-default stack size</b></p>
<p>Similar to the simple thread all attributes are default. The stack is dynamically allocated from the <a class="el" href="theory_of_operation.html#GlobalMemoryPool">Global Memory Pool</a></p>
<p><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">osThreadAttr_t::stack_size</a> is used to pass the stack size in Bytes to osThreadNew.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line">  <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line">  .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">stack_size</a> = 1024                            <span class="comment">// Create the thread stack with a size of 1024 bytes</span></div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line">  ;  </div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr);    <span class="comment">// Create thread with custom sized stack memory</span></div>
<div class="line">  ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 3 - Create thread with statically allocated stack</b></p>
<p>Similar to the simple thread all attributes are default. The stack is statically allocated using the <code>uint64_t</code> array <code>thread1_stk_1</code>. This allocates 64*8 Bytes (=512 Bytes) with an alignment of 8 Bytes (mandatory for Cortex-M stack memory).</p>
<p><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">osThreadAttr_t::stack_mem</a> holds a pointer to the stacks lowest address.</p>
<p><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">osThreadAttr_t::stack_size</a> is used to pass the stack size in Bytes to osThreadNew.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line">  <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> uint64_t thread1_stk_1[64];</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line">  .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a>  = &amp;thread1_stk_1[0],</div>
<div class="line">  .stack_size = <span class="keyword">sizeof</span>(thread1_stk_1)</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line">  ;  </div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr);    <span class="comment">// Create thread with statically allocated stack memory</span></div>
<div class="line">  ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 4 - Thread with statically allocated task control block</b></p>
<p>Typically this method is chosen together with a statically allocated stack as shown in Example 2. </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">//include rtx_os.h for types of RTX objects</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="rtx__os_8h.html">rtx_os.h</a>&quot;</span></div>
<div class="line"></div>
<div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line">  <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code" href="rtx__os_8h.html#structosRtxThread__t">osRtxThread_t</a> thread1_tcb;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line">  .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>  = &amp;thread1_tcb,</div>
<div class="line">  .cb_size = <span class="keyword">sizeof</span>(thread1_tcb),</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line">  ;</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr);    <span class="comment">// Create thread with custom tcb memory</span></div>
<div class="line">  ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 5 - Create thread with a different priority</b></p>
<p>The default priority of RTX is <a class="el" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1">osPriorityNormal</a>. Often you want to run a task with a higher or lower priority. Using the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> control structure you can set any initial priority required.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line">  <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line">  .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#a6a5183df4c54c3e28dc8dc704f2487d5">priority</a> = <a class="code" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a>                    <span class="comment">//Set initial thread priority to high   </span></div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line">  ;</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr);</div>
<div class="line">  ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><a class="anchor" id="joinable_threads"></a><b>Example 6 - Joinable threads</b></p>
<p>In this example a master thread creates four threads with the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a> attribute. These will do some work and return using the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a> call after finished. <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> is used to synchronize the thread termination.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> worker (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  ; <span class="comment">// work a lot on data[] </span></div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000U);</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>();</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> worker_attr;</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> worker_ids[4];</div>
<div class="line">  uint8_t data[4][10];</div>
<div class="line"></div>
<div class="line">  memset(&amp;worker_attr, 0, <span class="keyword">sizeof</span>(worker_attr));</div>
<div class="line">  worker_attr.<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#a6e93b49cb79c12f768d72580c7731f30">attr_bits</a> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>;</div>
<div class="line"> </div>
<div class="line">  worker_ids[0] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[0][0], &amp;worker_attr);</div>
<div class="line">  worker_ids[1] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[1][0], &amp;worker_attr);</div>
<div class="line">  worker_ids[2] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[2][0], &amp;worker_attr);</div>
<div class="line">  worker_ids[3] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[3][0], &amp;worker_attr);</div>
<div class="line"> </div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[0]);</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[1]);</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[2]);</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[3]);</div>
<div class="line"> </div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>(); </div>
<div class="line">}</div>
</div><!-- fragment --> <hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structosThreadAttr__t" id="structosThreadAttr__t"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct osThreadAttr_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<div class="textblock"><p>Specifies the following attributes for the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> function. </p>
</div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
<td class="fieldname">
name</td>
<td class="fielddoc">
name of the thread <p>Pointer to a constant string with a human readable name (displayed during debugging) of the thread object.</p>
<p>Default: <span class="XML-Token">NULL</span> no name specified (debugger may display function name instead). </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
<td class="fieldname">
attr_bits</td>
<td class="fielddoc">
attribute bits <p>The following bit masks can be used to set options:</p>
<ul>
<li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a> : create thread in a detached mode (default).</li>
<li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a> : create thread in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#joinable_threads">joinable mode</a>. </li>
</ul>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
<td class="fieldname">
cb_mem</td>
<td class="fielddoc">
memory for control block <p>Pointer to a memory for the thread control block object. Refer to <a class="el" href="theory_of_operation.html#StaticObjectMemory">Static Object Memory</a> for more information.</p>
<p>Default: <span class="XML-Token">NULL</span> to use <a class="el" href="group__CMSIS__RTOS__MemoryMgmt.html#CMSIS_RTOS_MemoryMgmt_Automatic">Automatic Dynamic Allocation</a> for the thread control block. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
<td class="fieldname">
cb_size</td>
<td class="fielddoc">
size of provided memory for control block <p>The size (in bytes) of memory block passed with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. For RTX, the minimum value is defined with <a class="el" href="group__rtx5__specific__defines.html#ga30d19272204231956582ebfff69567f6">osRtxThreadCbSize</a> (higher values are permitted).</p>
<p>Default: <span class="XML-Token">0</span> as the default is no memory provided with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ad7c9b42355a4c8b9467130ab3fb19e43"></a>void *</td>
<td class="fieldname">
stack_mem</td>
<td class="fielddoc">
memory for stack <p>Pointer to a memory location for the thread stack (64-bit aligned).</p>
<p>Default: <span class="XML-Token">NULL</span> to allocate stack from a fixed-size memory pool using <a class="el" href="theory_of_operation.html#ThreadStack">Thread Stack Management</a>. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aacbc9a219f2d6870e9ce89bb93f975c9"></a>uint32_t</td>
<td class="fieldname">
stack_size</td>
<td class="fielddoc">
size of stack <p>The size (in bytes) of the stack specified by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a>.</p>
<p>Default: <span class="XML-Token">0</span> as the default is no memory provided with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a>.</p>
<p>/** </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a6a5183df4c54c3e28dc8dc704f2487d5"></a><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></td>
<td class="fieldname">
priority</td>
<td class="fielddoc">
initial thread priority (default: osPriorityNormal) <p>Specifies the initial thread priority with a value from <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec" title="Priority values. ">osPriority_t</a>.</p>
<p>Default: <span class="XML-Token">osPriorityNormal</span>. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a697f2aad6119d655d212ea10245ae394"></a><a class="el" href="cmsis__os2_8h.html#ad5ef21485fe5f60263bc0b48006202cb">TZ_ModuleId_t</a></td>
<td class="fieldname">
tz_module</td>
<td class="fielddoc">
TrustZone module identifier. <p>TrustZone Thread Context Management Identifier to allocate context memory for threads. The RTOS kernel that runs in non-secure state calls the interface functions defined by the header file TZ_context.h. Can safely be set to zero for threads not using secure calls at all. See <a href="../../Core/html/group__context__trustzone__functions.html">TrustZone RTOS Context Management</a>.</p>
<p>Default: <span class="XML-Token">0</span> not thread context specified.</p>
<p>/** </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a66f538babc389986738ec70104e0562b"></a>uint32_t</td>
<td class="fieldname">
reserved</td>
<td class="fielddoc">
reserved (must be 0) <p>Reserved for future use. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga249499c519f3f8eef5673009ab6cfcbe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osThreadJoinable&#160;&#160;&#160;0x00000001U</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A thread in this state can be joined using <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. </p>

</div>
</div>
<a class="anchor" id="gaa9336c1073858d6b118e2e011636246f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osThreadDetached&#160;&#160;&#160;0x00000000U</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A thread in this state cannot be joined using <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. </p>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="gadd51f99a6eb50b94eee75f27cae815eb"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* osThreadFunc_t)(void *argument)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Entry function for threads. Setting up a new thread (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>) will start execution with a call into this entry function. The optional argument can be used to hand over arbitrary user data to the thread, i.e. to identify the thread or for runtime parameters.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">argument</td><td>Arbitrary user data set on <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaa6c32fe2a3e0a2e01f212d55b02e51c7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Thread ID identifies the thread.</p>
<p>Returned by:</p>
<ul>
<li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a></li>
<li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a></li>
<li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5606604d56e21ece1a654664be877439">osThreadEnumerate</a></li>
<li><a class="el" href="group__CMSIS__RTOS__MutexMgmt.html#ga7f9a7666df0978738cd570cb700b83fb">osMutexGetOwner</a> </li>
</ul>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>State of a thread as retrieved by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a>. In case <b>osThreadGetState</b> fails or if it is called from an ISR, it will return <code>osThreadError</code>, otherwise it returns the thread state. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="ggad3dc89e942e38d9f3af858a0269a820dae9d77830b6866e287417b6e1d983e971"></a>osThreadInactive</em>&#160;</td><td class="fielddoc">
<p>Inactive. </p>
<p>The thread is created but not actively used, or has been terminated (returned for static control block allocation, when memory pools are used <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a> is returned as the control block is no longer valid) </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad3dc89e942e38d9f3af858a0269a820da59e286915944fe0e4d1ffdb1f2946f14"></a>osThreadReady</em>&#160;</td><td class="fielddoc">
<p>Ready. </p>
<p>The thread is ready for execution but not currently running. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad3dc89e942e38d9f3af858a0269a820dac4fe336e0790188fcf7d667372eca19d"></a>osThreadRunning</em>&#160;</td><td class="fielddoc">
<p>Running. </p>
<p>The thread is currently running. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968"></a>osThreadBlocked</em>&#160;</td><td class="fielddoc">
<p>Blocked. </p>
<p>The thread is currently blocked (delayed, waiting for an event or suspended). </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c"></a>osThreadTerminated</em>&#160;</td><td class="fielddoc">
<p>Terminated. </p>
<p>The thread is terminated and all its resources are not yet freed (applies to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#joinable_threads">joinable threads).</a></p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e"></a>osThreadError</em>&#160;</td><td class="fielddoc">
<p>Error. </p>
<p>The thread does not exist (has raised an error condition) and cannot be scheduled. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c"></a>osThreadReserved</em>&#160;</td><td class="fielddoc">
<p>Prevents enum down-size compiler optimization. </p>
</td></tr>
</table>

</div>
</div>
<a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ec"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The <b>osPriority_t</b> value specifies the priority for a thread. The default thread priority should be <em>osPriorityNormal</em>. If an active thread becomes ready that has a higher priority than the currently running thread then a thread switch occurs immediately. The system continues executing the thread with the higher priority.</p>
<p>To prevent from a priority inversion, a CMSIS-RTOS compliant OS may optionally implement a <b>priority inheritance</b> method. A priority inversion occurs when a high priority thread is waiting for a resource or event that is controlled by a thread with a lower priority. Thus causing the high priority thread potentially beeing blocked forever by another thread with lower priority. To come over this issue the low priority thread controlling the resource should be treated as having the higher priority until it releases the resource.</p>
<dl class="section note"><dt>Note</dt><dd>Priority inheritance only applies to mutexes. </dd></dl>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3"></a>osPriorityNone</em>&#160;</td><td class="fielddoc">
<p>No priority (not initialized). </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad4e3e0971b41f2d17584a8c6837342ecacd5864eac01a6916a7c866bb51a6aac1"></a>osPriorityIdle</em>&#160;</td><td class="fielddoc">
<p>Reserved for Idle thread. </p>
<p>This lowest priority should not be used for any other thread. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4"></a>osPriorityLow</em>&#160;</td><td class="fielddoc">
<p>Priority: low. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe"></a>osPriorityLow1</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507"></a>osPriorityLow2</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50"></a>osPriorityLow3</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81"></a>osPriorityLow4</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353"></a>osPriorityLow5</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393"></a>osPriorityLow6</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a"></a>osPriorityLow7</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6"></a>osPriorityBelowNormal</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5"></a>osPriorityBelowNormal1</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3"></a>osPriorityBelowNormal2</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf"></a>osPriorityBelowNormal3</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24"></a>osPriorityBelowNormal4</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e"></a>osPriorityBelowNormal5</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05"></a>osPriorityBelowNormal6</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b"></a>osPriorityBelowNormal7</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1"></a>osPriorityNormal</em>&#160;</td><td class="fielddoc">
<p>Priority: normal. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c"></a>osPriorityNormal1</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205"></a>osPriorityNormal2</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91"></a>osPriorityNormal3</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d"></a>osPriorityNormal4</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab"></a>osPriorityNormal5</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204"></a>osPriorityNormal6</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b"></a>osPriorityNormal7</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b"></a>osPriorityAboveNormal</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998"></a>osPriorityAboveNormal1</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562"></a>osPriorityAboveNormal2</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013"></a>osPriorityAboveNormal3</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec"></a>osPriorityAboveNormal4</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c"></a>osPriorityAboveNormal5</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207"></a>osPriorityAboveNormal6</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d"></a>osPriorityAboveNormal7</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2"></a>osPriorityHigh</em>&#160;</td><td class="fielddoc">
<p>Priority: high. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb"></a>osPriorityHigh1</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03"></a>osPriorityHigh2</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759"></a>osPriorityHigh3</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb"></a>osPriorityHigh4</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9"></a>osPriorityHigh5</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc"></a>osPriorityHigh6</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652"></a>osPriorityHigh7</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af"></a>osPriorityRealtime</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b"></a>osPriorityRealtime1</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff"></a>osPriorityRealtime2</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa"></a>osPriorityRealtime3</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70"></a>osPriorityRealtime4</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df"></a>osPriorityRealtime5</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194"></a>osPriorityRealtime6</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b"></a>osPriorityRealtime7</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ggad4e3e0971b41f2d17584a8c6837342eca4b4fa46c3ebaf4259662a0a0a3173b7f"></a>osPriorityISR</em>&#160;</td><td class="fielddoc">
<p>Reserved for ISR deferred thread. </p>
<p>This highest priority might be used by the RTOS implementation but must not be used for any user thread. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4"></a>osPriorityError</em>&#160;</td><td class="fielddoc">
<p>System cannot determine priority or illegal priority. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b"></a>osPriorityReserved</em>&#160;</td><td class="fielddoc">
<p>Prevents enum down-size compiler optimization. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga48d68b8666d99d28fa646ee1d2182b8f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> osThreadNew </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a>&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>argument</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> *&#160;</td>
          <td class="paramname"><em>attr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">func</td><td>thread function. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">argument</td><td>pointer that is passed to the thread function as start argument. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>thread attributes; NULL: default values. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>thread ID for reference by other functions or NULL in case of error.</dd></dl>
<p>The function <b>osThreadNew</b> starts a thread function by adding it to the list of active threads and sets it to state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a>. Arguments for the thread function are passed using the parameter pointer <em>*argument</em>. When the priority of the created thread function is higher than the current <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread, the created thread function starts instantly and becomes the new <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread. Thread attributes are defined with the parameter pointer <em>attr</em>. Attributes include settings for thread priority, stack size, or memory allocation.</p>
<p>The function can be safely called before the RTOS is started (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>), but not before it is initialized (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>).</p>
<p>The function <b>osThreadNew</b> returns the pointer to the thread object identifier or <span class="XML-Token">NULL</span> in case of an error.</p>
<dl class="section note"><dt>Note</dt><dd>Cannot be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><b>Code</b> <b>Example</b> </p>
<p>Refer to the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#thread_examples">Thread Examples</a> section. </p>

</div>
</div>
<a class="anchor" id="gac3230f3a55a297514b013ebf38f27e0a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const char * osThreadGetName </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
<p>The function <b>osThreadGetName</b> returns the pointer to the name string of the thread identified by parameter <em>thread_id</em> or <span class="XML-Token">NULL</span> in case of an error.</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> ThreadGetName_example (<span class="keywordtype">void</span>) {</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>();</div>
<div class="line">  <span class="keyword">const</span> <span class="keywordtype">char</span>* name = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac3230f3a55a297514b013ebf38f27e0a">osThreadGetName</a>(thread_id);</div>
<div class="line">  <span class="keywordflow">if</span> (name == NULL) {</div>
<div class="line">    <span class="comment">// Failed to get the thread name; not in a thread</span></div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga8df03548e89fbc56402a5cd584a505da"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> osThreadGetId </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>thread ID for reference by other functions or NULL in case of error.</dd></dl>
<p>The function <b>osThreadGetId</b> returns the thread object ID of the currently running thread or NULL in case of an error.</p>
<dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> ThreadGetId_example (<span class="keywordtype">void</span>) {</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id;                              <span class="comment">// id for the currently running thread</span></div>
<div class="line">   </div>
<div class="line">  <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>();</div>
<div class="line">  <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == NULL) {</div>
<div class="line">    <span class="comment">// Failed to get the id</span></div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gacc0a98b42f0a5928e12dc91dc76866b9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> osThreadGetState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>current thread state of the specified thread.</dd></dl>
<p>The function <b>osThreadGetState</b> returns the state of the thread identified by parameter <em>thread_id</em>. In case it fails or if it is called from an ISR, it will return <code>osThreadError</code>, otherwise it returns the thread state (refer to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> for the list of thread states).</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="ga861a420fb2d643115b06622903fb3bfb"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSetPriority </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a>&#160;</td>
          <td class="paramname"><em>priority</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">priority</td><td>new priority value for the thread function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadSetPriority</b> changes the priority of an active thread specified by the parameter <em>thread_id</em> to the priority specified by the parameter <em>priority</em>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the priority of the specified thread has been changed successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid or <em>priority</em> is incorrect.</li>
<li><em>osErrorResource:</em> the thread is in an invalid state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadSetPriority</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) {               <span class="comment">// Thread function</span></div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id;                              <span class="comment">// id for the currently running thread</span></div>
<div class="line">  osStatus_t   status;                          <span class="comment">// status of the executed function</span></div>
<div class="line"> </div>
<div class="line">  :</div>
<div class="line">  <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>();                         <span class="comment">// Obtain ID of current running thread</span></div>
<div class="line"> </div>
<div class="line">  status = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a>(<span class="keywordtype">id</span>, <a class="code" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a>);  <span class="comment">// Set thread priority</span></div>
<div class="line">  <span class="keywordflow">if</span> (status == <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
<div class="line">    <span class="comment">// Thread priority changed to BelowNormal</span></div>
<div class="line">  }</div>
<div class="line">  <span class="keywordflow">else</span> {</div>
<div class="line">    <span class="comment">// Failed to set the priority</span></div>
<div class="line">  }</div>
<div class="line">  :</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga0aeaf349604f456e68e78f9d3b42e44b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> osThreadGetPriority </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>current priority value of the specified thread.</dd></dl>
<p>The function <b>osThreadGetPriority</b> returns the priority of an active thread specified by the parameter <em>thread_id</em>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> return values:</p>
<ul>
<li><em>priority:</em> the priority of the specified thread.</li>
<li><em>osPriorityError:</em> priority cannot be determined or is illegal. It is also returned when the function is called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) {               <span class="comment">// Thread function</span></div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id;                              <span class="comment">// id for the currently running thread</span></div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> priority;                        <span class="comment">// thread priority</span></div>
<div class="line">   </div>
<div class="line">  <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>();                         <span class="comment">// Obtain ID of current running thread</span></div>
<div class="line">  priority = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga0aeaf349604f456e68e78f9d3b42e44b">osThreadGetPriority</a>(<span class="keywordtype">id</span>);           <span class="comment">// Obtain the thread priority</span></div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gad01c7ec26535b1de6b018bb9466720e2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadYield </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadYield</b> passes control to the next thread with the same priority that is in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state. If there is no other thread with the same priority in state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a>, then the current thread continues execution and no thread switch occurs. <b>osThreadYield</b> does not set the thread to state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a>. Thus no thread with a lower priority will be scheduled even if threads in state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> are available.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> control has been passed to the next thread successfully.</li>
<li><em>osError:</em> an unspecified error has occurred.</li>
<li><em>osErrorISR:</em> the function <b>osThreadYield</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd>
<dd>
This function <b>has no impact</b> when called when the kernel is locked, see <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga948609ee930d9b38336b9e1c2a4dfe12">osKernelLock</a>.</dd></dl>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) {               <span class="comment">// Thread function</span></div>
<div class="line">  osStatus_t status;                            <span class="comment">// status of the executed function</span></div>
<div class="line">  :</div>
<div class="line">  <span class="keywordflow">while</span> (1) {</div>
<div class="line">    status = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>();</div>
<div class="line">    <span class="keywordflow">if</span> (status != <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
<div class="line">      <span class="comment">// an error occurred</span></div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gaa9de419d0152bf77e9bbcd1f369fb990"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSuspend </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadSuspend</b> suspends the execution of the thread identified by parameter <em>thread_id</em>. The thread is put into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968">osThreadBlocked</a>). Suspending the running thread will cause a context switch to another thread in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state immediately. The suspended thread is not executed until explicitly resumed with the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3dbad90eff394b02de76a452c84c5d80">osThreadResume</a>.</p>
<p>Threads that are already <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> are removed from any wait list and become ready when they are resumed. Thus it is not recommended to suspend an already blocked thread.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the thread has been suspended successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> the thread is in an invalid state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadSuspend</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd>
<dd>
This function <b>must not</b> be called to suspend the running thread when the kernel is locked, i.e. <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga948609ee930d9b38336b9e1c2a4dfe12">osKernelLock</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="ga3dbad90eff394b02de76a452c84c5d80"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadResume </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadResume</b> puts the thread identified by parameter <em>thread_id</em> (which has to be in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state) back to the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state. If the resumed thread has a higher priority than the running thread a context switch occurs immediately.</p>
<p>The thread becomes ready regardless of the reason why the thread was blocked. Thus it is not recommended to resume a thread not suspended by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a>.</p>
<p>Functions that will put a thread into <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state are: <a class="el" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> and <a class="el" href="group__CMSIS__RTOS__ThreadFlagsMgmt.html#gac11542ad6300b600f872fc96e340ec2b">osThreadFlagsWait</a>, <a class="el" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> and <a class="el" href="group__CMSIS__RTOS__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a>, <a class="el" href="group__CMSIS__RTOS__MutexMgmt.html#gabc54686ea0fc281823b1763422d2a924">osMutexAcquire</a> and <a class="el" href="group__CMSIS__RTOS__SemaphoreMgmt.html#ga7e94c8b242a0c81f2cc79ec22895c87b">osSemaphoreAcquire</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#gad90d4959466a7a65105061da8256ab9e">osMessageQueueGet</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>, <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>, <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the thread has been resumed successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> the thread is in an invalid state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadResume</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd>
<dd>
This function <b>may be</b> called when kernel is locked (<a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga948609ee930d9b38336b9e1c2a4dfe12">osKernelLock</a>). Under this circumstances a potential context switch is delayed until the kernel gets unlocked, i.e. <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gaf401728b4657456198c33fe75f8d6720">osKernelUnlock</a> or <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae7d0a71b9586cbbb49fcbdf6a04f0289">osKernelRestoreLock</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="gaaad14cd9547341ea8109dc4e8540f1dc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadDetach </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadDetach</b> changes the attribute of a thread (specified by <em>thread_id</em>) to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>. Detached threads are not joinable with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. When a detached thread is terminated, all resources are returned to the system. The behavior of <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaaad14cd9547341ea8109dc4e8540f1dc">osThreadDetach</a> on an already detached thread is undefined.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the attribute of the specified thread has been changed to detached successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> the thread is in an invalid state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadDetach</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="ga3fca90fb0679afeb968aa8c3d5874487"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadJoin </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadJoin</b> waits for the thread specified by <em>thread_id</em> to terminate. If that thread has already terminated, then <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> returns immediately. The thread must be joinable. By default threads are created with the attribute <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> if the thread has already been terminated and joined or once the thread has been terminated and the join operations succeeds.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> the thread is in an invalid state (ex: not joinable).</li>
<li><em>osErrorISR:</em> the function <b>osThreadJoin</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. <br/>
 </dd>
<dd>
Only one thread shall call <b>osThreadJoin</b> to join the target thread. If multiple threads try to join simultaneously with the same thread, the results are undefined. </dd></dl>

</div>
</div>
<a class="anchor" id="gaddaa452dd7610e4096647a566d3556fc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> void osThreadExit </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The function <b>osThreadExit</b> terminates the calling thread. This allows the thread to be synchronized with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>.</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<p><b>Code</b> <b>Example</b> </p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> worker (<span class="keywordtype">void</span> *argument) {</div>
<div class="line">  <span class="comment">// do something</span></div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000U);</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>();</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga2f8ba6dba6e9c065a6e236ffd410d74a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadTerminate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadTerminate</b> removes the thread specified by parameter <em>thread_id</em> from the list of active threads. If the thread is currently <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a>, the thread terminates and the execution continues with the next <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread. If no such thread exists, the function will not terminate the running thread, but return <em>osErrorResource</em>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the specified thread has been removed from the active thread list successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> the thread is in an invalid state or no other <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread exists.</li>
<li><em>osErrorISR:</em> the function <b>osThreadTerminate</b> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd>
<dd>
Avoid calling the function with a <em>thread_id</em> that does not exist or has been terminated already. </dd>
<dd>
<b>osThreadTerminate</b> destroys non-joinable threads and removes their thread_id from the system. Subsequent access to the thread_id (for example <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a>) will return an <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a>. Joinable threads will not be destroyed and return the status <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c">osThreadTerminated</a> until they are joined with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>.</dd></dl>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> *arg);                      <span class="comment">// function prototype for Thread_1</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> ThreadTerminate_example (<span class="keywordtype">void</span>) {</div>
<div class="line">  osStatus_t status;</div>
<div class="line">  <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id;</div>
<div class="line"> </div>
<div class="line">  <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(Thread_1, NULL, NULL);       <span class="comment">// create the thread</span></div>
<div class="line">                                                <span class="comment">// do something</span></div>
<div class="line">  status = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a>(<span class="keywordtype">id</span>);               <span class="comment">// stop the thread</span></div>
<div class="line">  <span class="keywordflow">if</span> (status == <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
<div class="line">                                                <span class="comment">// Thread was terminated successfully</span></div>
<div class="line">  }</div>
<div class="line">  <span class="keywordflow">else</span> {</div>
<div class="line">                                                <span class="comment">// Failed to terminate a thread</span></div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gab9f8bd715d671c6ee27644867bc1bf65"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t osThreadGetStackSize </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>stack size in bytes.</dd></dl>
<p>The function <b>osThreadGetStackSize</b> returns the stack size of the thread specified by parameter <em>thread_id</em>. In case of an error, it returns <span class="XML-Token">0</span>.</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="ga9c83bd5dd8de329701775d6ef7012720"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t osThreadGetStackSpace </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
          <td class="paramname"><em>thread_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>remaining stack space in bytes.</dd></dl>
<p>The function <b>osThreadGetStackSpace</b> returns the size of unused stack space for the thread specified by parameter <em>thread_id</em>. Stack watermark recording during execution needs to be enabled (refer to <a class="el" href="config_rtx5.html#threadConfig">Thread Configuration</a>). In case of an error, it returns <span class="XML-Token">0</span>.</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="ga495b3f812224e7301f23a691793765db"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t osThreadGetCount </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>number of active threads.</dd></dl>
<p>The function <b>osThreadGetCount</b> returns the number of active threads or <span class="XML-Token">0</span> in case of an error.</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="ga5606604d56e21ece1a654664be877439"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t osThreadEnumerate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> *&#160;</td>
          <td class="paramname"><em>thread_array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>array_items</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">thread_array</td><td>pointer to array for retrieving thread IDs. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">array_items</td><td>maximum number of items in array for retrieving thread IDs. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>number of enumerated threads.</dd></dl>
<p>The function <b>osThreadEnumerate</b> returns the number of enumerated threads or <span class="XML-Token">0</span> in case of an error.</p>
<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Wed Jul 10 2019 15:21:04 for CMSIS-RTOS2 Version 2.1.3 by Arm Ltd. All rights reserved.
	<!--
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 
	-->
	</li>
  </ul>
</div>
</body>
</html>