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
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</legalnotice>
<title>erlang</title>
<prepared></prepared>
<docno></docno>
<date></date>
<rev></rev>
<file>erlang.xml</file>
</header>
<module>erlang</module>
<modulesummary>The Erlang BIFs</modulesummary>
<description>
<p>By convention, most built-in functions (BIFs) are seen as being
in the module <c>erlang</c>. A number of the BIFs are viewed more
or less as part of the Erlang programming language and are
<em>auto-imported</em>. Thus, it is not necessary to specify
the module name and both the calls <c>atom_to_list(Erlang)</c> and
<c>erlang:atom_to_list(Erlang)</c> are identical.</p>
<p>In the text, auto-imported BIFs are listed without module prefix.
BIFs listed with module prefix are not auto-imported.</p>
<p>BIFs may fail for a variety of reasons. All BIFs fail with
reason <c>badarg</c> if they are called with arguments of an
incorrect type. The other reasons that may make BIFs fail are
described in connection with the description of each individual
BIF.</p>
<p>Some BIFs may be used in guard tests, these are marked with
"Allowed in guard tests".</p>
</description>
<datatypes>
<datatype>
<name><marker id="type-ext_binary">ext_binary()</marker></name>
<desc>
<p>A binary data object, structured according to
the Erlang external term format.</p>
</desc>
</datatype>
<datatype>
<name name="timestamp"></name>
<desc><p>See <seealso marker="#timestamp/0">erlang:timestamp/0</seealso>.</p>
</desc>
</datatype>
<marker id="type_time_unit"/>
<datatype>
<name name="time_unit"></name>
<desc><p>Currently supported time unit representations:</p>
<taglist>
<tag><c>PartsPerSecond :: integer() >= 1</c></tag>
<item><p>Time unit expressed in parts per second. That is,
the time unit equals <c>1/PartsPerSecond</c> second.</p></item>
<tag><c>seconds</c></tag>
<item><p>Symbolic representation of the time unit
represented by the integer <c>1</c>.</p></item>
<tag><c>milli_seconds</c></tag>
<item><p>Symbolic representation of the time unit
represented by the integer <c>1000</c>.</p></item>
<tag><c>micro_seconds</c></tag>
<item><p>Symbolic representation of the time unit
represented by the integer <c>1000000</c>.</p></item>
<tag><c>nano_seconds</c></tag>
<item><p>Symbolic representation of the time unit
represented by the integer <c>1000000000</c>.</p></item>
<tag><c>native</c></tag>
<item><p>Symbolic representation of the native time unit
used by the Erlang runtime system.</p>
<p>The <c>native</c> time unit is determined at
runtime system start, and will remain the same until
the runtime system terminates. If a runtime system
is stopped and then started again (even on the same
machine), the <c>native</c> time unit of the new
runtime system instance may differ from the
<c>native</c> time unit of the old runtime system
instance.</p>
<p>One can get an approximation of the <c>native</c>
time unit by calling <c>erlang:convert_time_unit(1,
seconds, native)</c>. The result equals the number
of whole <c>native</c> time units per second. In case
the number of <c>native</c> time units per second does
not add up to a whole number, the result will be
rounded downwards.</p>
<note>
<p>The value of the <c>native</c> time unit gives
you more or less no information at all about the
quality of time values. It sets a limit for
the
<seealso marker="time_correction#Time_Resolution">resolution</seealso>
as well as for the
<seealso marker="time_correction#Time_Precision">precision</seealso>
of time values,
but it gives absolutely no information at all about the
<seealso marker="time_correction#Time_Accuracy">accuracy</seealso>
of time values. The resolution of the <c>native</c> time
unit and the resolution of time values may differ
significantly.</p>
</note>
</item>
</taglist>
<p>The <c>time_unit/0</c> type may be extended. Use
<seealso marker="#convert_time_unit/3"><c>erlang:convert_time_unit/3</c></seealso>
in order to convert time values between time units.</p>
</desc>
</datatype>
</datatypes>
<funcs>
<func>
<name name="abs" arity="1" clause_i="1"/>
<name name="abs" arity="1" clause_i="2"/>
<type variable="Float" name_i="1"/>
<type variable="Int" name_i="2"/>
<fsummary>Arithmetical absolute value</fsummary>
<desc>
<p>Returns an integer or float which is the arithmetical
absolute value of <c><anno>Float</anno></c> or <c><anno>Int</anno></c>.</p>
<pre>
> <input>abs(-3.33).</input>
3.33
> <input>abs(-3).</input>
3</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="adler32" arity="1"/>
<fsummary>Compute adler32 checksum</fsummary>
<desc>
<p>Computes and returns the adler32 checksum for <c><anno>Data</anno></c>.</p>
</desc>
</func>
<func>
<name name="adler32" arity="2"/>
<fsummary>Compute adler32 checksum</fsummary>
<desc>
<p>Continue computing the adler32 checksum by combining
the previous checksum, <c><anno>OldAdler</anno></c>, with the checksum of
<c><anno>Data</anno></c>.</p>
<p>The following code:</p>
<code>
X = erlang:adler32(Data1),
Y = erlang:adler32(X,Data2).
</code>
<p>- would assign the same value to <c>Y</c> as this would:</p>
<code>
Y = erlang:adler32([Data1,Data2]).
</code>
</desc>
</func>
<func>
<name name="adler32_combine" arity="3"/>
<fsummary>Combine two adler32 checksums</fsummary>
<desc>
<p>Combines two previously computed adler32 checksums.
This computation requires the size of the data object for
the second checksum to be known.</p>
<p>The following code:</p>
<code>
Y = erlang:adler32(Data1),
Z = erlang:adler32(Y,Data2).
</code>
<p>- would assign the same value to <c>Z</c> as this would:</p>
<code>
X = erlang:adler32(Data1),
Y = erlang:adler32(Data2),
Z = erlang:adler32_combine(X,Y,iolist_size(Data2)).
</code>
</desc>
</func>
<func>
<name name="append_element" arity="2"/>
<fsummary>Append an extra element to a tuple</fsummary>
<desc>
<p>Returns a new tuple which has one element more than
<c><anno>Tuple1</anno></c>, and contains the elements in <c><anno>Tuple1</anno></c>
followed by <c><anno>Term</anno></c> as the last element. Semantically
equivalent to
<c>list_to_tuple(tuple_to_list(<anno>Tuple1</anno>) ++ [<anno>Term</anno>])</c>, but much
faster.</p>
<pre>
> <input>erlang:append_element({one, two}, three).</input>
{one,two,three}</pre>
</desc>
</func>
<func>
<name name="apply" arity="2"/>
<fsummary>Apply a function to an argument list</fsummary>
<desc>
<p>Call a fun, passing the elements in <c><anno>Args</anno></c> as
arguments.</p>
<p>Note: If the number of elements in the arguments are known at
compile-time, the call is better written as
<c><anno>Fun</anno>(Arg1, Arg2, ... ArgN)</c>.</p>
<warning>
<p>Earlier, <c><anno>Fun</anno></c> could also be given as
<c>{Module, Function}</c>, equivalent to
<c>apply(Module, Function, Args)</c>. This usage is
deprecated and will stop working in a future release of
Erlang/OTP.</p>
</warning>
</desc>
</func>
<func>
<name name="apply" arity="3"/>
<fsummary>Apply a function to an argument list</fsummary>
<desc>
<p>Returns the result of applying <c>Function</c> in
<c><anno>Module</anno></c> to <c><anno>Args</anno></c>. The applied function must
be exported from <c>Module</c>. The arity of the function is
the length of <c>Args</c>.</p>
<pre>
> <input>apply(lists, reverse, [[a, b, c]]).</input>
[c,b,a]</pre>
<p><c>apply</c> can be used to evaluate BIFs by using
the module name <c>erlang</c>.</p>
<pre>
> <input>apply(erlang, atom_to_list, ['Erlang']).</input>
"Erlang"</pre>
<p>Note: If the number of arguments are known at compile-time,
the call is better written as
<c><anno>Module</anno>:<anno>Function</anno>(Arg1, Arg2, ..., ArgN)</c>.</p>
<p>Failure: <c>error_handler:undefined_function/3</c> is called
if the applied function is not exported. The error handler
can be redefined (see
<seealso marker="#process_flag/2">process_flag/2</seealso>).
If the <c>error_handler</c> is undefined, or if the user has
redefined the default <c>error_handler</c> so the replacement
module is undefined, an error with the reason <c>undef</c>
is generated.</p>
</desc>
</func>
<func>
<name name="atom_to_binary" arity="2"/>
<fsummary>Return the binary representation of an atom</fsummary>
<desc>
<p>Returns a binary which corresponds to the text
representation of <c><anno>Atom</anno></c>. If <c><anno>Encoding</anno></c>
is <c>latin1</c>, there will be one byte for each character
in the text representation. If <c><anno>Encoding</anno></c> is
<c>utf8</c> or
<c>unicode</c>, the characters will be encoded using UTF-8
(meaning that characters from 16#80 up to 0xFF will be
encoded in two bytes).</p>
<note><p>Currently, <c>atom_to_binary(<anno>Atom</anno>, latin1)</c> can
never fail because the text representation of an atom can only contain
characters from 0 to 16#FF. In a future release, the text representation
of atoms might be allowed to contain any Unicode character
and <c>atom_to_binary(<anno>Atom</anno>, latin1)</c> will fail if the
text representation for the <c><anno>Atom</anno></c> contains a Unicode
character greater than 16#FF.</p></note>
<pre>
> <input>atom_to_binary('Erlang', latin1).</input>
<<"Erlang">></pre>
</desc>
</func>
<func>
<name name="atom_to_list" arity="1"/>
<fsummary>Text representation of an atom</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c><anno>Atom</anno></c>.</p>
<pre>
> <input>atom_to_list('Erlang').</input>
"Erlang"</pre>
</desc>
</func>
<func>
<name name="binary_part" arity="2"/>
<fsummary>Extracts a part of a binary</fsummary>
<desc>
<p>Extracts the part of the binary described by <c><anno>PosLen</anno></c>.</p>
<p>Negative length can be used to extract bytes at the end of a binary:</p>
<code>
1> Bin = <<1,2,3,4,5,6,7,8,9,10>>.
2> binary_part(Bin,{byte_size(Bin), -5}).
<<6,7,8,9,10>>
</code>
<p>If <c><anno>PosLen</anno></c> in any way references outside the binary, a <c>badarg</c> exception is raised.</p>
<p><c><anno>Start</anno></c> is zero-based, i.e.:</p>
<code>
1> Bin = <<1,2,3>>
2> binary_part(Bin,{0,2}).
<<1,2>>
</code>
<p>See the STDLIB module <c>binary</c> for details about the <c><anno>PosLen</anno></c> semantics.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="binary_part" arity="3"/>
<fsummary>Extracts a part of a binary</fsummary>
<desc>
<p>The same as <c>binary_part(<anno>Subject</anno>, {<anno>Start</anno>, <anno>Length</anno>})</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="binary_to_atom" arity="2"/>
<fsummary>Convert from text representation to an atom</fsummary>
<desc>
<p>Returns the atom whose text representation is
<c><anno>Binary</anno></c>. If <c><anno>Encoding</anno></c> is <c>latin1</c>, no
translation of bytes in the binary is done. If <c><anno>Encoding</anno></c>
is <c>utf8</c> or <c>unicode</c>, the binary must contain
valid UTF-8 sequences; furthermore, only Unicode characters up
to 0xFF are allowed.</p>
<note><p><c>binary_to_atom(<anno>Binary</anno>, utf8)</c> will fail if
the binary contains Unicode characters greater than 16#FF.
In a future release, such Unicode characters might be allowed
and <c>binary_to_atom(<anno>Binary</anno>, utf8)</c>
will not fail in that case. For more information on Unicode support in atoms
see <seealso marker="erl_ext_dist#utf8_atoms">note on UTF-8 encoded atoms</seealso>
in the chapter about the external term format in the ERTS User's Guide.</p></note>
<pre>
> <input>binary_to_atom(<<"Erlang">>, latin1).</input>
'Erlang'
> <input>binary_to_atom(<<1024/utf8>>, utf8).</input>
** exception error: bad argument
in function binary_to_atom/2
called as binary_to_atom(<<208,128>>,utf8)</pre>
</desc>
</func>
<func>
<name name="binary_to_existing_atom" arity="2"/>
<fsummary>Convert from text representation to an atom</fsummary>
<desc>
<p>Works like <seealso marker="#binary_to_atom/2">binary_to_atom/2</seealso>,
but the atom must already exist.</p>
<p>Failure: <c>badarg</c> if the atom does not already exist.</p>
</desc>
</func>
<func>
<name name="binary_to_float" arity="1"/>
<fsummary>Convert from text representation to a float</fsummary>
<desc>
<p>Returns the float whose text representation is <c><anno>Binary</anno></c>.</p>
<pre>
> <input>binary_to_float(<<"2.2017764e+0">>).</input>
2.2017764</pre>
<p>Failure: <c>badarg</c> if <c><anno>Binary</anno></c> contains a bad
representation of a float.</p>
</desc>
</func>
<func>
<name name="binary_to_integer" arity="1"/>
<fsummary>Convert from text representation to an integer</fsummary>
<desc>
<p>Returns an integer whose text representation is
<c><anno>Binary</anno></c>.</p>
<pre>
> <input>binary_to_integer(<<"123">>).</input>
123</pre>
<p>Failure: <c>badarg</c> if <c><anno>Binary</anno></c> contains a bad
representation of an integer.</p>
</desc>
</func>
<func>
<name name="binary_to_integer" arity="2"/>
<fsummary>Convert from text representation to an integer</fsummary>
<desc>
<p>Returns an integer whose text representation in base
<c><anno>Base</anno></c> is <c><anno>Binary</anno></c>.</p>
<pre>
> <input>binary_to_integer(<<"3FF">>, 16).</input>
1023</pre>
<p>Failure: <c>badarg</c> if <c><anno>Binary</anno></c> contains a bad
representation of an integer.</p>
</desc>
</func>
<func>
<name name="binary_to_list" arity="1"/>
<fsummary>Convert a binary to a list</fsummary>
<desc>
<p>Returns a list of integers which correspond to the bytes of
<c><anno>Binary</anno></c>.</p>
</desc>
</func>
<func>
<name name="binary_to_list" arity="3"/>
<fsummary>Convert part of a binary to a list</fsummary>
<type_desc variable="Start">1..byte_size(<anno>Binary</anno>)</type_desc>
<desc>
<p>As <c>binary_to_list/1</c>, but returns a list of integers
corresponding to the bytes from position <c><anno>Start</anno></c> to
position <c><anno>Stop</anno></c> in <c><anno>Binary</anno></c>. Positions in the
binary are numbered starting from 1.</p>
<note><p>This function's indexing style of using one-based indices for
binaries is deprecated. New code should use the functions in
the STDLIB module <c>binary</c> instead. They consequently
use the same (zero-based) style of indexing.</p></note>
</desc>
</func>
<func>
<name name="bitstring_to_list" arity="1"/>
<fsummary>Convert a bitstring to a list</fsummary>
<desc>
<p>Returns a list of integers which correspond to the bytes of
<c><anno>Bitstring</anno></c>. If the number of bits in the binary is not
divisible by 8, the last element of the list will be a bitstring
containing the remaining bits (1 up to 7 bits).</p>
</desc>
</func>
<func>
<name name="binary_to_term" arity="1"/>
<fsummary>Decode an Erlang external term format binary</fsummary>
<desc>
<p>Returns an Erlang term which is the result of decoding
the binary object <c><anno>Binary</anno></c>, which must be encoded
according to the Erlang external term format.</p>
<warning>
<p>When decoding binaries from untrusted sources, consider using
<c>binary_to_term/2</c> to prevent denial of service attacks.</p>
</warning>
<p>See also
<seealso marker="#term_to_binary/1">term_to_binary/1</seealso>
and
<seealso marker="#binary_to_term/2">binary_to_term/2</seealso>.</p>
</desc>
</func>
<func>
<name name="binary_to_term" arity="2"/>
<fsummary>Decode an Erlang external term format binary</fsummary>
<desc>
<p>As <c>binary_to_term/1</c>, but takes options that affect decoding
of the binary.</p>
<taglist>
<tag><c>safe</c></tag>
<item>
<p>Use this option when receiving binaries from an untrusted
source.</p>
<p>When enabled, it prevents decoding data that may be used to
attack the Erlang system. In the event of receiving unsafe
data, decoding fails with a badarg error.</p>
<p>Currently, this prevents creation of new atoms directly,
creation of new atoms indirectly (as they are embedded in
certain structures like pids, refs, funs, etc.), and creation of
new external function references. None of those resources are
currently garbage collected, so unchecked creation of them can
exhaust available memory.</p>
</item>
</taglist>
<p>Failure: <c>badarg</c> if <c>safe</c> is specified and unsafe data
is decoded.</p>
<p>See also
<seealso marker="#term_to_binary/1">term_to_binary/1</seealso>,
<seealso marker="#binary_to_term/1">binary_to_term/1</seealso>,
and <seealso marker="#list_to_existing_atom/1">
list_to_existing_atom/1</seealso>.</p>
</desc>
</func>
<func>
<name name="bit_size" arity="1"/>
<fsummary>Return the size of a bitstring</fsummary>
<desc>
<p>Returns an integer which is the size in bits of <c><anno>Bitstring</anno></c>.</p>
<pre>
> <input>bit_size(<<433:16,3:3>>).</input>
19
> <input>bit_size(<<1,2,3>>).</input>
24</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="bump_reductions" arity="1"/>
<fsummary>Increment the reduction counter</fsummary>
<desc>
<p>This implementation-dependent function increments
the reduction counter for the calling process. In the Beam
emulator, the reduction counter is normally incremented by
one for each function and BIF call, and a context switch is
forced when the counter reaches the maximum number of reductions
for a process (2000 reductions in R12B).</p>
<warning>
<p>This BIF might be removed in a future version of the Beam
machine without prior warning. It is unlikely to be
implemented in other Erlang implementations.</p>
</warning>
</desc>
</func>
<func>
<name name="byte_size" arity="1"/>
<fsummary>Return the size of a bitstring (or binary)</fsummary>
<desc>
<p>Returns an integer which is the number of bytes needed to contain
<c><anno>Bitstring</anno></c>. (That is, if the number of bits in <c><anno>Bitstring</anno></c> is not
divisible by 8, the resulting number of bytes will be rounded <em>up</em>.)</p>
<pre>
> <input>byte_size(<<433:16,3:3>>).</input>
3
> <input>byte_size(<<1,2,3>>).</input>
3</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="cancel_timer" arity="2"/>
<fsummary>Cancel a timer</fsummary>
<desc>
<p>
Cancels a timer that has been created by either
<seealso marker="#start_timer/4"><c>erlang:start_timer()</c></seealso>,
or <seealso marker="#send_after/4"><c>erlang:send_after()</c></seealso>.
<c><anno>TimerRef</anno></c> identifies the timer, and
was returned by the BIF that created the timer.
</p>
<p>Currently available <c><anno>Option</anno></c>s:</p>
<taglist>
<tag><c>{async, Async}</c></tag>
<item>
<p>
Asynchronous request for cancellation. <c>Async</c>
defaults to <c>false</c> which will cause the
cancellation to be performed synchronously. When
<c>Async</c> is set to <c>true</c>, the cancel
operation will be performed asynchronously. That is,
<c>erlang:cancel_timer()</c> will send an asynchronous
request for cancellation to the timer service that
manages the timer, and then return <c>ok</c>.
</p>
</item>
<tag><c>{info, Info}</c></tag>
<item>
<p>
Request information about the <c><anno>Result</anno></c>
of the cancellation. <c>Info</c> defaults to <c>true</c>
which means that the <c><anno>Result</anno></c> will
be given. When <c>Info</c> is set to <c>false</c>, no
information about the result of the cancellation
will be given. When the operation is performed</p>
<taglist>
<tag>synchronously</tag>
<item>
<p>
If <c>Info</c> is <c>true</c>, the <c>Result</c> will
returned by <c>erlang:cancel_timer()</c>; otherwise,
<c>ok</c> will be returned.
</p>
</item>
<tag>asynchronously</tag>
<item>
<p>
If <c>Info</c> is <c>true</c>, a message on the form
<c>{cancel_timer, <anno>TimerRef</anno>,
<anno>Result</anno>}</c> will be sent to the
caller of <c>erlang:cancel_timer()</c> when the
cancellation operation has been performed; otherwise,
no message will be sent.
</p>
</item>
</taglist>
</item>
</taglist>
<p>
More <c><anno>Option</anno></c>s may be added in the future.
</p>
<p>
When the <c><anno>Result</anno></c> equals <c>false</c>, a
timer corresponding to <c><anno>TimerRef</anno></c> could not
be found. This can be either because the timer had expired,
already had been canceled, or because <c><anno>TimerRef</anno></c>
never has corresponded to a timer. If the timer has expired,
the timeout message has been sent, but it does not tell you
whether or not it has arrived at its destination yet. When the
<c><anno>Result</anno></c> is an integer, it represents the
time in milli-seconds left until the timer will expire.
</p>
<note>
<p>
The timer service that manages the timer may be co-located
with another scheduler than the scheduler that the calling
process is executing on. If this is the case, communication
with the timer service will take much longer time than if it
is located locally. If the calling process is in critical
path, and can do other things while waiting for the result
of this operation, or is not interested in the result of
the operation, you want to use the <c>{async, true}</c>
option. If using the <c>{async, false}</c> option, the calling
process will be blocked until the operation has been
performed.
</p>
</note>
<p>See also
<seealso marker="#send_after/4"><c>erlang:send_after/4</c></seealso>,
<seealso marker="#start_timer/4"><c>erlang:start_timer/4</c></seealso>,
and
<seealso marker="#read_timer/2"><c>erlang:read_timer/2</c></seealso>.</p>
</desc>
</func>
<func>
<name name="cancel_timer" arity="1"/>
<fsummary>Cancel a timer</fsummary>
<desc>
<p>Cancels a timer. The same as calling
<seealso marker="#cancel_timer/2"><c>erlang:cancel_timer(TimerRef,
[])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="check_old_code" arity="1"/>
<fsummary>Check if a module has old code</fsummary>
<desc>
<p>Returns <c>true</c> if the <c><anno>Module</anno></c> has old code,
and <c>false</c> otherwise.</p>
<p>See also <seealso marker="kernel:code">code(3)</seealso>.</p>
</desc>
</func>
<func>
<name name="check_process_code" arity="2"/>
<fsummary>Check if a process is executing old code for a module</fsummary>
<desc>
<p>The same as
<seealso marker="#check_process_code/3"><c>erlang:check_process_code(<anno>Pid</anno>,
<anno>Module</anno>, [])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="check_process_code" arity="3"/>
<fsummary>Check if a process is executing old code for a module</fsummary>
<desc>
<p>Check if the node local process identified by <c><anno>Pid</anno></c>
is executing old code for <c><anno>Module</anno></c>.</p>
<p>Currently available <c><anno>Option</anno>s</c>:</p>
<taglist>
<tag><c>{allow_gc, boolean()}</c></tag>
<item>
Determines if garbage collection is allowed when performing
the operation. If <c>{allow_gc, false}</c> is passed, and
a garbage collection is needed in order to determine the
result of the operation, the operation will be aborted
(see information on <c><anno>CheckResult</anno></c> below).
The default is to allow garbage collection, i.e.,
<c>{allow_gc, true}</c>.
</item>
<tag><c>{async, RequestId}</c></tag>
<item>
The <c>check_process_code/3</c> function will return
the value <c>async</c> immediately after the request
has been sent. When the request has been processed, the
process that called this function will be passed a
message on the form:<br/>
<c>{check_process_code, <anno>RequestId</anno>, <anno>CheckResult</anno>}</c>.
</item>
</taglist>
<p>If <c><anno>Pid</anno></c> equals <c>self()</c>, and
no <c>async</c> option has been passed, the operation will
be performed at once. In all other cases a request for
the operation will be sent to the process identified by
<c><anno>Pid</anno></c>, and will be handled when
appropriate. If no <c>async</c> option has been passed,
the caller will block until <c><anno>CheckResult</anno></c>
is available and can be returned.</p>
<p><c><anno>CheckResult</anno></c> informs about the result of
the request:</p>
<taglist>
<tag><c>true</c></tag>
<item>
The process identified by <c><anno>Pid</anno></c> is
executing old code for <c><anno>Module</anno></c>.
That is, the current call of the process executes old
code for this module, or the process has references
to old code for this module, or the process contains
funs that references old code for this module.
</item>
<tag><c>false</c></tag>
<item>
The process identified by <c><anno>Pid</anno></c> is
not executing old code for <c><anno>Module</anno></c>.
</item>
<tag><c>aborted</c></tag>
<item>
The operation was aborted since the process needed to
be garbage collected in order to determine the result
of the operation, and the operation was requested
by passing the <c>{allow_gc, false}</c> option.</item>
</taglist>
<p>See also <seealso marker="kernel:code">code(3)</seealso>.</p>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Pid</anno></c> is not a node local process identifier.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Module</anno></c> is not an atom.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>OptionList</anno></c> is not a valid list of options.
</item>
</taglist>
</desc>
</func>
<func>
<name name="convert_time_unit" arity="3"/>
<fsummary>Convert time unit of a time value</fsummary>
<desc>
<p>Converts the <c><anno>Time</anno></c> value of time unit
<c><anno>FromUnit</anno></c> to the corresponding
<c><anno>ConvertedTime</anno></c> value of time unit
<c><anno>ToUnit</anno></c>. The result is rounded
using the floor function.</p>
<warning><p>You may lose accuracy and precision when converting
between time units. In order to minimize such loss, collect all
data at <c>native</c> time unit and do the conversion on the end
result.</p></warning>
</desc>
</func>
<func>
<name name="crc32" arity="1"/>
<fsummary>Compute crc32 (IEEE 802.3) checksum</fsummary>
<desc>
<p>Computes and returns the crc32 (IEEE 802.3 style) checksum for <c><anno>Data</anno></c>.</p>
</desc>
</func>
<func>
<name name="crc32" arity="2"/>
<fsummary>Compute crc32 (IEEE 802.3) checksum</fsummary>
<desc>
<p>Continue computing the crc32 checksum by combining
the previous checksum, <c><anno>OldCrc</anno></c>, with the checksum of
<c><anno>Data</anno></c>.</p>
<p>The following code:</p>
<code>
X = erlang:crc32(Data1),
Y = erlang:crc32(X,Data2).
</code>
<p>- would assign the same value to <c>Y</c> as this would:</p>
<code>
Y = erlang:crc32([Data1,Data2]).
</code>
</desc>
</func>
<func>
<name name="crc32_combine" arity="3"/>
<fsummary>Combine two crc32 (IEEE 802.3) checksums</fsummary>
<desc>
<p>Combines two previously computed crc32 checksums.
This computation requires the size of the data object for
the second checksum to be known.</p>
<p>The following code:</p>
<code>
Y = erlang:crc32(Data1),
Z = erlang:crc32(Y,Data2).
</code>
<p>- would assign the same value to <c>Z</c> as this would:</p>
<code>
X = erlang:crc32(Data1),
Y = erlang:crc32(Data2),
Z = erlang:crc32_combine(X,Y,iolist_size(Data2)).
</code>
</desc>
</func>
<func>
<name name="date" arity="0"/>
<fsummary>Current date</fsummary>
<desc>
<p>Returns the current date as <c>{Year, Month, Day}</c>.</p>
<p>The time zone and daylight saving time correction depend on
the underlying OS.</p>
<pre>
> <input>date().</input>
{1995,2,19}</pre>
</desc>
</func>
<func>
<name name="decode_packet" arity="3"/>
<fsummary>Extracts a protocol packet from a binary</fsummary>
<desc>
<p>Decodes the binary <c><anno>Bin</anno></c> according to the packet
protocol specified by <c><anno>Type</anno></c>. Very similar to the packet
handling done by sockets with the option {packet,<anno>Type</anno>}.</p>
<p>If an entire packet is contained in <c><anno>Bin</anno></c> it is
returned together with the remainder of the binary as
<c>{ok,<anno>Packet</anno>,<anno>Rest</anno>}</c>.</p>
<p>If <c><anno>Bin</anno></c> does not contain the entire packet,
<c>{more,<anno>Length</anno>}</c> is returned. <c><anno>Length</anno></c> is either the
expected <em>total size</em> of the packet or <c>undefined</c>
if the expected packet size is not known. <c>decode_packet</c>
can then be called again with more data added.</p>
<p>If the packet does not conform to the protocol format
<c>{error,<anno>Reason</anno>}</c> is returned.</p>
<p>The following values of <c><anno>Type</anno></c> are valid:</p>
<taglist>
<tag><c>raw | 0</c></tag>
<item>
<p>No packet handling is done. Entire binary is
returned unless it is empty.</p>
</item>
<tag><c>1 | 2 | 4</c></tag>
<item>
<p>Packets consist of a header specifying the number of
bytes in the packet, followed by that number of bytes.
The length of header can be one, two, or four bytes;
the order of the bytes is big-endian. The header
will be stripped off when the packet is returned.</p>
</item>
<tag><c>line</c></tag>
<item>
<p>A packet is a line terminated with newline. The
newline character is included in the returned packet
unless the line was truncated according to the option
<c>line_length</c>.</p>
</item>
<tag><c>asn1 | cdr | sunrm | fcgi | tpkt</c></tag>
<item>
<p>The header is <em>not</em> stripped off.</p>
<p>The meanings of the packet types are as follows:</p>
<taglist>
<tag><c>asn1</c> - ASN.1 BER</tag><item></item>
<tag><c>sunrm</c> - Sun's RPC encoding</tag><item></item>
<tag><c>cdr</c> - CORBA (GIOP 1.1)</tag><item></item>
<tag><c>fcgi</c> - Fast CGI</tag><item></item>
<tag><c>tpkt</c> - TPKT format [RFC1006]</tag><item></item>
</taglist>
</item>
<tag><c>http | httph | http_bin | httph_bin</c></tag>
<item>
<p>The Hypertext Transfer Protocol. The packets
are returned with the format according to
<c><anno>HttpPacket</anno></c> described above. A packet is either a
request, a response, a header or an end of header
mark. Invalid lines are returned as <c><anno>HttpError</anno></c>.</p>
<p>Recognized request methods and header fields are returned as atoms.
Others are returned as strings. Strings of unrecognized header fields
are formatted with only capital letters first and after hyphen characters
(like <c>"Sec-Websocket-Key"</c>).</p>
<p>The protocol type <c>http</c> should only be used for
the first line when a <c><anno>HttpRequest</anno></c> or a
<c><anno>HttpResponse</anno></c> is expected. The following calls
should use <c>httph</c> to get <c><anno>HttpHeader</anno></c>'s until
<c>http_eoh</c> is returned that marks the end of the
headers and the beginning of any following message body.</p>
<p>The variants <c>http_bin</c> and <c>httph_bin</c> will return
strings (<c>HttpString</c>) as binaries instead of lists.</p>
</item>
</taglist>
<p>The following options are available:</p>
<taglist>
<tag><c>{packet_size, integer() >= 0}</c></tag>
<item><p>Sets the max allowed size of the packet body. If
the packet header indicates that the length of the
packet is longer than the max allowed length, the packet
is considered invalid. Default is 0 which means no
size limit.</p>
</item>
<tag><c>{line_length, integer() >= 0}</c></tag>
<item><p>For packet type <c>line</c>, truncate lines longer
than the indicated length.</p>
<p>Option <c>line_length</c> also applies to <c>http*</c>
packet types as an alias for option <c>packet_size</c> in the
case when <c>packet_size</c> itself is not set. This usage is
only intended for backward compatibility.</p>
</item>
</taglist>
<pre>
> <input>erlang:decode_packet(1,<<3,"abcd">>,[]).</input>
{ok,<<"abc">>,<<"d">>}
> <input>erlang:decode_packet(1,<<5,"abcd">>,[]).</input>
{more,6}</pre>
</desc>
</func>
<func>
<name name="delete_element" arity="2"/>
<fsummary>Delete element at index in a tuple</fsummary>
<type_desc variable="Index">1..tuple_size(<anno>Tuple1</anno>)</type_desc>
<desc>
<p>
Returns a new tuple with element at <c><anno>Index</anno></c> removed from
tuple <c><anno>Tuple1</anno></c>.
</p>
<pre>
> <input>erlang:delete_element(2, {one, two, three}).</input>
{one,three}</pre>
</desc>
</func>
<func>
<name name="delete_module" arity="1"/>
<fsummary>Make the current code for a module old</fsummary>
<desc>
<p>Makes the current code for <c><anno>Module</anno></c> become old code, and
deletes all references for this module from the export table.
Returns <c>undefined</c> if the module does not exist,
otherwise <c>true</c>.</p>
<warning>
<p>This BIF is intended for the code server (see
<seealso marker="kernel:code">code(3)</seealso>) and should not be
used elsewhere.</p>
</warning>
<p>Failure: <c>badarg</c> if there is already an old version of
<c>Module</c>.</p>
</desc>
</func>
<func>
<name name="demonitor" arity="1"/>
<fsummary>Stop monitoring</fsummary>
<desc>
<p>If <c><anno>MonitorRef</anno></c> is a reference which the calling process
obtained by calling
<seealso marker="#monitor/2">monitor/2</seealso>,
this monitoring is turned off. If the monitoring is already
turned off, nothing happens.</p>
<p>Once <c>demonitor(<anno>MonitorRef</anno>)</c> has returned it is
guaranteed that no <c>{'DOWN', <anno>MonitorRef</anno>, _, _, _}</c> message
due to the monitor will be placed in the caller's message queue
in the future. A <c>{'DOWN', <anno>MonitorRef</anno>, _, _, _}</c> message
might have been placed in the caller's message queue prior to
the call, though. Therefore, in most cases, it is advisable
to remove such a <c>'DOWN'</c> message from the message queue
after monitoring has been stopped.
<seealso marker="#demonitor/2">demonitor(<anno>MonitorRef</anno>, [flush])</seealso> can be used instead of
<c>demonitor(<anno>MonitorRef</anno>)</c> if this cleanup is wanted.</p>
<note>
<p>Prior to OTP release R11B (erts version 5.5) <c>demonitor/1</c>
behaved completely asynchronous, i.e., the monitor was active
until the "demonitor signal" reached the monitored entity. This
had one undesirable effect, though. You could never know when
you were guaranteed <em>not</em> to receive a <c>DOWN</c> message
due to the monitor.</p>
<p>Current behavior can be viewed as two combined operations:
asynchronously send a "demonitor signal" to the monitored entity
and ignore any future results of the monitor. </p>
</note>
<p>Failure: It is an error if <c><anno>MonitorRef</anno></c> refers to a
monitoring started by another process. Not all such cases are
cheap to check; if checking is cheap, the call fails with
<c>badarg</c> (for example if <c><anno>MonitorRef</anno></c> is a remote
reference).</p>
</desc>
</func>
<func>
<name name="demonitor" arity="2"/>
<fsummary>Stop monitoring</fsummary>
<desc>
<p>The returned value is <c>true</c> unless <c>info</c> is part
of <c><anno>OptionList</anno></c>.
</p>
<p><c>demonitor(<anno>MonitorRef</anno>, [])</c> is equivalent to
<seealso marker="#demonitor/1">demonitor(<anno>MonitorRef</anno>)</seealso>.</p>
<p>Currently the following <c><anno>Option</anno></c>s are valid:</p>
<taglist>
<tag><c>flush</c></tag>
<item>
<p>Remove (one) <c>{_, <anno>MonitorRef</anno>, _, _, _}</c> message,
if there is one, from the caller's message queue after
monitoring has been stopped.</p>
<p>Calling <c>demonitor(<anno>MonitorRef</anno>, [flush])</c>
is equivalent to the following, but more efficient:</p>
<code type="none">
demonitor(MonitorRef),
receive
{_, MonitorRef, _, _, _} ->
true
after 0 ->
true
end</code>
</item>
<tag><c>info</c></tag>
<item>
<p>The returned value is one of the following:</p>
<taglist>
<tag><c>true</c></tag>
<item><p>The monitor was found and removed. In this case
no <c>'DOWN'</c> message due to this monitor have
been nor will be placed in the message queue
of the caller.
</p>
</item>
<tag><c>false</c></tag>
<item><p>The monitor was not found and could not be removed.
This probably because someone already has placed a
<c>'DOWN'</c> message corresponding to this monitor
in the caller's message queue.
</p>
</item>
</taglist>
<p>If the <c>info</c> option is combined with the <c>flush</c>
option, <c>false</c> will be returned if a flush was needed;
otherwise, <c>true</c>.
</p>
</item>
</taglist>
<note>
<p>More options may be added in the future.</p>
</note>
<p>Failure: <c>badarg</c> if <c><anno>OptionList</anno></c> is not a list, or
if <c><anno>Option</anno></c> is not a valid option, or the same failure as for
<seealso marker="#demonitor/1">demonitor/1</seealso></p>
</desc>
</func>
<func>
<name name="disconnect_node" arity="1"/>
<fsummary>Force the disconnection of a node</fsummary>
<desc>
<p>Forces the disconnection of a node. This will appear to
the node <c><anno>Node</anno></c> as if the local node has crashed. This
BIF is mainly used in the Erlang network authentication
protocols. Returns <c>true</c> if disconnection succeeds,
otherwise <c>false</c>. If the local node is not alive,
the function returns <c>ignored</c>.</p>
</desc>
</func>
<func>
<name name="display" arity="1"/>
<fsummary>Print a term on standard output</fsummary>
<desc>
<p>Prints a text representation of <c><anno>Term</anno></c> on the standard
output.</p>
<warning>
<p>This BIF is intended for debugging only.</p>
</warning>
</desc>
</func>
<func>
<name name="element" arity="2"/>
<type_desc variable="N">1..tuple_size(<anno>Tuple</anno>)</type_desc>
<fsummary>Get Nth element of a tuple</fsummary>
<desc>
<p>Returns the <c><anno>N</anno></c>th element (numbering from 1) of
<c><anno>Tuple</anno></c>.</p>
<pre>
> <input>element(2, {a, b, c}).</input>
b</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="erase" arity="0"/>
<fsummary>Return and delete the process dictionary</fsummary>
<desc>
<p>Returns the process dictionary and deletes it.</p>
<pre>
> <input>put(key1, {1, 2, 3}),</input>
<input>put(key2, [a, b, c]),</input>
<input>erase().</input>
[{key1,{1,2,3}},{key2,[a,b,c]}]</pre>
</desc>
</func>
<func>
<name name="erase" arity="1"/>
<fsummary>Return and delete a value from the process dictionary</fsummary>
<desc>
<p>Returns the value <c><anno>Val</anno></c> associated with <c><anno>Key</anno></c> and
deletes it from the process dictionary. Returns
<c>undefined</c> if no value is associated with <c><anno>Key</anno></c>.</p>
<pre>
> <input>put(key1, {merry, lambs, are, playing}),</input>
<input>X = erase(key1),</input>
<input>{X, erase(key1)}.</input>
{{merry,lambs,are,playing},undefined}</pre>
</desc>
</func>
<func>
<name name="error" arity="1"/>
<fsummary>Stop execution with a given reason</fsummary>
<desc>
<p>Stops the execution of the calling process with the reason
<c><anno>Reason</anno></c>, where <c><anno>Reason</anno></c> is any term. The actual
exit reason will be <c>{<anno>Reason</anno>, Where}</c>, where <c>Where</c>
is a list of the functions most recently called (the current
function first). Since evaluating this function causes
the process to terminate, it has no return value.</p>
<pre>
> <input>catch error(foobar).</input>
{'EXIT',{foobar,[{erl_eval,do_apply,5},
{erl_eval,expr,5},
{shell,exprs,6},
{shell,eval_exprs,6},
{shell,eval_loop,3}]}}</pre>
</desc>
</func>
<func>
<name name="error" arity="2"/>
<fsummary>Stop execution with a given reason</fsummary>
<desc>
<p>Stops the execution of the calling process with the reason
<c><anno>Reason</anno></c>, where <c><anno>Reason</anno></c> is any term. The actual
exit reason will be <c>{<anno>Reason</anno>, Where}</c>, where <c>Where</c>
is a list of the functions most recently called (the current
function first). <c><anno>Args</anno></c> is expected to be the list of
arguments for the current function; in Beam it will be used
to provide the actual arguments for the current function in
the <c>Where</c> term. Since evaluating this function causes
the process to terminate, it has no return value.</p>
</desc>
</func>
<func>
<name name="exit" arity="1"/>
<fsummary>Stop execution with a given reason</fsummary>
<desc>
<p>Stops the execution of the calling process with the exit
reason <c><anno>Reason</anno></c>, where <c><anno>Reason</anno></c> is any term. Since
evaluating this function causes the process to terminate, it
has no return value.</p>
<pre>
> <input>exit(foobar).</input>
** exception exit: foobar
> <input>catch exit(foobar).</input>
{'EXIT',foobar}</pre>
</desc>
</func>
<func>
<name name="exit" arity="2"/>
<fsummary>Send an exit signal to a process or a port</fsummary>
<desc>
<p>Sends an exit signal with exit reason <c><anno>Reason</anno></c> to
the process or port identified by <c><anno>Pid</anno></c>.</p>
<p>The following behavior apply if <c><anno>Reason</anno></c> is any term
except <c>normal</c> or <c>kill</c>:</p>
<p>If <c><anno>Pid</anno></c> is not trapping exits, <c><anno>Pid</anno></c> itself will
exit with exit reason <c><anno>Reason</anno></c>. If <c><anno>Pid</anno></c> is trapping
exits, the exit signal is transformed into a message
<c>{'EXIT', From, <anno>Reason</anno>}</c> and delivered to the message
queue of <c><anno>Pid</anno></c>. <c>From</c> is the pid of the process
which sent the exit signal. See also
<seealso marker="#process_flag/2">process_flag/2</seealso>.</p>
<p>If <c><anno>Reason</anno></c> is the atom <c>normal</c>, <c><anno>Pid</anno></c> will
not exit. If it is trapping exits, the exit signal is
transformed into a message <c>{'EXIT', From, normal}</c>
and delivered to its message queue.</p>
<p>If <c><anno>Reason</anno></c> is the atom <c>kill</c>, that is if
<c>exit(<anno>Pid</anno>, kill)</c> is called, an untrappable exit signal
is sent to <c><anno>Pid</anno></c> which will unconditionally exit with
exit reason <c>killed</c>.</p>
</desc>
</func>
<func>
<name name="external_size" arity="1"/>
<fsummary>Calculate the maximum size for a term encoded in the Erlang
external term format</fsummary>
<desc>
<p>Calculates, without doing the encoding, the maximum byte size for
a term encoded in the Erlang external term format. The following
condition applies always:</p>
<p>
<pre>
> <input>Size1 = byte_size(term_to_binary(<anno>Term</anno>)),</input>
> <input>Size2 = erlang:external_size(<anno>Term</anno>),</input>
> <input>true = Size1 =< Size2.</input>
true
</pre>
</p>
<p>This is equivalent to a call to: <code>erlang:external_size(<anno>Term</anno>, [])
</code></p>
</desc>
</func>
<func>
<name name="external_size" arity="2"/>
<fsummary>Calculate the maximum size for a term encoded in the Erlang
external term format</fsummary>
<desc>
<p>Calculates, without doing the encoding, the maximum byte size for
a term encoded in the Erlang external term format. The following
condition applies always:</p>
<p>
<pre>
> <input>Size1 = byte_size(term_to_binary(<anno>Term</anno>, <anno>Options</anno>)),</input>
> <input>Size2 = erlang:external_size(<anno>Term</anno>, <anno>Options</anno>),</input>
> <input>true = Size1 =< Size2.</input>
true
</pre>
</p>
<p>The option <c>{minor_version, <anno>Version</anno>}</c> specifies how floats
are encoded. See
<seealso marker="#term_to_binary/2">term_to_binary/2</seealso> for
a more detailed description.
</p>
</desc>
</func>
<func>
<name name="float" arity="1"/>
<fsummary>Convert a number to a float</fsummary>
<desc>
<p>Returns a float by converting <c><anno>Number</anno></c> to a float.</p>
<pre>
> <input>float(55).</input>
55.0</pre>
<p>Allowed in guard tests.</p>
<note>
<p>Note that if used on the top-level in a guard, it will
test whether the argument is a floating point number; for
clarity, use
<seealso marker="#is_float/1">is_float/1</seealso> instead.</p>
<p>When <c>float/1</c> is used in an expression in a guard,
such as '<c>float(A) == 4.0</c>', it converts a number as
described above.</p>
</note>
</desc>
</func>
<func>
<name name="float_to_binary" arity="1"/>
<fsummary>Text representation of a float</fsummary>
<desc>
<p>The same as <c>float_to_binary(<anno>Float</anno>,[{scientific,20}])</c>.</p>
</desc>
</func>
<func>
<name name="float_to_binary" arity="2"/>
<fsummary>Text representation of a float formatted using given options</fsummary>
<desc>
<p>Returns a binary which corresponds to the text
representation of <c><anno>Float</anno></c> using fixed decimal
point formatting. The <c><anno>Options</anno></c> behave in the same
way as <seealso marker="#float_to_list/2">float_to_list/2</seealso>.
</p>
<pre>
> <input>float_to_binary(7.12, [{decimals, 4}]).</input>
<<"7.1200">>
> <input>float_to_binary(7.12, [{decimals, 4}, compact]).</input>
<<"7.12">></pre>
</desc>
</func>
<func>
<name name="float_to_list" arity="1"/>
<fsummary>Text representation of a float</fsummary>
<desc>
<p>The same as <c>float_to_list(<anno>Float</anno>,[{scientific,20}])</c>.</p>
</desc>
</func>
<func>
<name name="float_to_list" arity="2"/>
<fsummary>Text representation of a float formatted using given options</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c>Float</c> using fixed decimal point formatting.
When <c>decimals</c> option is specified
the returned value will contain at most <c>Decimals</c> number of
digits past the decimal point. If the number doesn't fit in the
internal static buffer of 256 bytes, the function throws <c>badarg</c>.
When <c>compact</c> option is provided
the trailing zeros at the end of the list are truncated (this option is
only meaningful together with the <c>decimals</c> option). When
<c>scientific</c> option is provided, the float will be formatted using
scientific notation with <c>Decimals</c> digits of precision. If
<c>Options</c> is <c>[]</c> the function behaves like
<c><seealso marker="#float_to_list/1">float_to_list/1</seealso></c>.
</p>
<pre>
> <input>float_to_list(7.12, [{decimals, 4}]).</input>
"7.1200"
> <input>float_to_list(7.12, [{decimals, 4}, compact]).</input>
"7.12"</pre>
</desc>
</func>
<func>
<name name="fun_info" arity="1"/>
<fsummary>Information about a fun</fsummary>
<desc>
<p>Returns a list containing information about the fun
<c><anno>Fun</anno></c>. Each element of the list is a tuple. The order of
the tuples is not defined, and more tuples may be added in a
future release.</p>
<warning>
<p>This BIF is mainly intended for debugging, but it can
occasionally be useful in library functions that might need
to verify, for instance, the arity of a fun.</p>
</warning>
<p>There are two types of funs with slightly different
semantics:</p>
<p>A fun created by <c>fun M:F/A</c> is called an
<em>external</em> fun. Calling it will always call the
function <c>F</c> with arity <c>A</c> in the latest code for
module <c>M</c>. Note that module <c>M</c> does not even need
to be loaded when the fun <c>fun M:F/A</c> is created.</p>
<p>All other funs are called <em>local</em>. When a local fun
is called, the same version of the code that created the fun
will be called (even if newer version of the module has been
loaded).</p>
<p>The following elements will always be present in the list
for both local and external funs:</p>
<taglist>
<tag><c>{type, Type}</c></tag>
<item>
<p><c>Type</c> is either <c>local</c> or <c>external</c>.</p>
</item>
<tag><c>{module, Module}</c></tag>
<item>
<p><c>Module</c> (an atom) is the module name.</p>
<p>If <c>Fun</c> is a local fun, <c>Module</c> is the module
in which the fun is defined.</p>
<p>If <c>Fun</c> is an external fun, <c>Module</c> is the
module that the fun refers to.</p>
</item>
<tag><c>{name, Name}</c></tag>
<item>
<p><c>Name</c> (an atom) is a function name.</p>
<p>If <c>Fun</c> is a local fun, <c>Name</c> is the name
of the local function that implements the fun.
(This name was generated by the compiler, and is generally
only of informational use. As it is a local function, it
is not possible to call it directly.)
If no code is currently loaded for the fun, <c>[]</c>
will be returned instead of an atom.</p>
<p>If <c>Fun</c> is an external fun, <c>Name</c> is the name
of the exported function that the fun refers to.</p>
</item>
<tag><c>{arity, Arity}</c></tag>
<item>
<p><c>Arity</c> is the number of arguments that the fun
should be called with.</p>
</item>
<tag><c>{env, Env}</c></tag>
<item>
<p><c>Env</c> (a list) is the environment or free variables
for the fun. (For external funs, the returned list is
always empty.)</p>
</item>
</taglist>
<p>The following elements will only be present in the list if
<c>Fun</c> is local:</p>
<taglist>
<tag><c>{pid, Pid}</c></tag>
<item>
<p><c>Pid</c> is the pid of the process that originally
created the fun.</p>
</item>
<tag><c>{index, Index}</c></tag>
<item>
<p><c>Index</c> (an integer) is an index into the module's
fun table.</p>
</item>
<tag><c>{new_index, Index}</c></tag>
<item>
<p><c>Index</c> (an integer) is an index into the module's
fun table.</p>
</item>
<tag><c>{new_uniq, Uniq}</c></tag>
<item>
<p><c>Uniq</c> (a binary) is a unique value for this fun.
It is calculated from the compiled code for the entire module.</p>
</item>
<tag><c>{uniq, Uniq}</c></tag>
<item>
<p><c>Uniq</c> (an integer) is a unique value for this fun.
Starting in the R15 release, this integer is calculated from
the compiled code for the entire module. Before R15, this
integer was based on only the body of the fun.
</p>
</item>
</taglist>
</desc>
</func>
<func>
<name name="fun_info" arity="2"/>
<type name="fun_info_item"/>
<fsummary>Information about a fun</fsummary>
<desc>
<p>Returns information about <c><anno>Fun</anno></c> as specified by
<c><anno>Item</anno></c>, in the form <c>{<anno>Item</anno>,<anno>Info</anno>}</c>.</p>
<p>For any fun, <c><anno>Item</anno></c> can be any of the atoms
<c>module</c>, <c>name</c>, <c>arity</c>, <c>env</c>, or <c>type</c>.</p>
<p>For a local fun, <c><anno>Item</anno></c> can also be any of the atoms
<c>index</c>, <c>new_index</c>, <c>new_uniq</c>,
<c>uniq</c>, and <c>pid</c>. For an external fun, the value
of any of these items is always the atom <c>undefined</c>.</p>
<p>See
<seealso marker="#fun_info/1">erlang:fun_info/1</seealso>.</p>
</desc>
</func>
<func>
<name name="fun_to_list" arity="1"/>
<fsummary>Text representation of a fun</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c><anno>Fun</anno></c>.</p>
</desc>
</func>
<func>
<name name="function_exported" arity="3"/>
<fsummary>Check if a function is exported and loaded</fsummary>
<desc>
<p>Returns <c>true</c> if the module <c><anno>Module</anno></c> is loaded
and contains an exported function <c><anno>Function</anno>/<anno>Arity</anno></c>,
or if there is a BIF (a built-in function implemented in C)
with the given name; otherwise returns <c>false</c>.</p>
<note><p>This function used to return false for built-in
functions before the 18.0 release.</p></note>
</desc>
</func>
<func>
<name name="garbage_collect" arity="0"/>
<fsummary>Force an immediate garbage collection of the calling process</fsummary>
<desc>
<p>Forces an immediate garbage collection of the currently
executing process. The function should not be used, unless
it has been noticed -- or there are good reasons to suspect --
that the spontaneous garbage collection will occur too late
or not at all. Improper use may seriously degrade system
performance.</p>
</desc>
</func>
<func>
<name name="garbage_collect" arity="1"/>
<fsummary>Garbage collect a process</fsummary>
<desc>
<p>The same as
<seealso marker="#garbage_collect/2"><c>garbage_collect(<anno>Pid</anno>, [])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="garbage_collect" arity="2"/>
<fsummary>Garbage collect a process</fsummary>
<desc>
<p>Garbage collect the node local process identified by
<c><anno>Pid</anno></c>.</p>
<p>Currently available <c><anno>Option</anno></c>s:</p>
<taglist>
<tag><c>{async, RequestId}</c></tag>
<item>
The <c>garbage_collect/2</c> function will return
the value <c>async</c> immediately after the request
has been sent. When the request has been processed, the
process that called this function will be passed a
message on the form:<br/>
<c>{garbage_collect, <anno>RequestId</anno>, <anno>GCResult</anno>}</c>.
</item>
</taglist>
<p>If <c><anno>Pid</anno></c> equals <c>self()</c>, and
no <c>async</c> option has been passed, the garbage
collection will be performed at once, i.e. the same as
calling
<seealso marker="#garbage_collect/0">garbage_collect/0</seealso>.
In all other cases a request for garbage collection will
be sent to the process identified by <c><anno>Pid</anno></c>,
and will be handled when appropriate. If no <c>async</c>
option has been passed, the caller will block until
<c><anno>GCResult</anno></c> is available and can be
returned.</p>
<p><c><anno>GCResult</anno></c> informs about the result of
the garbage collection request:</p>
<taglist>
<tag><c>true</c></tag>
<item>
The process identified by <c><anno>Pid</anno></c> has
been garbage collected.
</item>
<tag><c>false</c></tag>
<item>
No garbage collection was performed. This since the
the process identified by <c><anno>Pid</anno></c>
terminated before the request could be satisfied.
</item>
</taglist>
<p>Note that the same caveats as for
<seealso marker="#garbage_collect/0">garbage_collect/0</seealso>
apply.</p>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Pid</anno></c> is not a node local process identifier.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>OptionList</anno></c> is not a valid list of options.
</item>
</taglist>
</desc>
</func>
<func>
<name name="get" arity="0"/>
<fsummary>Return the process dictionary</fsummary>
<desc>
<p>Returns the process dictionary as a list of
<c>{<anno>Key</anno>, <anno>Val</anno>}</c> tuples.</p>
<pre>
> <input>put(key1, merry),</input>
<input>put(key2, lambs),</input>
<input>put(key3, {are, playing}),</input>
<input>get().</input>
[{key1,merry},{key2,lambs},{key3,{are,playing}}]</pre>
</desc>
</func>
<func>
<name name="get" arity="1"/>
<fsummary>Return a value from the process dictionary</fsummary>
<desc>
<p>Returns the value <c><anno>Val</anno></c> associated with <c><anno>Key</anno></c> in
the process dictionary, or <c>undefined</c> if <c><anno>Key</anno></c>
does not exist.</p>
<pre>
> <input>put(key1, merry),</input>
<input>put(key2, lambs),</input>
<input>put({any, [valid, term]}, {are, playing}),</input>
<input>get({any, [valid, term]}).</input>
{are,playing}</pre>
</desc>
</func>
<func>
<name name="get_cookie" arity="0"/>
<fsummary>Get the magic cookie of the local node</fsummary>
<desc>
<p>Returns the magic cookie of the local node, if the node is
alive; otherwise the atom <c>nocookie</c>.</p>
</desc>
</func>
<func>
<name name="get_keys" arity="0"/>
<fsummary>Return a list of all keys from the process dictionary</fsummary>
<desc>
<p>Returns a list of keys all keys present in the process dictionary.</p>
<pre>
> <input>put(dog, {animal,1}),</input>
<input>put(cow, {animal,2}),</input>
<input>put(lamb, {animal,3}),</input>
<input>get_keys().</input>
[dog,cow,lamb]</pre>
</desc>
</func>
<func>
<name name="get_keys" arity="1"/>
<fsummary>Return a list of keys from the process dictionary</fsummary>
<desc>
<p>Returns a list of keys which are associated with the value
<c><anno>Val</anno></c> in the process dictionary.</p>
<pre>
> <input>put(mary, {1, 2}),</input>
<input>put(had, {1, 2}),</input>
<input>put(a, {1, 2}),</input>
<input>put(little, {1, 2}),</input>
<input>put(dog, {1, 3}),</input>
<input>put(lamb, {1, 2}),</input>
<input>get_keys({1, 2}).</input>
[mary,had,a,little,lamb]</pre>
</desc>
</func>
<func>
<name name="get_stacktrace" arity="0"/>
<fsummary>Get the call stack back-trace of the last exception</fsummary>
<type name="stack_item"/>
<desc>
<p>Get the call stack back-trace (<em>stacktrace</em>) of the last
exception in the calling process as a list of
<c>{<anno>Module</anno>,<anno>Function</anno>,<anno>Arity</anno>,<anno>Location</anno>}</c> tuples.
The <c><anno>Arity</anno></c> field in the first tuple may be the argument
list of that function call instead of an arity integer,
depending on the exception.</p>
<p>If there has not been any exceptions in a process, the
stacktrace is <c>[]</c>. After a code change for the process,
the stacktrace may also be reset to [].</p>
<p>The stacktrace is the same data as the <c>catch</c> operator
returns, for example:</p>
<p><c>{'EXIT',{badarg,Stacktrace}} = catch abs(x)</c></p>
<p><c><anno>Location</anno></c> is a (possibly empty) list of two-tuples that
may indicate the location in the source code of the function.
The first element is an atom that describes the type of
information in the second element. Currently the following
items may occur:</p>
<taglist>
<tag><c>file</c></tag>
<item>
<p>The second element of the tuple is a string (list of
characters) representing the filename of the source file
of the function.</p>
</item>
<tag><c>line</c></tag>
<item>
<p>The second element of the tuple is the line number
(an integer greater than zero) in the source file
where the exception occurred or the function was called.</p>
</item>
</taglist>
<p>See also
<seealso marker="#error/1">erlang:error/1</seealso> and
<seealso marker="#error/2">erlang:error/2</seealso>.</p>
</desc>
</func>
<func>
<name name="group_leader" arity="0"/>
<fsummary>Get the group leader for the calling process</fsummary>
<desc>
<p>Returns the pid of the group leader for the process which
evaluates the function.</p>
<p>Every process is a member of some process group and all
groups have a <em>group leader</em>. All IO from the group
is channeled to the group leader. When a new process is
spawned, it gets the same group leader as the spawning
process. Initially, at system start-up, <c>init</c> is both
its own group leader and the group leader of all processes.</p>
</desc>
</func>
<func>
<name name="group_leader" arity="2"/>
<fsummary>Set the group leader for a process</fsummary>
<desc>
<p>Sets the group leader of <c><anno>Pid</anno></c> to <c><anno>GroupLeader</anno></c>.
Typically, this is used when a processes started from a
certain shell should have another group leader than
<c>init</c>.</p>
<p>See also
<seealso marker="#group_leader/0">group_leader/0</seealso>.</p>
</desc>
</func>
<func>
<name name="halt" arity="0"/>
<fsummary>Halt the Erlang runtime system and indicate normal exit to the calling environment</fsummary>
<desc>
<p>The same as
<seealso marker="#halt/2"><c>halt(0, [])</c></seealso>.</p>
<pre>
> <input>halt().</input>
os_prompt% </pre>
</desc>
</func>
<func>
<name name="halt" arity="1"/>
<fsummary>Halt the Erlang runtime system</fsummary>
<desc>
<p>The same as
<seealso marker="#halt/2"><c>halt(<anno>Status</anno>, [])</c></seealso>.</p>
<pre>
> <input>halt(17).</input>
os_prompt% <input>echo $?</input>
17
os_prompt% </pre>
</desc>
</func>
<func>
<name name="halt" arity="2"/>
<fsummary>Halt the Erlang runtime system</fsummary>
<desc>
<p><c><anno>Status</anno></c> must be a non-negative integer, a string,
or the atom <c>abort</c>.
Halts the Erlang runtime system. Has no return value.
Depending on <c><anno>Status</anno></c>:
</p>
<taglist>
<tag>integer()</tag>
<item>The runtime system exits with the integer value <c><anno>Status</anno></c>
as status code to the calling environment (operating system).
</item>
<tag>string()</tag>
<item>An erlang crash dump is produced with <c><anno>Status</anno></c> as slogan,
and then the runtime system exits with status code <c>1</c>.
</item>
<tag><c>abort</c></tag>
<item>
The runtime system aborts producing a core dump, if that is
enabled in the operating system.
</item>
</taglist>
<p>Note that on many platforms, only the status codes 0-255 are
supported by the operating system.
</p>
<p>For integer <c><anno>Status</anno></c> the Erlang runtime system closes all ports
and allows async threads to finish their operations before exiting.
To exit without such flushing use
<c><anno>Option</anno></c> as <c>{flush,false}</c>.
</p>
<p>For statuses <c>string()</c> and <c>abort</c> the <c>flush</c>
option is ignored and flushing is <em>not</em> done.
</p>
</desc>
</func>
<func>
<name name="hash" arity="2"/>
<fsummary>Hash function (deprecated)</fsummary>
<desc>
<p>Returns a hash value for <c><anno>Term</anno></c> within the range
<c>1..<anno>Range</anno></c>. The allowed range is 1..2^27-1.</p>
<warning>
<p>This BIF is deprecated as the hash value may differ on
different architectures. Also the hash values for integer
terms larger than 2^27 as well as large binaries are very
poor. The BIF is retained for backward compatibility
reasons (it may have been used to hash records into a file),
but all new code should use one of the BIFs
<c>erlang:phash/2</c> or <c>erlang:phash2/1,2</c> instead.</p>
</warning>
</desc>
</func>
<func>
<name name="hd" arity="1"/>
<fsummary>Head of a list</fsummary>
<desc>
<p>Returns the head of <c><anno>List</anno></c>, that is, the first element.</p>
<pre>
> <input>hd([1,2,3,4,5]).</input>
1</pre>
<p>Allowed in guard tests.</p>
<p>Failure: <c>badarg</c> if <c><anno>List</anno></c> is the empty list [].</p>
</desc>
</func>
<func>
<name name="hibernate" arity="3"/>
<fsummary>Hibernate a process until a message is sent to it</fsummary>
<desc>
<p>Puts the calling process into a wait state where its memory
allocation has been reduced as much as possible, which is
useful if the process does not expect to receive any messages
in the near future.</p>
<p>The process will be awaken when a message is sent to it, and
control will resume in <c><anno>Module</anno>:<anno>Function</anno></c> with
the arguments given by <c><anno>Args</anno></c> with the call stack
emptied, meaning that the process will terminate when that
function returns. Thus <c>erlang:hibernate/3</c> will never
return to its caller.</p>
<p>If the process has any message in its message queue,
the process will be awaken immediately in the same way as
described above.</p>
<p>In more technical terms, what <c>erlang:hibernate/3</c> does
is the following. It discards the call stack for the process.
Then it garbage collects the process. After the garbage
collection, all live data is in one continuous heap. The heap
is then shrunken to the exact same size as the live data
which it holds (even if that size is less than the minimum
heap size for the process).</p>
<p>If the size of the live data in the process is less than
the minimum heap size, the first garbage collection occurring
after the process has been awaken will ensure that the heap
size is changed to a size not smaller than the minimum heap
size.</p>
<p>Note that emptying the call stack means that any surrounding
<c>catch</c> is removed and has to be re-inserted after
hibernation. One effect of this is that processes started
using <c>proc_lib</c> (also indirectly, such as
<c>gen_server</c> processes), should use
<seealso marker="stdlib:proc_lib#hibernate/3">proc_lib:hibernate/3</seealso>
instead to ensure that the exception handler continues to work
when the process wakes up.</p>
</desc>
</func>
<func>
<name name="insert_element" arity="3"/>
<fsummary>Insert an element at index in a tuple</fsummary>
<type_desc variable="Index">1..tuple_size(<anno>Tuple1</anno>) + 1</type_desc>
<desc>
<p>
Returns a new tuple with element <c><anno>Term</anno></c> insert at position
<c><anno>Index</anno></c> in tuple <c><anno>Tuple1</anno></c>.
All elements from position <c><anno>Index</anno></c> and upwards are subsequently
pushed one step higher in the new tuple <c><anno>Tuple2</anno></c>.
</p>
<pre>
> <input>erlang:insert_element(2, {one, two, three}, new).</input>
{one,new,two,three}</pre>
</desc>
</func>
<func>
<name name="integer_to_binary" arity="1"/>
<fsummary>Text representation of an integer</fsummary>
<desc>
<p>Returns a binary which corresponds to the text
representation of <c><anno>Integer</anno></c>.</p>
<pre>
> <input>integer_to_binary(77).</input>
<<"77">></pre>
</desc>
</func>
<func>
<name name="integer_to_binary" arity="2"/>
<fsummary>Text representation of an integer</fsummary>
<desc>
<p>Returns a binary which corresponds to the text
representation of <c><anno>Integer</anno></c> in base <c><anno>Base</anno></c>.</p>
<pre>
> <input>integer_to_binary(1023, 16).</input>
<<"3FF">></pre>
</desc>
</func>
<func>
<name name="integer_to_list" arity="1"/>
<fsummary>Text representation of an integer</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c><anno>Integer</anno></c>.</p>
<pre>
> <input>integer_to_list(77).</input>
"77"</pre>
</desc>
</func>
<func>
<name name="integer_to_list" arity="2"/>
<fsummary>Text representation of an integer</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c><anno>Integer</anno></c> in base <c><anno>Base</anno></c>.</p>
<pre>
> <input>integer_to_list(1023, 16).</input>
"3FF"</pre>
</desc>
</func>
<func>
<name name="iolist_to_binary" arity="1"/>
<fsummary>Convert an iolist to a binary</fsummary>
<desc>
<p>Returns a binary which is made from the integers and
binaries in <c><anno>IoListOrBinary</anno></c>.</p>
<pre>
> <input>Bin1 = <<1,2,3>>.</input>
<<1,2,3>>
> <input>Bin2 = <<4,5>>.</input>
<<4,5>>
> <input>Bin3 = <<6>>.</input>
<<6>>
> <input>iolist_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).</input>
<<1,2,3,1,2,3,4,5,4,6>></pre>
</desc>
</func>
<func>
<name name="iolist_size" arity="1"/>
<fsummary>Size of an iolist</fsummary>
<desc>
<p>Returns an integer which is the size in bytes
of the binary that would be the result of
<c>iolist_to_binary(<anno>Item</anno>)</c>.</p>
<pre>
> <input>iolist_size([1,2|<<3,4>>]).</input>
4</pre>
</desc>
</func>
<func>
<name name="is_alive" arity="0"/>
<fsummary>Check whether the local node is alive</fsummary>
<desc>
<p>Returns <c>true</c> if the local node is alive; that is, if
the node can be part of a distributed system. Otherwise, it
returns <c>false</c>.</p>
</desc>
</func>
<func>
<name name="is_atom" arity="1"/>
<fsummary>Check whether a term is an atom</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is an atom;
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_binary" arity="1"/>
<fsummary>Check whether a term is a binary</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a binary;
otherwise returns <c>false</c>.</p>
<p>A binary always contains a complete number of bytes.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_bitstring" arity="1"/>
<fsummary>Check whether a term is a bitstring</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a bitstring (including a binary);
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_boolean" arity="1"/>
<fsummary>Check whether a term is a boolean</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is
either the atom <c>true</c> or the atom <c>false</c>
(i.e. a boolean); otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_builtin" arity="3"/>
<fsummary>Check if a function is a BIF implemented in C</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Module</anno>:<anno>Function</anno>/<anno>Arity</anno></c> is
a BIF implemented in C; otherwise returns <c>false</c>.
This BIF is useful for builders of cross reference tools.</p>
</desc>
</func>
<func>
<name name="is_float" arity="1"/>
<fsummary>Check whether a term is a float</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a floating point
number; otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_function" arity="1"/>
<fsummary>Check whether a term is a fun</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a fun; otherwise
returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_function" arity="2"/>
<fsummary>Check whether a term is a fun with a given arity</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a fun that can be
applied with <c><anno>Arity</anno></c> number of arguments; otherwise
returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_integer" arity="1"/>
<fsummary>Check whether a term is an integer</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is an integer;
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_list" arity="1"/>
<fsummary>Check whether a term is a list</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a list with
zero or more elements; otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_map" arity="1"/>
<fsummary>Check whether a term is a map</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a map;
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_number" arity="1"/>
<fsummary>Check whether a term is a number</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is either an integer or a
floating point number; otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_pid" arity="1"/>
<fsummary>Check whether a term is a pid</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a pid (process
identifier); otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_port" arity="1"/>
<fsummary>Check whether a term is a port</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a port identifier;
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_process_alive" arity="1"/>
<fsummary>Check whether a process is alive</fsummary>
<desc>
<p>
<c><anno>Pid</anno></c> must refer to a process at the local node.
Returns <c>true</c> if the process exists and is alive, that
is, is not exiting and has not exited. Otherwise, returns
<c>false</c>.
</p>
</desc>
</func>
<func>
<name name="is_record" arity="2"/>
<fsummary>Check whether a term appears to be a record</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a tuple and its first
element is <c><anno>RecordTag</anno></c>. Otherwise, returns <c>false</c>.</p>
<note>
<p>Normally the compiler treats calls to <c>is_record/2</c>
specially. It emits code to verify that <c><anno>Term</anno></c> is a
tuple, that its first element is <c><anno>RecordTag</anno></c>, and that
the size is correct. However, if the <c><anno>RecordTag</anno></c> is
not a literal atom, the <c>is_record/2</c> BIF will be
called instead and the size of the tuple will not be
verified.</p>
</note>
<p>Allowed in guard tests, if <c><anno>RecordTag</anno></c> is a literal
atom.</p>
</desc>
</func>
<func>
<name name="is_record" arity="3"/>
<fsummary>Check whether a term appears to be a record</fsummary>
<desc>
<p><c><anno>RecordTag</anno></c> must be an atom. Returns <c>true</c> if
<c><anno>Term</anno></c> is a tuple, its first element is <c><anno>RecordTag</anno></c>,
and its size is <c><anno>Size</anno></c>. Otherwise, returns <c>false</c>.</p>
<p>Allowed in guard tests, provided that <c><anno>RecordTag</anno></c> is
a literal atom and <c>Size</c> is a literal integer.</p>
<note>
<p>This BIF is documented for completeness. In most cases
<c>is_record/2</c> should be used.</p>
</note>
</desc>
</func>
<func>
<name name="is_reference" arity="1"/>
<fsummary>Check whether a term is a reference</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a reference;
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="is_tuple" arity="1"/>
<fsummary>Check whether a term is a tuple</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a tuple;
otherwise returns <c>false</c>.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="length" arity="1"/>
<fsummary>Length of a list</fsummary>
<desc>
<p>Returns the length of <c><anno>List</anno></c>.</p>
<pre>
> <input>length([1,2,3,4,5,6,7,8,9]).</input>
9</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="link" arity="1"/>
<fsummary>Create a link to another process (or port)</fsummary>
<desc>
<p>Creates a link between the calling process and another
process (or port) <c><anno>PidOrPort</anno></c>, if there is not such a link
already. If a process attempts to create a link to itself,
nothing is done. Returns <c>true</c>.</p>
<p>If <c><anno>PidOrPort</anno></c> does not exist, the behavior of the BIF depends
on if the calling process is trapping exits or not (see
<seealso marker="#process_flag/2">process_flag/2</seealso>):</p>
<list type="bulleted">
<item>If the calling process is not trapping exits, and
checking <c><anno>PidOrPort</anno></c> is cheap -- that is, if <c><anno>PidOrPort</anno></c> is
local -- <c>link/1</c> fails with reason <c>noproc</c>.</item>
<item>Otherwise, if the calling process is trapping exits,
and/or <c><anno>PidOrPort</anno></c> is remote, <c>link/1</c> returns
<c>true</c>, but an exit signal with reason <c>noproc</c>
is sent to the calling process.</item>
</list>
</desc>
</func>
<func>
<name name="list_to_atom" arity="1"/>
<fsummary>Convert from text representation to an atom</fsummary>
<desc>
<p>Returns the atom whose text representation is <c><anno>String</anno></c>.</p>
<p><c><anno>String</anno></c> may only contain ISO-latin-1
characters (i.e. numbers below 256) as the current
implementation does not allow unicode characters >= 256 in
atoms. For more information on Unicode support in atoms
see <seealso marker="erl_ext_dist#utf8_atoms">note on UTF-8 encoded atoms</seealso>
in the chapter about the external term format in the ERTS User's Guide.</p>
<pre>
> <input>list_to_atom("Erlang").</input>
'Erlang'</pre>
</desc>
</func>
<func>
<name name="list_to_binary" arity="1"/>
<fsummary>Convert a list to a binary</fsummary>
<desc>
<p>Returns a binary which is made from the integers and
binaries in <c><anno>IoList</anno></c>.</p>
<pre>
> <input>Bin1 = <<1,2,3>>.</input>
<<1,2,3>>
> <input>Bin2 = <<4,5>>.</input>
<<4,5>>
> <input>Bin3 = <<6>>.</input>
<<6>>
> <input>list_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).</input>
<<1,2,3,1,2,3,4,5,4,6>></pre>
</desc>
</func>
<func>
<name name="list_to_bitstring" arity="1"/>
<type name="bitstring_list"/>
<fsummary>Convert a list to a bitstring</fsummary>
<desc>
<p>Returns a bitstring which is made from the integers and
bitstrings in <c><anno>BitstringList</anno></c>. (The last tail in <c><anno>BitstringList</anno></c>
is allowed to be a bitstring.)</p>
<pre>
> <input>Bin1 = <<1,2,3>>.</input>
<<1,2,3>>
> <input>Bin2 = <<4,5>>.</input>
<<4,5>>
> <input>Bin3 = <<6,7:4,>>.</input>
<<6>>
> <input>list_to_bitstring([Bin1,1,[2,3,Bin2],4|Bin3]).</input>
<<1,2,3,1,2,3,4,5,4,6,7:46>></pre>
</desc>
</func>
<func>
<name name="list_to_existing_atom" arity="1"/>
<fsummary>Convert from text representation to an atom</fsummary>
<desc>
<p>Returns the atom whose text representation is <c><anno>String</anno></c>,
but only if there already exists such atom.</p>
<p>Failure: <c>badarg</c> if there does not already exist an atom
whose text representation is <c><anno>String</anno></c>.</p>
</desc>
</func>
<func>
<name name="list_to_float" arity="1"/>
<fsummary>Convert from text representation to a float</fsummary>
<desc>
<p>Returns the float whose text representation is <c><anno>String</anno></c>.</p>
<pre>
> <input>list_to_float("2.2017764e+0").</input>
2.2017764</pre>
<p>Failure: <c>badarg</c> if <c><anno>String</anno></c> contains a bad
representation of a float.</p>
</desc>
</func>
<func>
<name name="list_to_integer" arity="1"/>
<fsummary>Convert from text representation to an integer</fsummary>
<desc>
<p>Returns an integer whose text representation is
<c><anno>String</anno></c>.</p>
<pre>
> <input>list_to_integer("123").</input>
123</pre>
<p>Failure: <c>badarg</c> if <c><anno>String</anno></c> contains a bad
representation of an integer.</p>
</desc>
</func>
<func>
<name name="list_to_integer" arity="2"/>
<fsummary>Convert from text representation to an integer</fsummary>
<desc>
<p>Returns an integer whose text representation in base
<c><anno>Base</anno></c> is <c><anno>String</anno></c>.</p>
<pre>
> <input>list_to_integer("3FF", 16).</input>
1023</pre>
<p>Failure: <c>badarg</c> if <c><anno>String</anno></c> contains a bad
representation of an integer.</p>
</desc>
</func>
<func>
<name name="list_to_pid" arity="1"/>
<fsummary>Convert from text representation to a pid</fsummary>
<desc>
<p>Returns a pid whose text representation is <c><anno>String</anno></c>.</p>
<warning>
<p>This BIF is intended for debugging and for use in
the Erlang operating system. It should not be used in
application programs.</p>
</warning>
<pre>
> <input>list_to_pid("<0.4.1>").</input>
<0.4.1></pre>
<p>Failure: <c>badarg</c> if <c><anno>String</anno></c> contains a bad
representation of a pid.</p>
</desc>
</func>
<func>
<name name="list_to_tuple" arity="1"/>
<fsummary>Convert a list to a tuple</fsummary>
<desc>
<p>Returns a tuple which corresponds to <c><anno>List</anno></c>. <c><anno>List</anno></c>
can contain any Erlang terms.</p>
<pre>
> <input>list_to_tuple([share, ['Ericsson_B', 163]]).</input>
{share, ['Ericsson_B', 163]}</pre>
</desc>
</func>
<func>
<name name="load_module" arity="2"/>
<fsummary>Load object code for a module</fsummary>
<desc>
<p>If <c><anno>Binary</anno></c> contains the object code for the module
<c><anno>Module</anno></c>, this BIF loads that object code. Also, if
the code for the module <c><anno>Module</anno></c> already exists, all
export references are replaced so they point to the newly
loaded code. The previously loaded code is kept in the system
as old code, as there may still be processes which are
executing that code. It returns either
<c>{module, <anno>Module</anno>}</c>, or <c>{error, <anno>Reason</anno>}</c> if loading
fails. <c><anno>Reason</anno></c> is one of the following:</p>
<taglist>
<tag><c>badfile</c></tag>
<item>
<p>The object code in <c><anno>Binary</anno></c> has an
incorrect format <em>or</em> the object code contains code
for another module than <c><anno>Module</anno></c>.</p>
</item>
<tag><c>not_purged</c></tag>
<item>
<p><c><anno>Binary</anno></c> contains a module which cannot be loaded
because old code for this module already exists.</p>
</item>
</taglist>
<warning>
<p>This BIF is intended for the code server (see
<seealso marker="kernel:code">code(3)</seealso>) and should not be
used elsewhere.</p>
</warning>
</desc>
</func>
<func>
<name name="load_nif" arity="2"/>
<fsummary>Load NIF library</fsummary>
<desc>
<note>
<p>In releases older than OTP R14B, NIFs were an
experimental feature. Versions of OTP older than R14B might
have different and possibly incompatible NIF semantics and
interfaces. For example, in R13B03 the return value on
failure was
<c>{error,Reason,Text}</c>.</p>
</note>
<p>Loads and links a dynamic library containing native
implemented functions (NIFs) for a module. <c><anno>Path</anno></c> is a
file path to the sharable object/dynamic library file minus
the OS-dependent file extension (.so for Unix and .dll for
Windows). See <seealso marker="erl_nif">erl_nif</seealso>
on how to implement a NIF library.</p>
<p><c><anno>LoadInfo</anno></c> can be any term. It will be passed on to
the library as part of the initialization. A good practice is
to include a module version number to support future code
upgrade scenarios.</p>
<p>The call to <c>load_nif/2</c> must be made
<em>directly</em> from the Erlang code of the module that the
NIF library belongs to.</p>
<p>It returns either <c>ok</c>, or <c>{error,{<anno>Reason</anno>,Text}}</c>
if loading fails. <c><anno>Reason</anno></c> is one of the atoms below,
while <c><anno>Text</anno></c> is a human readable string that may give
some more information about the failure.</p>
<taglist>
<tag><c>load_failed</c></tag>
<item>
<p>The OS failed to load the NIF library.</p>
</item>
<tag><c>bad_lib</c></tag>
<item>
<p>The library did not fulfil the requirements as a NIF
library of the calling module.</p>
</item>
<tag><c>load | reload | upgrade</c></tag>
<item>
<p>The corresponding library callback was not successful.</p>
</item>
<tag><c>old_code</c></tag>
<item>
<p>The call to <c>load_nif/2</c> was made from the old
code of a module that has been upgraded. This is not
allowed.</p>
</item>
</taglist>
</desc>
</func>
<func>
<name name="loaded" arity="0"/>
<fsummary>List of all loaded modules</fsummary>
<desc>
<p>Returns a list of all loaded Erlang modules (current and/or
old code), including preloaded modules.</p>
<p>See also <seealso marker="kernel:code">code(3)</seealso>.</p>
</desc>
</func>
<func>
<name name="localtime" arity="0"/>
<fsummary>Current local date and time</fsummary>
<desc>
<p>Returns the current local date and time
<c>{{Year, Month, Day}, {Hour, Minute, Second}}</c>.</p>
<p>The time zone and daylight saving time correction depend
on the underlying OS.</p>
<pre>
> <input>erlang:localtime().</input>
{{1996,11,6},{14,45,17}}</pre>
</desc>
</func>
<func>
<name name="localtime_to_universaltime" arity="1"/>
<fsummary>Convert from local to Universal Time Coordinated (UTC) date and time</fsummary>
<desc>
<p>Converts local date and time to Universal Time Coordinated
(UTC), if this is supported by the underlying OS. Otherwise,
no conversion is done and <c><anno>Localtime</anno></c> is returned.</p>
<pre>
> <input>erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}).</input>
{{1996,11,6},{13,45,17}}</pre>
<p>Failure: <c>badarg</c> if <c><anno>Localtime</anno></c> does not denote
a valid date and time.</p>
</desc>
</func>
<func>
<name name="localtime_to_universaltime" arity="2"/>
<fsummary>Convert from local to Universal Time Coordinated (UTC) date and time</fsummary>
<desc>
<p>Converts local date and time to Universal Time Coordinated
(UTC) just like <c>erlang:localtime_to_universaltime/1</c>,
but the caller decides if daylight saving time is active or
not.</p>
<p>If <c><anno>IsDst</anno> == true</c> the <c><anno>Localtime</anno></c> is during
daylight saving time, if <c><anno>IsDst</anno> == false</c> it is not,
and if <c><anno>IsDst</anno> == undefined</c> the underlying OS may
guess, which is the same as calling
<c>erlang:localtime_to_universaltime(<anno>Localtime</anno>)</c>.</p>
<pre>
> <input>erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, true).</input>
{{1996,11,6},{12,45,17}}
> <input>erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, false).</input>
{{1996,11,6},{13,45,17}}
> <input>erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, undefined).</input>
{{1996,11,6},{13,45,17}}</pre>
<p>Failure: <c>badarg</c> if <c><anno>Localtime</anno></c> does not denote
a valid date and time.</p>
</desc>
</func>
<func>
<name name="make_ref" arity="0"/>
<fsummary>Return a unique reference</fsummary>
<desc>
<p>Return a <seealso marker="doc/efficiency_guide:advanced#unique_references">unique
reference</seealso>. The reference is unique among
connected nodes.</p>
<warning><p>Known issue: When a node is restarted multiple
times with the same node name, references created
on a newer node can be mistaken for a reference
created on an older node with the same node name.</p></warning>
</desc>
</func>
<func>
<name name="make_tuple" arity="2"/>
<fsummary>Create a new tuple of a given arity</fsummary>
<desc>
<p>Returns a new tuple of the given <c><anno>Arity</anno></c>, where all
elements are <c><anno>InitialValue</anno></c>.</p>
<pre>
> <input>erlang:make_tuple(4, []).</input>
{[],[],[],[]}</pre>
</desc>
</func>
<func>
<name name="make_tuple" arity="3"/>
<fsummary>Create a new tuple with given arity and contents</fsummary>
<desc>
<p><c>erlang:make_tuple</c> first creates a tuple of size <c><anno>Arity</anno></c>
where each element has the value <c><anno>DefaultValue</anno></c>. It then fills
in values from <c><anno>InitList</anno></c>. Each list element in <c><anno>InitList</anno></c>
must be a two-tuple where the first element is a position in the
newly created tuple and the second element is any term. If a position
occurs more than once in the list, the term corresponding to
last occurrence will be used.</p>
<pre>
> <input>erlang:make_tuple(5, [], [{2,ignored},{5,zz},{2,aa}]).</input>
{{[],aa,[],[],zz}</pre>
</desc>
</func>
<func>
<name name="map_size" arity="1"/>
<fsummary>Return the size of a map</fsummary>
<desc>
<p>Returns an integer which is the number of key-value pairs in <c><anno>Map</anno></c>.</p>
<pre>
> <input>map_size(#{a=>1, b=>2, c=>3}).</input>
3</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="max" arity="2"/>
<fsummary>Return the largest of two term</fsummary>
<desc>
<p>Return the largest of <c><anno>Term1</anno></c> and <c><anno>Term2</anno></c>;
if the terms compare equal, <c><anno>Term1</anno></c> will be returned.</p>
</desc>
</func>
<func>
<name name="md5" arity="1"/>
<fsummary>Compute an MD5 message digest</fsummary>
<desc>
<p>Computes an <c>MD5</c> message digest from <c><anno>Data</anno></c>, where
the length of the digest is 128 bits (16 bytes). <c><anno>Data</anno></c>
is a binary or a list of small integers and binaries.</p>
<p>See The MD5 Message Digest Algorithm (RFC 1321) for more
information about MD5.</p>
<warning><p>The MD5 Message Digest Algorithm is <em>not</em> considered
safe for code-signing or software integrity purposes.</p></warning>
</desc>
</func>
<func>
<name name="md5_final" arity="1"/>
<fsummary>Finish the update of an MD5 context and return the computed MD5 message digest</fsummary>
<desc>
<p>Finishes the update of an MD5 <c><anno>Context</anno></c> and returns
the computed <c>MD5</c> message digest.</p>
</desc>
</func>
<func>
<name name="md5_init" arity="0"/>
<fsummary>Create an MD5 context</fsummary>
<desc>
<p>Creates an MD5 context, to be used in subsequent calls to
<c>md5_update/2</c>.</p>
</desc>
</func>
<func>
<name name="md5_update" arity="2"/>
<fsummary>Update an MD5 context with data, and return a new context</fsummary>
<desc>
<p>Updates an MD5 <c><anno>Context</anno></c> with <c><anno>Data</anno></c>, and returns
a <c><anno>NewContext</anno></c>.</p>
</desc>
</func>
<func>
<name name="memory" arity="0"/>
<type name="memory_type"/>
<fsummary>Information about dynamically allocated memory</fsummary>
<desc>
<p>Returns a list containing information about memory
dynamically allocated by the Erlang emulator. Each element of
the list is a tuple <c>{Type, Size}</c>. The first element
<c><anno>Type</anno></c>is an atom describing memory type. The second
element <c><anno>Size</anno></c>is memory size in bytes. A description of
each memory type follows:</p>
<taglist>
<tag><c>total</c></tag>
<item>
<p>The total amount of memory currently allocated, which is
the same as the sum of memory size for <c>processes</c>
and <c>system</c>.</p>
</item>
<tag><c>processes</c></tag>
<item>
<p>The total amount of memory currently allocated by
the Erlang processes.</p>
</item>
<tag><c>processes_used</c></tag>
<item>
<p>The total amount of memory currently used by the Erlang
processes.</p>
<p>This memory is part of the memory presented as
<c>processes</c> memory.</p>
</item>
<tag><c>system</c></tag>
<item>
<p>The total amount of memory currently allocated by
the emulator that is not directly related to any Erlang
process.</p>
<p>Memory presented as <c>processes</c> is not included in
this memory.</p>
</item>
<tag><c>atom</c></tag>
<item>
<p>The total amount of memory currently allocated for atoms.</p>
<p>This memory is part of the memory presented as
<c>system</c> memory.</p>
</item>
<tag><c>atom_used</c></tag>
<item>
<p>The total amount of memory currently used for atoms.</p>
<p>This memory is part of the memory presented as
<c>atom</c> memory.</p>
</item>
<tag><c>binary</c></tag>
<item>
<p>The total amount of memory currently allocated for
binaries.</p>
<p>This memory is part of the memory presented as
<c>system</c> memory.</p>
</item>
<tag><c>code</c></tag>
<item>
<p>The total amount of memory currently allocated for
Erlang code.</p>
<p>This memory is part of the memory presented as
<c>system</c> memory.</p>
</item>
<tag><c>ets</c></tag>
<item>
<p>The total amount of memory currently allocated for ets
tables.</p>
<p>This memory is part of the memory presented as
<c>system</c> memory.</p>
</item>
<tag><c>low</c></tag>
<item>
<p>Only on 64-bit halfword emulator.</p>
<p>The total amount of memory allocated in low memory areas
that are restricted to less than 4 Gb even though
the system may have more physical memory.</p>
<p>May be removed in future releases of halfword emulator.</p>
</item>
<tag><c>maximum</c></tag>
<item>
<p>The maximum total amount of memory allocated since
the emulator was started.</p>
<p>This tuple is only present when the emulator is run with
instrumentation.</p>
<p>For information on how to run the emulator with
instrumentation see
<seealso marker="tools:instrument">instrument(3)</seealso>
and/or <seealso marker="erts:erl">erl(1)</seealso>.</p>
</item>
</taglist>
<note>
<p>The <c>system</c> value is not complete. Some allocated
memory that should be part of the <c>system</c> value are
not.</p>
<p>When the emulator is run with instrumentation,
the <c>system</c> value is more accurate, but memory
directly allocated by <c>malloc</c> (and friends) are still
not part of the <c>system</c> value. Direct calls to
<c>malloc</c> are only done from OS specific runtime
libraries and perhaps from user implemented Erlang drivers
that do not use the memory allocation functions in
the driver interface.</p>
<p>Since the <c>total</c> value is the sum of <c>processes</c>
and <c>system</c> the error in <c>system</c> will propagate
to the <c>total</c> value.</p>
<p>The different amounts of memory that are summed are
<em>not</em> gathered atomically which also introduce
an error in the result.</p>
</note>
<p>The different values has the following relation to each
other. Values beginning with an uppercase letter is not part
of the result.</p>
<code type="none">
total = processes + system
processes = processes_used + ProcessesNotUsed
system = atom + binary + code + ets + OtherSystem
atom = atom_used + AtomNotUsed
RealTotal = processes + RealSystem
RealSystem = system + MissedSystem</code>
<p>More tuples in the returned list may be added in the future.</p>
<note>
<p>The <c>total</c> value is supposed to be the total amount
of memory dynamically allocated by the emulator. Shared
libraries, the code of the emulator itself, and
the emulator stack(s) are not supposed to be included. That
is, the <c>total</c> value is <em>not</em> supposed to be
equal to the total size of all pages mapped to the emulator.
Furthermore, due to fragmentation and pre-reservation of
memory areas, the size of the memory segments which contain
the dynamically allocated memory blocks can be substantially
larger than the total size of the dynamically allocated
memory blocks.</p>
</note>
<note>
<p>
Since erts version 5.6.4 <c>erlang:memory/0</c> requires that
all <seealso marker="erts:erts_alloc">erts_alloc(3)</seealso>
allocators are enabled (default behaviour).
</p>
</note>
<p>Failure:</p>
<taglist>
<tag><c>notsup</c></tag>
<item>
If an <seealso marker="erts:erts_alloc">erts_alloc(3)</seealso>
allocator has been disabled.
</item>
</taglist>
</desc>
</func>
<func>
<name name="memory" arity="1" clause_i="1"/>
<name name="memory" arity="1" clause_i="2"/>
<type name="memory_type"/>
<fsummary>Information about dynamically allocated memory</fsummary>
<desc>
<p>Returns the memory size in bytes allocated for memory of
type <c><anno>Type</anno></c>. The argument can also be given as a list
of <c>memory_type()</c> atoms, in which case a corresponding list of
<c>{memory_type(), Size :: integer >= 0}</c> tuples is returned.</p>
<note>
<p>
Since erts version 5.6.4 <c>erlang:memory/1</c> requires that
all <seealso marker="erts:erts_alloc">erts_alloc(3)</seealso>
allocators are enabled (default behaviour).
</p>
</note>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Type</anno></c> is not one of the memory types listed in the
documentation of
<seealso marker="#memory/0">erlang:memory/0</seealso>.
</item>
<tag><c>badarg</c></tag>
<item>
If <c>maximum</c> is passed as <c><anno>Type</anno></c> and the emulator
is not run in instrumented mode.
</item>
<tag><c>notsup</c></tag>
<item>
If an <seealso marker="erts:erts_alloc">erts_alloc(3)</seealso>
allocator has been disabled.
</item>
</taglist>
<p>See also
<seealso marker="#memory/0">erlang:memory/0</seealso>.</p>
</desc>
</func>
<func>
<name name="min" arity="2"/>
<fsummary>Return the smallest of two term</fsummary>
<desc>
<p>Return the smallest of <c><anno>Term1</anno></c> and <c><anno>Term2</anno></c>;
if the terms compare equal, <c><anno>Term1</anno></c> will be returned.</p>
</desc>
</func>
<func>
<name name="module_loaded" arity="1"/>
<fsummary>Check if a module is loaded</fsummary>
<desc>
<p>Returns <c>true</c> if the module <c><anno>Module</anno></c> is loaded,
otherwise returns <c>false</c>. It does not attempt to load
the module.</p>
<warning>
<p>This BIF is intended for the code server (see
<seealso marker="kernel:code">code(3)</seealso>) and should not be
used elsewhere.</p>
</warning>
</desc>
</func>
<func>
<name name="monitor" arity="2" clause_i="1"/>
<name name="monitor" arity="2" clause_i="2"/>
<type name="registered_name"/>
<type name="registered_process_identifier"/>
<type name="monitor_process_identifier"/>
<fsummary>Start monitoring</fsummary>
<desc>
<p>Send a monitor request of type <c><anno>Type</anno></c> to the
entity identified by <c><anno>Item</anno></c>. The caller of
<c>monitor/2</c> will later be notified by a monitor message on the
following format if the monitored state is changed:</p>
<code type="none">{Tag, <anno>MonitorRef</anno>, <anno>Type</anno>, Object, Info}</code>
<note><p>The monitor request is an asynchronous signal. That is, it
takes time before the signal reach its destination.</p></note>
<p>Currently valid <c><anno>Type</anno></c>s:</p>
<taglist>
<tag><marker id="monitor_process"/><c>process</c></tag>
<item>
<p>Monitor the existence of the process identified by
<c><anno>Item</anno></c>. Currently valid
<c><anno>Item</anno></c>s in combination with the
<c>process <anno>Type</anno></c>:</p>
<taglist>
<tag><c>pid()</c></tag>
<item>
<p>The process identifier of the process to monitor.</p>
</item>
<tag><c>{RegisteredName, Node}</c></tag>
<item>
<p>A tuple consisting of a registered name of a process and
a node name. The process residing on the node <c>Node</c>
with the registered name <c>{RegisteredName, Node}</c> will
be monitored.</p>
</item>
<tag><c>RegisteredName</c></tag>
<item>
<p>The process locally registered as <c>RegisteredName</c>
will become monitored.</p>
</item>
</taglist>
<note><p>When a process is monitored by registered name, the
process that has the registered name at the time when the
monitor request reach its destination will be monitored.
The monitor will not be effected, if the registered name is
unregistered, or unregistered and later registered on another
process.</p></note>
<p>The monitor is triggered either when the monitored process
terminates, is non existing, or if the connection to it is
lost. In the case the connection to it is lost, we do not know
if it still exist or not. After this type of monitor has been
triggered, the monitor is automatically removed.</p>
<p>When the monitor is triggered a <c>'DOWN'</c> message will
be sent to the monitoring process. A <c>'DOWN'</c> message has
the following pattern:</p>
<code type="none">{'DOWN', MonitorRef, Type, Object, Info}</code>
<p>where <c>MonitorRef</c> and <c>Type</c> are the same as
described above, and:</p>
<taglist>
<tag><c>Object</c></tag>
<item>
<p>equals:</p>
<taglist>
<tag><c><anno>Item</anno></c></tag>
<item>If <c><anno>Item</anno></c> was specified by a
pid.</item>
<tag><c>{RegisteredName, Node}</c></tag>
<item>If <c><anno>Item</anno></c> was specified as
<c>RegisteredName</c>, or <c>{RegisteredName, Node}</c>
where <c>Node</c> corresponds to the node that the
monitored process resides on.</item>
</taglist>
</item>
<tag><c>Info</c></tag>
<item>
<p>Either the exit reason of the process, <c>noproc</c>
(non-existing process), or <c>noconnection</c> (no
connection to the node where the monitored process
resides).</p></item>
</taglist>
<p>The monitoring is turned off either when the <c>'DOWN'</c>
message is sent, or when
<seealso marker="#demonitor/1">demonitor/1</seealso>
is called.</p>
<p>If an attempt is made to monitor a process on an older node
(where remote process monitoring is not implemented or one
where remote process monitoring by registered name is not
implemented), the call fails with <c>badarg</c>.</p>
<note>
<p>The format of the <c>'DOWN'</c> message changed in the 5.2
version of the emulator (OTP release R9B) for monitor
<em>by registered name</em>. The <c>Object</c> element of
the <c>'DOWN'</c> message could in earlier versions
sometimes be the pid of the monitored process and sometimes
be the registered name. Now the <c>Object</c> element is
always a tuple consisting of the registered name and
the node name. Processes on new nodes (emulator version 5.2
or greater) will always get <c>'DOWN'</c> messages on
the new format even if they are monitoring processes on old
nodes. Processes on old nodes will always get <c>'DOWN'</c>
messages on the old format.</p>
</note>
</item>
<tag><marker id="monitor_time_offset"/><c>time_offset</c></tag>
<item>
<p>Monitor changes in
<seealso marker="#time_offset/0">time offset</seealso>
between
<seealso marker="time_correction#Erlang_Monotonic_Time">Erlang
monotonic time</seealso> and
<seealso marker="time_correction#Erlang_System_Time">Erlang
system time</seealso>. There is only one valid
<c><anno>Item</anno></c> in combination with the
<c>time_offset <anno>Type</anno></c>, namely the atom
<c>clock_service</c>. Note that the atom <c>clock_service</c> is
<em>not</em> the registered name of a process. In this specific
case it serves as an identifier of the runtime system internal
clock service at current runtime system instance.</p>
<p>The monitor is triggered when the time offset is changed.
This either if the time offset value is changed, or if the
offset is changed from preliminary to final during
<seealso marker="#system_flag_time_offset">finalization
of the time offset</seealso> when the
<seealso marker="time_correction#Single_Time_Warp_Mode">single
time warp mode</seealso> is used. When a change from preliminary
to final time offset is made, the monitor will be triggered once
regardless of whether the time offset value was changed due to
the finalization or not.</p>
<p>If the runtime system is in
<seealso marker="time_correction#Multi_Time_Warp_Mode">multi
time warp mode</seealso>, the time offset will be changed when
the runtime system detects that the
<seealso marker="time_correction#OS_System_Time">OS system
time</seealso> has changed. The runtime system will, however,
not detect this immediately when it happens. A task checking
the time offset is scheduled to execute at least once a minute,
so under normal operation this should be detected within a
minute, but during heavy load it might take longer time.</p>
<p>The monitor will <em>not</em> be automatically removed
after it has been triggered. That is, repeated changes of
the time offset will trigger the monitor repeatedly.</p>
<p>When the monitor is triggered a <c>'CHANGE'</c> message will
be sent to the monitoring process. A <c>'CHANGE'</c> message has
the following pattern:</p>
<code type="none">{'CHANGE', MonitorRef, Type, Item, NewTimeOffset}</code>
<p>where <c>MonitorRef</c>, <c><anno>Type</anno></c>, and
<c><anno>Item</anno></c> are the same as described above, and
<c>NewTimeOffset</c> is the new time offset.</p>
<p>When the <c>'CHANGE'</c> message has been received you are
guaranteed not to retrieve the old time offset when calling
<seealso marker="#time_offset/0"><c>erlang:time_offset()</c></seealso>.
Note that you may observe the change of the time offset
when calling <c>erlang:time_offset()</c> before you
get the <c>'CHANGE'</c> message.</p>
</item>
</taglist>
<p>Making several calls to <c>monitor/2</c> for the same
<c><anno>Item</anno></c> and/or <c><anno>Type</anno></c> is not
an error; it results in many, completely independent,
monitorings.</p>
<p>The monitor functionality is expected to be extended. That is,
other <c><anno>Type</anno></c>s and <c><anno>Item</anno></c>s
are expected to be supported in the future.</p>
<note>
<p>If/when <c>monitor/2</c> is extended, other
possible values for <c>Tag</c>, <c>Object</c>, and
<c>Info</c> in the monitor message will be introduced.</p>
</note>
</desc>
</func>
<func>
<name name="monitor_node" arity="2"/>
<fsummary>Monitor the status of a node</fsummary>
<desc>
<p>Monitors the status of the node <c><anno>Node</anno></c>. If <c><anno>Flag</anno></c>
is <c>true</c>, monitoring is turned on; if <c><anno>Flag</anno></c> is
<c>false</c>, monitoring is turned off.</p>
<p>Making several calls to <c>monitor_node(Node, true)</c> for
the same <c><anno>Node</anno></c> is not an error; it results in as many,
completely independent, monitorings.</p>
<p>If <c><anno>Node</anno></c> fails or does not exist, the message
<c>{nodedown, Node}</c> is delivered to the process. If a
process has made two calls to <c>monitor_node(Node, true)</c>
and <c><anno>Node</anno></c> terminates, two <c>nodedown</c> messages are
delivered to the process. If there is no connection to
<c><anno>Node</anno></c>, there will be an attempt to create one. If this
fails, a <c>nodedown</c> message is delivered.</p>
<p>Nodes connected through hidden connections can be monitored
as any other node.</p>
<p>Failure: <c>badarg</c> if the local node is not alive.</p>
</desc>
</func>
<func>
<name name="monitor_node" arity="3"/>
<fsummary>Monitor the status of a node</fsummary>
<desc>
<p>Behaves as <c>monitor_node/2</c> except that it allows an
extra option to be given, namely <c>allow_passive_connect</c>.
The option allows the BIF to wait the normal net connection
timeout for the <em>monitored node</em> to connect itself,
even if it cannot be actively connected from this node
(i.e. it is blocked). The state where this might be useful can
only be achieved by using the kernel option
<c>dist_auto_connect once</c>. If that kernel option is not
used, the <c>allow_passive_connect</c> option has no
effect.</p>
<note>
<p>The <c>allow_passive_connect</c> option is used
internally and is seldom needed in applications where the
network topology and the kernel options in effect is known in
advance.</p>
</note>
<p>Failure: <c>badarg</c> if the local node is not alive or the
option list is malformed.</p>
</desc>
</func>
<func>
<name name="monotonic_time" arity="0"/>
<fsummary>Current Erlang monotonic time</fsummary>
<desc>
<p>Returns the current
<seealso marker="time_correction#Erlang_Monotonic_Time">Erlang
monotonic time</seealso> in <c>native</c>
<seealso marker="#type_time_unit">time unit</seealso>. This
is a monotonically increasing time since some unspecified point in
time.</p>
<note><p>This is a
<seealso marker="time_correction#Monotonically_Increasing">monotonically increasing</seealso> time, but <em>not</em> a
<seealso marker="time_correction#Strictly_Monotonically_Increasing">strictly monotonically increasing</seealso>
time. That is, consecutive calls to
<c>erlang:monotonic_time/0</c> may produce the same result.</p>
<p>Different runtime system instances will use different
unspecified points in time as base for their Erlang monotonic clocks.
That is, it is <em>pointless</em> comparing monotonic times from
different runtime system instances. Different runtime system instances
may also place this unspecified point in time different relative
runtime system start. It may be placed in the future (time at start
will be a negative value), the past (time at start will be a
positive value), or the runtime system start (time at start will
be zero). The monotonic time as of runtime system start can be
retrieved by calling
<seealso marker="#system_info_start_time"><c>erlang:system_info(start_time)</c></seealso>.</p></note>
</desc>
</func>
<func>
<name name="monotonic_time" arity="1"/>
<fsummary>Current Erlang monotonic time</fsummary>
<desc>
<p>Returns the current
<seealso marker="time_correction#Erlang_Monotonic_Time">Erlang
monotonic time</seealso> converted
into the <c><anno>Unit</anno></c> passed as argument.</p>
<p>Same as calling
<seealso marker="#convert_time_unit/3"><c>erlang:convert_time_unit</c></seealso><c>(</c><seealso marker="#monotonic_time/0"><c>erlang:monotonic_time()</c></seealso><c>,
native, <anno>Unit</anno>)</c>
however optimized for commonly used <c><anno>Unit</anno></c>s.</p>
</desc>
</func>
<func>
<name name="nif_error" arity="1"/>
<fsummary>Stop execution with a given reason</fsummary>
<desc>
<p>Works exactly like
<seealso marker="#error/1">erlang:error/1</seealso>,
but Dialyzer thinks that this BIF will return an arbitrary term.
When used in a stub function for a NIF to generate an
exception when the NIF library is not loaded, Dialyzer
will not generate false warnings.</p>
</desc>
</func>
<func>
<name name="nif_error" arity="2"/>
<fsummary>Stop execution with a given reason</fsummary>
<desc>
<p>Works exactly like
<seealso marker="#error/2">erlang:error/2</seealso>,
but Dialyzer thinks that this BIF will return an arbitrary term.
When used in a stub function for a NIF to generate an
exception when the NIF library is not loaded, Dialyzer
will not generate false warnings.</p>
</desc>
</func>
<func>
<name name="node" arity="0"/>
<fsummary>Name of the local node</fsummary>
<desc>
<p>Returns the name of the local node. If the node is not alive,
<c>nonode@nohost</c> is returned instead.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="node" arity="1"/>
<fsummary>At which node is a pid, port or reference located</fsummary>
<desc>
<p>Returns the node where <c><anno>Arg</anno></c> is located. <c><anno>Arg</anno></c> can
be a pid, a reference, or a port. If the local node is not
alive, <c>nonode@nohost</c> is returned.</p>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="nodes" arity="0"/>
<fsummary>All visible nodes in the system</fsummary>
<desc>
<p>Returns a list of all visible nodes in the system, excluding
the local node. Same as <c>nodes(visible)</c>.</p>
</desc>
</func>
<func>
<name name="nodes" arity="1"/>
<fsummary>All nodes of a certain type in the system</fsummary>
<desc>
<p>Returns a list of nodes according to argument given.
The result returned when the argument is a list, is the list
of nodes satisfying the disjunction(s) of the list elements.</p>
<p><c><anno>NodeType</anno></c> can be any of the following:</p>
<taglist>
<tag><c>visible</c></tag>
<item>
<p>Nodes connected to this node through normal connections.</p>
</item>
<tag><c>hidden</c></tag>
<item>
<p>Nodes connected to this node through hidden connections.</p>
</item>
<tag><c>connected</c></tag>
<item>
<p>All nodes connected to this node.</p>
</item>
<tag><c>this</c></tag>
<item>
<p>This node.</p>
</item>
<tag><c>known</c></tag>
<item>
<p>Nodes which are known to this node, i.e., connected,
previously connected, etc.</p>
</item>
</taglist>
<p>Some equalities: <c>[node()] = nodes(this)</c>,
<c>nodes(connected) = nodes([visible, hidden])</c>, and
<c>nodes() = nodes(visible)</c>.</p>
<p>If the local node is not alive,
<c>nodes(this) == nodes(known) == [nonode@nohost]</c>, for
any other <c><anno>Arg</anno></c> the empty list [] is returned.</p>
</desc>
</func>
<func>
<name name="now" arity="0"/>
<type name="timestamp"/>
<fsummary>Elapsed time since 00:00 GMT</fsummary>
<desc>
<warning><p><em>This function is deprecated! Do not use it!</em>
See the users guide chapter
<seealso marker="time_correction">Time and Time Correction</seealso>
for more information. Specifically the
<seealso marker="time_correction#Dos_and_Donts">Dos and Dont's</seealso>
section for information on what to use instead of <c>erlang:now/0</c>.
</p></warning>
<p>Returns the tuple <c>{MegaSecs, Secs, MicroSecs}</c> which is
the elapsed time since 00:00 GMT, January 1, 1970 (zero hour)
on the assumption that the underlying OS supports this.
Otherwise, some other point in time is chosen. It is also
guaranteed that subsequent calls to this BIF returns
continuously increasing values. Hence, the return value from
<c>now()</c> can be used to generate unique time-stamps,
and if it is called in a tight loop on a fast machine
the time of the node can become skewed.</p>
<p>It can only be used to check the local time of day if
the time-zone info of the underlying operating system is
properly configured.</p>
</desc>
</func>
<func>
<name name="open_port" arity="2"/>
<fsummary>Open a port</fsummary>
<desc>
<p>Returns a port identifier as the result of opening a
new Erlang port. A port can be seen as an external Erlang
process.
</p>
<p>The name of the executable as well as the arguments
given in <c>cd</c>, <c>env</c>, <c>args</c> and <c>arg0</c> is subject to
Unicode file name translation if the system is running
in Unicode file name mode. To avoid
translation or force i.e. UTF-8, supply the executable
and/or arguments as a binary in the correct
encoding. See the <seealso
marker="kernel:file">file</seealso> module, the
<seealso marker="kernel:file#native_name_encoding/0">
file:native_name_encoding/0</seealso> function and the
<seealso marker="stdlib:unicode_usage">stdlib users guide
</seealso> for details.</p>
<note><p>The characters in the name (if given as a list)
can only be > 255 if the Erlang VM is started in
Unicode file name translation mode, otherwise the name
of the executable is limited to the ISO-latin-1
character set.</p></note>
<p><c><anno>PortName</anno></c> is one of the following:</p>
<taglist>
<tag><c>{spawn, <anno>Command</anno>}</c></tag>
<item>
<p>Starts an external program. <c><anno>Command</anno></c> is the name
of the external program which will be run. <c><anno>Command</anno></c>
runs outside the Erlang work space unless an Erlang
driver with the name <c><anno>Command</anno></c> is found. If found,
that driver will be started. A driver runs in the Erlang
workspace, which means that it is linked with the Erlang
runtime system.</p>
<p>When starting external programs on Solaris, the system
call <c>vfork</c> is used in preference to <c>fork</c>
for performance reasons, although it has a history of
being less robust. If there are problems with using
<c>vfork</c>, setting the environment variable
<c>ERL_NO_VFORK</c> to any value will cause <c>fork</c>
to be used instead.</p>
<p>For external programs, the <c>PATH</c> is searched
(or an equivalent method is used to find programs,
depending on operating system). This is done by invoking
the shell on certain platforms. The first space
separated token of the command will be considered as the
name of the executable (or driver). This (among other
things) makes this option unsuitable for running
programs having spaces in file or directory names. Use
{spawn_executable, <anno>Command</anno>} instead if spaces in executable
file names is desired.</p>
</item>
<tag><c>{spawn_driver, <anno>Command</anno>}</c></tag>
<item>
<p>Works like <c>{spawn, <anno>Command</anno>}</c>, but demands the
first (space separated) token of the command to be the name of a
loaded driver. If no driver with that name is loaded, a
<c>badarg</c> error is raised.</p>
</item>
<tag><c>{spawn_executable, <anno>FileName</anno>}</c></tag>
<item>
<p>Works like <c>{spawn, <anno>FileName</anno>}</c>, but only runs
external executables. The <c><anno>FileName</anno></c> in its whole
is used as the name of the executable, including any
spaces. If arguments are to be passed, the
<c>args</c> and <c>arg0</c> <c><anno>PortSettings</anno></c> can be used.</p>
<p>The shell is not usually invoked to start the
program, it's executed directly. Neither is the
<c>PATH</c> (or equivalent) searched. To find a program
in the PATH to execute, use <seealso
marker="kernel:os#find_executable/1">os:find_executable/1</seealso>.</p>
<p>Only if a shell script or <c>.bat</c> file is
executed, the appropriate command interpreter will
implicitly be invoked, but there will still be no
command argument expansion or implicit PATH search.</p>
<p>If the <c><anno>FileName</anno></c> cannot be run, an error
exception, with the posix error code as the reason, is
raised. The error reason may differ between operating
systems. Typically the error <c>enoent</c> is raised
when one tries to run a program that is not found and
<c>eacces</c> is raised when the given file is not
executable.</p>
</item>
<tag><c>{fd, <anno>In</anno>, <anno>Out</anno>}</c></tag>
<item>
<p>Allows an Erlang process to access any currently opened
file descriptors used by Erlang. The file descriptor
<c><anno>In</anno></c> can be used for standard input, and the file
descriptor <c><anno>Out</anno></c> for standard output. It is only
used for various servers in the Erlang operating system
(<c>shell</c> and <c>user</c>). Hence, its use is very
limited.</p>
</item>
</taglist>
<p><c><anno>PortSettings</anno></c> is a list of settings for the port.
Valid settings are:</p>
<taglist>
<tag><c>{packet, <anno>N</anno>}</c></tag>
<item>
<p>Messages are preceded by their length, sent in <c><anno>N</anno></c>
bytes, with the most significant byte first. Valid values
for <c>N</c> are 1, 2, or 4.</p>
</item>
<tag><c>stream</c></tag>
<item>
<p>Output messages are sent without packet lengths. A
user-defined protocol must be used between the Erlang
process and the external object.</p>
</item>
<tag><c>{line, <anno>L</anno>}</c></tag>
<item>
<p>Messages are delivered on a per line basis. Each line
(delimited by the OS-dependent newline sequence) is
delivered in one single message. The message data format
is <c>{Flag, Line}</c>, where <c>Flag</c> is either
<c>eol</c> or <c>noeol</c> and <c>Line</c> is the actual
data delivered (without the newline sequence).</p>
<p><c><anno>L</anno></c> specifies the maximum line length in bytes.
Lines longer than this will be delivered in more than one
message, with the <c>Flag</c> set to <c>noeol</c> for all
but the last message. If end of file is encountered
anywhere else than immediately following a newline
sequence, the last line will also be delivered with
the <c>Flag</c> set to <c>noeol</c>. In all other cases,
lines are delivered with <c>Flag</c> set to <c>eol</c>.</p>
<p>The <c>{packet, <anno>N</anno>}</c> and <c>{line, <anno>L</anno>}</c> settings are
mutually exclusive.</p>
</item>
<tag><c>{cd, <anno>Dir</anno>}</c></tag>
<item>
<p>This is only valid for <c>{spawn, <anno>Command</anno>}</c> and
<c>{spawn_executable, <anno>FileName</anno>}</c>.
The external program starts using <c><anno>Dir</anno></c> as its
working directory. <c><anno>Dir</anno></c> must be a string.
</p>
</item>
<tag><c>{env, <anno>Env</anno>}</c></tag>
<item>
<p>This is only valid for <c>{spawn, <anno>Command</anno>}</c> and
<c>{spawn_executable, <anno>FileName</anno>}</c>.
The environment of the started process is extended using
the environment specifications in <c><anno>Env</anno></c>.</p>
<p><c><anno>Env</anno></c> should be a list of tuples <c>{<anno>Name</anno>, <anno>Val</anno>}</c>,
where <c><anno>Name</anno></c> is the name of an environment variable,
and <c><anno>Val</anno></c> is the value it is to have in the spawned
port process. Both <c><anno>Name</anno></c> and <c><anno>Val</anno></c> must be
strings. The one exception is <c><anno>Val</anno></c> being the atom
<c>false</c> (in analogy with <c>os:getenv/1</c>), which
removes the environment variable.
</p>
</item>
<tag><c>{args, [ string() | binary() ]}</c></tag>
<item>
<p>This option is only valid for <c>{spawn_executable, <anno>FileName</anno>}</c>
and specifies arguments to the executable. Each argument
is given as a separate string and (on Unix) eventually
ends up as one element each in the argument vector. On
other platforms, similar behavior is mimicked.</p>
<p>The arguments are not expanded by the shell prior to
being supplied to the executable, most notably this
means that file wildcard expansion will not happen. Use
<seealso
marker="stdlib:filelib#wildcard/1">filelib:wildcard/1</seealso>
to expand wildcards for the arguments. Note that even if
the program is a Unix shell script, meaning that the
shell will ultimately be invoked, wildcard expansion
will not happen and the script will be provided with the
untouched arguments. On Windows®, wildcard expansion
is always up to the program itself, why this isn't an
issue.</p>
<p>Note also that the actual executable name (a.k.a. <c>argv[0]</c>)
should not be given in this list. The proper executable name will
automatically be used as argv[0] where applicable.</p>
<p>If one, for any reason, wants to explicitly set the
program name in the argument vector, the <c>arg0</c>
option can be used.</p>
</item>
<tag><c>{arg0, string() | binary()}</c></tag>
<item>
<p>This option is only valid for <c>{spawn_executable, <anno>FileName</anno>}</c>
and explicitly specifies the program name argument when
running an executable. This might in some circumstances,
on some operating systems, be desirable. How the program
responds to this is highly system dependent and no specific
effect is guaranteed.</p>
</item>
<tag><c>exit_status</c></tag>
<item>
<p>This is only valid for <c>{spawn, <anno>Command</anno>}</c> where
<c><anno>Command</anno></c> refers to an external program, and for
<c>{spawn_executable, <anno>FileName</anno>}</c>.</p>
<p>When the external process connected to the port exits, a
message of the form <c>{Port,{exit_status,Status}}</c> is
sent to the connected process, where <c>Status</c> is the
exit status of the external process. If the program
aborts, on Unix the same convention is used as the shells
do (i.e., 128+signal).</p>
<p>If the <c>eof</c> option has been given as well,
the <c>eof</c> message and the <c>exit_status</c> message
appear in an unspecified order.</p>
<p>If the port program closes its stdout without exiting,
the <c>exit_status</c> option will not work.</p>
</item>
<tag><c>use_stdio</c></tag>
<item>
<p>This is only valid for <c>{spawn, <anno>Command</anno>}</c> and
<c>{spawn_executable, <anno>FileName</anno>}</c>. It
allows the standard input and output (file descriptors 0
and 1) of the spawned (UNIX) process for communication
with Erlang.</p>
</item>
<tag><c>nouse_stdio</c></tag>
<item>
<p>The opposite of <c>use_stdio</c>. Uses file descriptors
3 and 4 for communication with Erlang.</p>
</item>
<tag><c>stderr_to_stdout</c></tag>
<item>
<p>Affects ports to external programs. The executed program
gets its standard error file redirected to its standard
output file. <c>stderr_to_stdout</c> and
<c>nouse_stdio</c> are mutually exclusive.</p>
</item>
<tag><c>overlapped_io</c></tag>
<item>
<p>Affects ports to external programs on Windows® only.
The standard input and standard output handles of the port program
will, if this option is supplied, be opened with the flag
FILE_FLAG_OVERLAPPED, so that the port program can (and has to) do
overlapped I/O on its standard handles. This is not normally
the case for simple port programs, but an option of value for the
experienced Windows programmer. <em>On all other platforms, this
option is silently discarded</em>.</p>
</item>
<tag><c>in</c></tag>
<item>
<p>The port can only be used for input.</p>
</item>
<tag><c>out</c></tag>
<item>
<p>The port can only be used for output.</p>
</item>
<tag><c>binary</c></tag>
<item>
<p>All IO from the port are binary data objects as opposed
to lists of bytes.</p>
</item>
<tag><c>eof</c></tag>
<item>
<p>The port will not be closed at the end of the file and
produce an exit signal. Instead, it will remain open and
a <c>{Port, eof}</c> message will be sent to the process
holding the port.</p>
</item>
<tag><c>hide</c></tag>
<item>
<p>When running on Windows, suppress creation of a new
console window when spawning the port program.
(This option has no effect on other platforms.)</p>
</item>
<tag><marker id="open_port_parallelism"><c>{parallelism, Boolean}</c></marker></tag>
<item>
<p>Set scheduler hint for port parallelism. If set to <c>true</c>,
the VM will schedule port tasks when doing so will improve
parallelism in the system. If set to <c>false</c>, the VM will
try to perform port tasks immediately, improving latency at the
expense of parallelism. The default can be set on system startup
by passing the
<seealso marker="erl#+spp">+spp</seealso> command line argument
to <seealso marker="erl">erl(1)</seealso>.
</p>
</item>
</taglist>
<p>The default is <c>stream</c> for all types of port and
<c>use_stdio</c> for spawned ports.</p>
<p>Failure: If the port cannot be opened, the exit reason is
<c>badarg</c>, <c>system_limit</c>, or the Posix error code which
most closely describes the error, or <c>einval</c> if no Posix code
is appropriate:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
<p>Bad input arguments to <c>open_port</c>.</p>
</item>
<tag><c>system_limit</c></tag>
<item>
<p>All available ports in the Erlang emulator are in use.</p>
</item>
<tag><c>enomem</c></tag>
<item>
<p>There was not enough memory to create the port.</p>
</item>
<tag><c>eagain</c></tag>
<item>
<p>There are no more available operating system processes.</p>
</item>
<tag><c>enametoolong</c></tag>
<item>
<p>The external command given was too long.</p>
</item>
<tag><c>emfile</c></tag>
<item>
<p>There are no more available file descriptors (for the operating system process
that the Erlang emulator runs in).</p>
</item>
<tag><c>enfile</c></tag>
<item>
<p>The file table is full (for the entire operating system).</p>
</item>
<tag><c>eacces</c></tag>
<item>
<p>The <c>Command</c> given in <c>{spawn_executable, Command}</c> does not point out an executable file.</p>
</item>
<tag><c>enoent</c></tag>
<item>
<p>The <c><anno>FileName</anno></c> given in <c>{spawn_executable, <anno>FileName</anno>}</c> does not point out an existing file.</p>
</item>
</taglist>
<p>During use of a port opened using <c>{spawn, Name}</c>,
<c>{spawn_driver, Name}</c> or <c>{spawn_executable, Name}</c>,
errors arising when sending messages to it are reported to
the owning process using signals of the form
<c>{'EXIT', Port, PosixCode}</c>. See <c>file(3)</c> for
possible values of <c>PosixCode</c>.</p>
<p>The maximum number of ports that can be open at the same
time can be configured by passing the
<seealso marker="erl#max_ports"><c>+Q</c></seealso>
command line flag to
<seealso marker="erl"><c>erl(1)</c></seealso>.</p>
</desc>
</func>
<func>
<name name="phash" arity="2"/>
<type_desc variable="Range">Range = 1..2^32, Hash = 1..Range</type_desc>
<fsummary>Portable hash function</fsummary>
<desc>
<p>Portable hash function that will give the same hash for
the same Erlang term regardless of machine architecture and
ERTS version (the BIF was introduced in ERTS 4.9.1.1). Range
can be between 1 and 2^32, the function returns a hash value
for <c><anno>Term</anno></c> within the range <c>1..<anno>Range</anno></c>.</p>
<p>This BIF could be used instead of the old deprecated
<c>erlang:hash/2</c> BIF, as it calculates better hashes for
all data-types, but consider using <c>phash2/1,2</c> instead.</p>
</desc>
</func>
<func>
<name name="phash2" arity="1"/>
<name name="phash2" arity="2"/>
<type_desc variable="Range">1..2^32</type_desc>
<type_desc variable="Hash">0..Range-1</type_desc>
<fsummary>Portable hash function</fsummary>
<desc>
<p>Portable hash function that will give the same hash for
the same Erlang term regardless of machine architecture and
ERTS version (the BIF was introduced in ERTS 5.2). Range can
be between 1 and 2^32, the function returns a hash value for
<c><anno>Term</anno></c> within the range <c>0..<anno>Range</anno>-1</c>. When called
without the <c><anno>Range</anno></c> argument, a value in the range
<c>0..2^27-1</c> is returned.</p>
<p>This BIF should always be used for hashing terms. It
distributes small integers better than <c>phash/2</c>, and
it is faster for bignums and binaries.</p>
<p>Note that the range <c>0..<anno>Range</anno>-1</c> is different from
the range of <c>phash/2</c> (<c>1..<anno>Range</anno></c>).</p>
</desc>
</func>
<func>
<name name="pid_to_list" arity="1"/>
<fsummary>Text representation of a pid</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c><anno>Pid</anno></c>.</p>
<warning>
<p>This BIF is intended for debugging and for use in
the Erlang operating system. It should not be used in
application programs.</p>
</warning>
</desc>
</func>
<func>
<name name="port_close" arity="1"/>
<fsummary>Close an open port</fsummary>
<desc>
<p>Closes an open port. Roughly the same as
<c><anno>Port</anno> ! {self(), close}</c> except for the error behaviour
(see below), being synchronous, and that the port does
<em>not</em> reply with <c>{Port, closed}</c>. Any process may
close a port with <c>port_close/1</c>, not only the port owner
(the connected process). If the calling process is linked to
port identified by <c><anno>Port</anno></c>, an exit signal due
to that link will be received by the process prior to the return
from <c>port_close/1</c>.</p>
<p>For comparison: <c><anno>Port</anno> ! {self(), close}</c> fails with
<c>badarg</c> if <c><anno>Port</anno></c> cannot be sent to (i.e.,
<c><anno>Port</anno></c> refers neither to a port nor to a process). If
<c><anno>Port</anno></c> is a closed port nothing happens. If <c><anno>Port</anno></c>
is an open port and the calling process is the port owner,
the port replies with <c>{Port, closed}</c> when all buffers
have been flushed and the port really closes, but if
the calling process is not the port owner the <em>port owner</em> fails with <c>badsig</c>.</p>
<p>Note that any process can close a port using
<c><anno>Port</anno> ! {PortOwner, close}</c> just as if it itself was
the port owner, but the reply always goes to the port owner.</p>
<p>As of OTP-R16 <c><anno>Port</anno> ! {PortOwner, close}</c> is truly
asynchronous. Note that this operation has always been
documented as an asynchronous operation, while the underlying
implementation has been synchronous. <c>port_close/1</c> is
however still fully synchronous. This due to its error
behavior.</p>
<p>Failure:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Port</anno></c> is not an identifier of an open
port, or the registered name of an open port. If the calling
process was linked to the previously open port identified by
<c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to this exception.
</item>
</taglist>
</desc>
</func>
<func>
<name name="port_command" arity="2"/>
<fsummary>Send data to a port</fsummary>
<desc>
<p>Sends data to a port. Same as
<c><anno>Port</anno> ! {PortOwner, {command, Data}}</c> except for the error
behaviour and being synchronous (see below). Any process may
send data to a port with <c>port_command/2</c>, not only the
port owner (the connected process).</p>
<p>For comparison: <c><anno>Port</anno> ! {PortOwner, {command, Data}}</c>
fails with <c>badarg</c> if <c><anno>Port</anno></c> cannot be sent to
(i.e., <c><anno>Port</anno></c> refers neither to a port nor to a process).
If <c><anno>Port</anno></c> is a closed port the data message disappears
without a sound. If <c><anno>Port</anno></c> is open and the calling
process is not the port owner, the <em>port owner</em> fails
with <c>badsig</c>. The port owner fails with <c>badsig</c>
also if <c><anno>Data</anno></c> is not a valid IO list.</p>
<p>Note that any process can send to a port using
<c><anno>Port</anno> ! {PortOwner, {command, <anno>Data</anno>}}</c> just as if it
itself was the port owner.</p>
<p>If the port is busy, the calling process will be suspended
until the port is not busy anymore.</p>
<p>As of OTP-R16 <c><anno>Port</anno> ! {PortOwner, {command, Data}}</c> is
truly asynchronous. Note that this operation has always been
documented as an asynchronous operation, while the underlying
implementation has been synchronous. <c>port_command/2</c> is
however still fully synchronous. This due to its error
behavior.</p>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Port</anno></c> is not an identifier of an open
port, or the registered name of an open port. If the calling
process was linked to the previously open port identified by
<c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to this exception.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Data</anno></c> is not a valid io list.
</item>
</taglist>
</desc>
</func>
<func>
<name name="port_command" arity="3"/>
<fsummary>Send data to a port</fsummary>
<desc>
<p>Sends data to a port. <c>port_command(Port, Data, [])</c>
equals <c>port_command(Port, Data)</c>.</p>
<p>If the port command is aborted <c>false</c> is returned;
otherwise, <c>true</c> is returned.</p>
<p>If the port is busy, the calling process will be suspended
until the port is not busy anymore.</p>
<p>Currently the following <c><anno>Option</anno></c>s are valid:</p>
<taglist>
<tag><c>force</c></tag>
<item>The calling process will not be suspended if the port is
busy; instead, the port command is forced through. The
call will fail with a <c>notsup</c> exception if the
driver of the port does not support this. For more
information see the
<seealso marker="driver_entry#driver_flags"><![CDATA[ERL_DRV_FLAG_SOFT_BUSY]]></seealso>
driver flag.
</item>
<tag><c>nosuspend</c></tag>
<item>The calling process will not be suspended if the port is
busy; instead, the port command is aborted and
<c>false</c> is returned.
</item>
</taglist>
<note>
<p>More options may be added in the future.</p>
</note>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Port</anno></c> is not an identifier of an open
port, or the registered name of an open port. If the calling
process was linked to the previously open port identified by
<c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to this exception.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Data</anno></c> is not a valid io list.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>OptionList</anno></c> is not a valid option list.
</item>
<tag><c>notsup</c></tag>
<item>
If the <c>force</c> option has been passed, but the
driver of the port does not allow forcing through
a busy port.
</item>
</taglist>
</desc>
</func>
<func>
<name name="port_connect" arity="2"/>
<fsummary>Set the owner of a port</fsummary>
<desc>
<p>Sets the port owner (the connected port) to <c><anno>Pid</anno></c>.
Roughly the same as <c><anno>Port</anno> ! {Owner, {connect, <anno>Pid</anno>}}</c>
except for the following:</p>
<list type="bulleted">
<item>
<p>The error behavior differs, see below.</p>
</item>
<item>
<p>The port does <em>not</em> reply with
<c>{Port,connected}</c>.</p>
</item>
<item>
<p><c>port_connect/1</c> is synchronous, see below.</p>
</item>
<item>
<p>The new port owner gets linked to the port.</p>
</item>
</list>
<p>The old port owner stays linked to the port and have to call
<c>unlink(Port)</c> if this is not desired. Any process may
set the port owner to be any process with
<c>port_connect/2</c>.</p>
<p>For comparison: <c><anno>Port</anno> ! {self(), {connect, <anno>Pid</anno>}}</c> fails
with <c>badarg</c> if <c><anno>Port</anno></c> cannot be sent to (i.e.,
<c><anno>Port</anno></c> refers neither to a port nor to a process). If
<c><anno>Port</anno></c> is a closed port nothing happens. If <c><anno>Port</anno></c>
is an open port and the calling process is the port owner,
the port replies with <c>{Port, connected}</c> to the old
port owner. Note that the old port owner is still linked to
the port, and that the new is not. If <c><anno>Port</anno></c> is an open
port and the calling process is not the port owner,
the <em>port owner</em> fails with <c>badsig</c>. The port
owner fails with <c>badsig</c> also if <c><anno>Pid</anno></c> is not an
existing local pid.</p>
<p>Note that any process can set the port owner using
<c><anno>Port</anno> ! {PortOwner, {connect, <anno>Pid</anno>}}</c> just as if it
itself was the port owner, but the reply always goes to
the port owner.</p>
<p>As of OTP-R16 <c><anno>Port</anno> ! {PortOwner, {connect, <anno>Pid</anno>}}</c> is
truly asynchronous. Note that this operation has always been
documented as an asynchronous operation, while the underlying
implementation has been synchronous. <c>port_connect/2</c> is
however still fully synchronous. This due to its error
behavior.</p>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Port</anno></c> is not an identifier of an open
port, or the registered name of an open port. If the calling
process was linked to the previously open port identified by
<c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to this exception.
</item>
<tag><c>badarg</c></tag>
<item>If process identified by <c>Pid</c> is not an existing
local process.</item>
</taglist>
</desc>
</func>
<func>
<name name="port_control" arity="3"/>
<fsummary>Perform a synchronous control operation on a port</fsummary>
<desc>
<p>Performs a synchronous control operation on a port.
The meaning of <c><anno>Operation</anno></c> and <c><anno>Data</anno></c> depends on
the port, i.e., on the port driver. Not all port drivers
support this control feature.</p>
<p>Returns: a list of integers in the range 0 through 255, or a
binary, depending on the port driver. The meaning of
the returned data also depends on the port driver.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not an open port or
the registered name of an open port, if <c><anno>Operation</anno></c>
cannot fit in a 32-bit integer, if the port driver does not
support synchronous control operations, or if the port driver
so decides for any reason (probably something wrong with
<c><anno>Operation</anno></c> or <c><anno>Data</anno></c>).</p>
</desc>
</func>
<func>
<name name="port_call" arity="3"/>
<fsummary>Synchronous call to a port with term data</fsummary>
<desc>
<p>Performs a synchronous call to a port. The meaning of
<c><anno>Operation</anno></c> and <c><anno>Data</anno></c> depends on the port, i.e.,
on the port driver. Not all port drivers support this feature.</p>
<p><c><anno>Port</anno></c> is a port identifier, referring to a driver.</p>
<p><c><anno>Operation</anno></c> is an integer, which is passed on to
the driver.</p>
<p><c><anno>Data</anno></c> is any Erlang term. This data is converted to
binary term format and sent to the port.</p>
<p>Returns: a term from the driver. The meaning of the returned
data also depends on the port driver.</p>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Port</anno></c> is not an identifier of an open
port, or the registered name of an open port. If the calling
process was linked to the previously open port identified by
<c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to this exception.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Operation</anno></c> does not fit in a
32-bit integer.
</item>
<tag><c>badarg</c></tag>
<item>
If the port driver does not support synchronous control
operations.
</item>
<tag><c>badarg</c></tag>
<item>
If the port driver so decides for any reason (probably
something wrong with <c><anno>Operation</anno></c>, or
<c><anno>Data</anno></c>).
</item>
</taglist>
</desc>
</func>
<func>
<name name="port_info" arity="1"/>
<fsummary>Information about a port</fsummary>
<desc>
<p>Returns a list containing tuples with information about
the <c><anno>Port</anno></c>, or <c>undefined</c> if the port is not open.
The order of the tuples is not defined, nor are all the
tuples mandatory.
If <c>undefined</c> is returned and the calling process
was linked to a previously open port identified by
<c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/1</c>.</p>
<p>Currently the result will containt information about the
following <c>Item</c>s: <c>registered_name</c> (if the port has
a registered name), <c>id</c>, <c>connected</c>, <c>links</c>,
<c>name</c>, <c>input</c>, and <c>output</c>. For more information
about the different <c>Item</c>s, see
<seealso marker="#port_info/2">port_info/2</seealso>.</p>
<p>Failure: <c>badarg</c> if <c>Port</c> is not a local port
identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="1"/>
<fsummary>Information about the connected process of a port</fsummary>
<desc>
<p><c><anno>Pid</anno></c> is the process identifier of the process
connected to the port.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="2"/>
<fsummary>Information about the internal index of a port</fsummary>
<desc>
<p><c><anno>Index</anno></c> is the internal index of the port. This
index may be used to separate ports.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="3"/>
<fsummary>Information about the input of a port</fsummary>
<desc>
<p><c><anno>Bytes</anno></c> is the total number of bytes
read from the port.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="4"/>
<fsummary>Information about the links of a port</fsummary>
<desc>
<p><c><anno>Pids</anno></c> is a list of the process identifiers
of the processes that the port is linked to.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="5"/>
<fsummary>Information about the locking of a port</fsummary>
<desc>
<p><c><anno>Locking</anno></c> is currently either <c>false</c>
(emulator without SMP support), <c>port_level</c> (port specific
locking), or <c>driver_level</c> (driver specific locking). Note
that these results are highly implementation specific and might
change in the future.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="6"/>
<fsummary>Information about the memory size of a port</fsummary>
<desc>
<p><c><anno>Bytes</anno></c> is the total amount of memory,
in bytes, allocated for this port by the runtime system. Note
that the port itself might have allocated memory which is not
included in <c><anno>Bytes</anno></c>.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="7"/>
<fsummary>Information about the monitors of a port</fsummary>
<desc>
<p><c><anno>Monitors</anno></c> represent processes that this port
is monitoring.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="8"/>
<fsummary>Information about the name of a port</fsummary>
<desc>
<p><c><anno>Name</anno></c> is the command name set by
<seealso marker="#open_port/2">open_port/2</seealso>.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="9"/>
<fsummary>Information about the OS pid of a port</fsummary>
<desc>
<p><c><anno>OsPid</anno></c> is the process identifier (or equivalent)
of an OS process created with
<seealso marker="#open_port/2">open_port({spawn | spawn_executable,
Command}, Options)</seealso>. If the port is not the result of spawning
an OS process, the value is <c>undefined</c>.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="10"/>
<fsummary>Information about the output of a port</fsummary>
<desc>
<p><c><anno>Bytes</anno></c> is the total number of bytes written
to the port from Erlang processes using either
<seealso marker="#port_command/2">port_command/2</seealso>,
<seealso marker="#port_command/3">port_command/3</seealso>,
or <c><anno>Port</anno> ! {Owner, {command, Data}</c>.
</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="11"/>
<fsummary>Information about the parallelism hint of a port</fsummary>
<desc>
<p><c><anno>Boolean</anno></c> corresponds to the port parallelism
hint being used by this port. For more information see
the <seealso marker="#open_port_parallelism">parallelism</seealso>
option of <seealso marker="#open_port/2">open_port/2</seealso>.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="12"/>
<fsummary>Information about the queue size of a port</fsummary>
<desc>
<p><c><anno>Bytes</anno></c> is the total amount of data,
in bytes, queued by the port using the ERTS driver queue
implementation.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_info" arity="2" clause_i="13"/>
<fsummary>Information about the registered name of a port</fsummary>
<desc>
<p><c><anno>RegisteredName</anno></c> is the registered name of
the port. If the port has no registered name, <c>[]</c> is returned.</p>
<p>If the port identified by <c><anno>Port</anno></c> is not open,
<c>undefined</c> is returned. If <c>undefined</c> is returned and
the calling process was linked to a previously open port identified
by <c><anno>Port</anno></c>, an exit signal due to this link
was received by the process prior to the return from
<c>port_info/2</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Port</anno></c> is not a local
port identifier, or an atom.</p>
</desc>
</func>
<func>
<name name="port_to_list" arity="1"/>
<fsummary>Text representation of a port identifier</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of the port identifier <c><anno>Port</anno></c>.</p>
<warning>
<p>This BIF is intended for debugging and for use in
the Erlang operating system. It should not be used in
application programs.</p>
</warning>
</desc>
</func>
<func>
<name name="ports" arity="0"/>
<fsummary>All open ports</fsummary>
<desc>
<p>Returns a list of port identifiers corresponding to all the
ports currently existing on the local node.</p>
<p>Note that a port that is exiting, exists but is not open.</p>
</desc>
</func>
<func>
<name name="pre_loaded" arity="0"/>
<fsummary>List of all pre-loaded modules</fsummary>
<desc>
<p>Returns a list of Erlang modules which are pre-loaded in
the system. As all loading of code is done through the file
system, the file system must have been loaded previously.
Hence, at least the module <c>init</c> must be pre-loaded.</p>
</desc>
</func>
<func>
<name name="process_display" arity="2"/>
<fsummary>Write information about a local process on standard error</fsummary>
<desc>
<p>Writes information about the local process <c><anno>Pid</anno></c> on
standard error. The currently allowed value for the atom
<c><anno>Type</anno></c> is <c>backtrace</c>, which shows the contents of
the call stack, including information about the call chain, with
the current function printed first. The format of the output
is not further defined.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="1"/>
<fsummary>Set process flag trap_exit for the calling process</fsummary>
<desc>
<p>When <c>trap_exit</c> is set to <c>true</c>, exit signals
arriving to a process are converted to <c>{'EXIT', From, Reason}</c> messages, which can be received as ordinary
messages. If <c>trap_exit</c> is set to <c>false</c>, the
process exits if it receives an exit signal other than
<c>normal</c> and the exit signal is propagated to its
linked processes. Application processes should normally
not trap exits.</p>
<p>Returns the old value of the flag.</p>
<p>See also <seealso marker="#exit/2">exit/2</seealso>.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="2"/>
<fsummary>Set process flag error_handler for the calling process</fsummary>
<desc>
<p>This is used by a process to redefine the error handler
for undefined function calls and undefined registered
processes. Inexperienced users should not use this flag
since code auto-loading is dependent on the correct
operation of the error handling module.</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="3"/>
<fsummary>Set process flag min_heap_size for the calling process</fsummary>
<desc>
<p>This changes the minimum heap size for the calling
process.</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="4"/>
<fsummary>Set process flag min_bin_vheap_size for the calling process</fsummary>
<desc>
<p>This changes the minimum binary virtual heap size for the calling
process.</p>
<p>Returns the old value of the flag.</p> </desc>
</func>
<marker id="process_flag_off_heap_message_queue"/>
<func>
<name name="process_flag" arity="2" clause_i="5"/>
<fsummary>Set process flag <c>off_heap_message_queue</c> for the calling process</fsummary>
<desc>
<p>This flag determines how messages in the message queue
are stored. When the flag is:</p>
<taglist>
<tag><c>true</c></tag>
<item><p>
<em>All</em> messages in the message queue will be stored
outside of the process heap. This implies that <em>no</em>
messages in the message queue will be part of a garbage
collection of the process.
</p></item>
<tag><c>false</c></tag>
<item><p>
Messages may be placed either on the heap or outside
of the heap.
</p></item>
</taglist>
<p>
If the process potentially may get a hugh amount of messages,
you are recommended to set the flag to <c>true</c>. This since
a garbage collection with lots of messages placed on the heap
may become extremly expensive. Performance of the actual
message passing is however generally better when setting the
flag to <c>false</c>.
</p>
<p>
When changing this flag from <c>false</c> to <c>true</c>,
all messages in the message queue are moved off heap. This
work has been initiated but not completed when this function
call returns.
</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="6"/>
<type name="priority_level"/>
<fsummary>Set process flag priority for the calling process</fsummary>
<desc>
<p><marker id="process_flag_priority"></marker>
This sets the process priority. <c><anno>Level</anno></c> is an atom.
There are currently four priority levels: <c>low</c>,
<c>normal</c>, <c>high</c>, and <c>max</c>. The default
priority level is <c>normal</c>. <em>NOTE</em>: The
<c>max</c> priority level is reserved for internal use in
the Erlang runtime system, and should <em>not</em> be used
by others.
</p>
<p>Internally in each priority level processes are scheduled
in a round robin fashion.
</p>
<p>Execution of processes on priority <c>normal</c> and
priority <c>low</c> will be interleaved. Processes on
priority <c>low</c> will be selected for execution less
frequently than processes on priority <c>normal</c>.
</p>
<p>When there are runnable processes on priority <c>high</c>
no processes on priority <c>low</c>, or <c>normal</c> will
be selected for execution. Note, however, that this does
<em>not</em> mean that no processes on priority <c>low</c>,
or <c>normal</c> will be able to run when there are
processes on priority <c>high</c> running. On the runtime
system with SMP support there might be more processes running
in parallel than processes on priority <c>high</c>, i.e.,
a <c>low</c>, and a <c>high</c> priority process might
execute at the same time.
</p>
<p>When there are runnable processes on priority <c>max</c>
no processes on priority <c>low</c>, <c>normal</c>, or
<c>high</c> will be selected for execution. As with the
<c>high</c> priority, processes on lower priorities might
execute in parallel with processes on priority <c>max</c>.
</p>
<p>Scheduling is preemptive. Regardless of priority, a process
is preempted when it has consumed more than a certain amount
of reductions since the last time it was selected for
execution.
</p>
<p><em>NOTE</em>: You should not depend on the scheduling
to remain exactly as it is today. Scheduling, at least on
the runtime system with SMP support, is very likely to be
modified in the future in order to better utilize available
processor cores.
</p>
<p>There is currently <em>no</em> automatic mechanism for
avoiding priority inversion, such as priority inheritance,
or priority ceilings. When using priorities you have
to take this into account and handle such scenarios by
yourself.
</p>
<p>Making calls from a <c>high</c> priority process into code
that you don't have control over may cause the <c>high</c>
priority process to wait for a processes with lower
priority, i.e., effectively decreasing the priority of the
<c>high</c> priority process during the call. Even if this
isn't the case with one version of the code that you don't
have under your control, it might be the case in a future
version of it. This might, for example, happen if a
<c>high</c> priority process triggers code loading, since
the code server runs on priority <c>normal</c>.
</p>
<p>Other priorities than <c>normal</c> are normally not needed.
When other priorities are used, they need to be used
with care, especially the <c>high</c> priority <em>must</em>
be used with care. A process on <c>high</c> priority should
only perform work for short periods of time. Busy looping for
long periods of time in a <c>high</c> priority process will
most likely cause problems, since there are important servers
in OTP running on priority <c>normal</c>.
</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="7"/>
<fsummary>Set process flag save_calls for the calling process</fsummary>
<desc>
<p><c><anno>N</anno></c> must be an integer in the interval 0..10000.
If <c><anno>N</anno></c> > 0, call saving is made active for the
process, which means that information about the <c><anno>N</anno></c>
most recent global function calls, BIF calls, sends and
receives made by the process are saved in a list, which
can be retrieved with
<c>process_info(Pid, last_calls)</c>. A global function
call is one in which the module of the function is
explicitly mentioned. Only a fixed amount of information
is saved: a tuple <c>{Module, Function, Arity}</c> for
function calls, and the mere atoms <c>send</c>,
<c>'receive'</c> and <c>timeout</c> for sends and receives
(<c>'receive'</c> when a message is received and
<c>timeout</c> when a receive times out). If <c>N</c> = 0,
call saving is disabled for the process, which is the
default. Whenever the size of the call saving list is set,
its contents are reset.</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="2" clause_i="8"/>
<fsummary>Set process flag sensitive for the calling process</fsummary>
<desc>
<p>Set or clear the <c>sensitive</c> flag for the current process.
When a process has been marked as sensitive by calling
<c>process_flag(sensitive, true)</c>, features in the run-time
system that can be used for examining the data and/or inner working
of the process are silently disabled.</p>
<p>Features that are disabled include (but are not limited to)
the following:</p>
<p>Tracing: Trace flags can still be set for the process, but no
trace messages of any kind will be generated.
(If the <c>sensitive</c> flag is turned off, trace messages will
again be generated if there are any trace flags set.)</p>
<p>Sequential tracing: The sequential trace token will be propagated
as usual, but no sequential trace messages will be generated.</p>
<p><c>process_info/1,2</c> cannot be used to read out the message
queue or the process dictionary (both will be returned as empty lists).</p>
<p>Stack back-traces cannot be displayed for the process.</p>
<p>In crash dumps, the stack, messages, and the process dictionary
will be omitted.</p>
<p>If <c>{save_calls,N}</c> has been set for the process, no
function calls will be saved to the call saving list.
(The call saving list will not be cleared; furthermore, send, receive,
and timeout events will still be added to the list.)</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="process_flag" arity="3"/>
<fsummary>Set process flags for a process</fsummary>
<desc>
<p>Sets certain flags for the process <c><anno>Pid</anno></c>, in the same
manner as
<seealso marker="#process_flag/2">process_flag/2</seealso>.
Returns the old value of the flag. The allowed values for
<c><anno>Flag</anno></c> are only a subset of those allowed in
<c>process_flag/2</c>, namely: <c>save_calls</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Pid</anno></c> is not a local process.</p>
</desc>
</func>
<func>
<name name="process_info" arity="1"/>
<type name="process_info_result_item"/>
<type name="priority_level"/>
<type name="stack_item"/>
<fsummary>Information about a process</fsummary>
<desc>
<p>Returns a list containing <c><anno>InfoTuple</anno></c>s with
miscellaneous information about the process identified by
<c>Pid</c>, or <c>undefined</c> if the process is not alive.
</p>
<p>
The order of the <c><anno>InfoTuple</anno></c>s is not defined, nor
are all the <c><anno>InfoTuple</anno></c>s mandatory. The <c><anno>InfoTuple</anno></c>s
part of the result may be changed without prior notice.
Currently <c><anno>InfoTuple</anno></c>s with the following items
are part of the result:
<c>current_function</c>, <c>initial_call</c>, <c>status</c>,
<c>message_queue_len</c>, <c>messages</c>, <c>links</c>,
<c>dictionary</c>, <c>trap_exit</c>, <c>error_handler</c>,
<c>priority</c>, <c>group_leader</c>, <c>total_heap_size</c>,
<c>heap_size</c>, <c>stack_size</c>, <c>reductions</c>, and
<c>garbage_collection</c>.
If the process identified by <c><anno>Pid</anno></c> has a registered name
also an <c><anno>InfoTuple</anno></c> with the item <c>registered_name</c>
will appear.
</p>
<p>See <seealso marker="#process_info/2">process_info/2</seealso>
for information about specific <c><anno>InfoTuple</anno></c>s.</p>
<warning>
<p>This BIF is intended for <em>debugging only</em>, use
<seealso marker="#process_info/2">process_info/2</seealso>
for all other purposes.
</p>
</warning>
<p>Failure: <c>badarg</c> if <c>Pid</c> is not a local process.</p>
</desc>
</func>
<func>
<name name="process_info" arity="2" clause_i="1"/>
<name name="process_info" arity="2" clause_i="2"/>
<type name="process_info_item"/>
<type name="process_info_result_item"/>
<type name="stack_item"/>
<type name="priority_level"/>
<fsummary>Information about a process</fsummary>
<desc>
<p>Returns information about the process identified by <c><anno>Pid</anno></c>
as specified by the <c><anno>Item</anno></c> or the <c><anno>ItemList</anno></c>, or <c>undefined</c> if the
process is not alive.
</p>
<p>If the process is alive and a single <c><anno>Item</anno></c> is given,
the returned value is the corresponding
<c><anno>InfoTuple</anno></c> unless <c>Item =:= registered_name</c>
and the process has no registered name. In this case
<c>[]</c> is returned. This strange behavior is due to
historical reasons, and is kept for backward compatibility.
</p>
<p>If an <c>ItemList</c> is given, the result is an
<c><anno>InfoTupleList</anno></c>. The <c><anno>InfoTuple</anno></c>s in the
<c><anno>InfoTupleList</anno></c> will appear with the corresponding
<c><anno>Item</anno></c>s in the same order as the <c><anno>Item</anno></c>s appeared
in the <c><anno>ItemList</anno></c>. Valid <c><anno>Item</anno></c>s may appear multiple
times in the <c><anno>ItemList</anno></c>.
</p>
<note><p>If <c>registered_name</c> is part of an <c><anno>ItemList</anno></c>
and the process has no name registered a
<c>{registered_name, []}</c> <c><anno>InfoTuple</anno></c> <em>will</em>
appear in the resulting <c><anno>InfoTupleList</anno></c>. This
behavior is different than when a single
<c>Item =:= registered_name</c> is given, and than when
<c>process_info/1</c> is used.
</p></note>
<p>Currently the following <c><anno>InfoTuple</anno></c>s with corresponding
<c><anno>Item</anno></c>s are valid:</p>
<taglist>
<tag><c>{backtrace, <anno>Bin</anno>}</c></tag>
<item>
<p>The binary <c><anno>Bin</anno></c> contains the same information as
the output from
<c>erlang:process_display(<anno>Pid</anno>, backtrace)</c>. Use
<c>binary_to_list/1</c> to obtain the string of characters
from the binary.</p>
</item>
<tag><c>{binary, <anno>BinInfo</anno>}</c></tag>
<item>
<p><c><anno>BinInfo</anno></c> is a list containing miscellaneous information
about binaries currently being referred to by this process.
This <c><anno>InfoTuple</anno></c> may be changed or removed without prior
notice.</p>
</item>
<tag><c>{catchlevel, <anno>CatchLevel</anno>}</c></tag>
<item>
<p><c><anno>CatchLevel</anno></c> is the number of currently active
catches in this process. This <c><anno>InfoTuple</anno></c> may be
changed or removed without prior notice.</p>
</item>
<tag><c>{current_function, {<anno>Module</anno>, <anno>Function</anno>, <anno>Arity</anno>}}</c></tag>
<item>
<p><c><anno>Module</anno></c>, <c><anno>Function</anno></c>, <c><anno>Arity</anno></c> is
the current function call of the process.</p>
</item>
<tag><c>{current_location, {<anno>Module</anno>, <anno>Function</anno>, <anno>Arity</anno>, <anno>Location</anno>}}</c></tag>
<item>
<p><c><anno>Module</anno></c>, <c><anno>Function</anno></c>, <c><anno>Arity</anno></c> is
the current function call of the process.
<c><anno>Location</anno></c> is a list of two-tuples that describes the
location in the source code.
</p>
</item>
<tag><c>{current_stacktrace, <anno>Stack</anno>}</c></tag>
<item>
<p>Return the current call stack back-trace (<em>stacktrace</em>)
of the process. The stack has the same format as returned by
<seealso marker="#get_stacktrace/0">erlang:get_stacktrace/0</seealso>.
</p>
</item>
<tag><c>{dictionary, <anno>Dictionary</anno>}</c></tag>
<item>
<p><c><anno>Dictionary</anno></c> is the dictionary of the process.</p>
</item>
<tag><c>{error_handler, <anno>Module</anno>}</c></tag>
<item>
<p><c><anno>Module</anno></c> is the error handler module used by
the process (for undefined function calls, for example).</p>
</item>
<tag><c>{garbage_collection, <anno>GCInfo</anno>}</c></tag>
<item>
<p><c><anno>GCInfo</anno></c> is a list which contains miscellaneous
information about garbage collection for this process.
The content of <c><anno>GCInfo</anno></c> may be changed without
prior notice.</p>
</item>
<tag><c>{group_leader, <anno>GroupLeader</anno>}</c></tag>
<item>
<p><c><anno>GroupLeader</anno></c> is group leader for the IO of
the process.</p>
</item>
<tag><c>{heap_size, <anno>Size</anno>}</c></tag>
<item>
<p><c><anno>Size</anno></c> is the size in words of youngest heap generation
of the process. This generation currently include the stack
of the process. This information is highly implementation
dependent, and may change if the implementation change.
</p>
</item>
<tag><c>{initial_call, {Module, Function, Arity}}</c></tag>
<item>
<p><c>Module</c>, <c>Function</c>, <c>Arity</c> is
the initial function call with which the process was
spawned.</p>
</item>
<tag><c>{links, <anno>PidsAndPorts</anno>}</c></tag>
<item>
<p><c><anno>PidsAndPorts</anno></c> is a list of pids and
port identifiers, with processes or ports to which the process
has a link.</p>
</item>
<tag><c>{last_calls, false|Calls}</c></tag>
<item>
<p>The value is <c>false</c> if call saving is not active
for the process (see
<seealso marker="#process_flag/3">process_flag/3</seealso>).
If call saving is active, a list is returned, in which
the last element is the most recent called.</p>
</item>
<tag><c>{memory, <anno>Size</anno>}</c></tag>
<item>
<p><c><anno>Size</anno></c> is the size in bytes of the process. This
includes call stack, heap and internal structures.</p>
</item>
<tag><c>{message_queue_len, <anno>MessageQueueLen</anno>}</c></tag>
<item>
<p><c><anno>MessageQueueLen</anno></c> is the number of messages
currently in the message queue of the process. This is
the length of the list <c><anno>MessageQueue</anno></c> returned as
the info item <c>messages</c> (see below).</p>
</item>
<tag><c>{messages, <anno>MessageQueue</anno>}</c></tag>
<item>
<p><c><anno>MessageQueue</anno></c> is a list of the messages to
the process, which have not yet been processed.</p>
</item>
<tag><c>{min_heap_size, <anno>MinHeapSize</anno>}</c></tag>
<item>
<p><c><anno>MinHeapSize</anno></c> is the minimum heap size for the process.</p>
</item>
<tag><c>{min_bin_vheap_size, <anno>MinBinVHeapSize</anno>}</c></tag>
<item>
<p><c><anno>MinBinVHeapSize</anno></c> is the minimum binary virtual heap size for the process.</p>
</item>
<tag><c>{monitored_by, <anno>Pids</anno>}</c></tag>
<item>
<p>A list of pids that are monitoring the process (with
<c>monitor/2</c>).</p>
</item>
<tag><c>{monitors, <anno>Monitors</anno>}</c></tag>
<item>
<p>A list of monitors (started by <c>monitor/2</c>)
that are active for the process. For a local process
monitor or a remote process monitor by pid, the list item
is <c>{process, <anno>Pid</anno>}</c>, and for a remote process
monitor by name, the list item is
<c>{process, {<anno>RegName</anno>, <anno>Node</anno>}}</c>.</p>
</item>
<tag><c>{off_heap_message_queue, <anno>OHMQ</anno>}</c></tag>
<item>
<p>Returns the current state of the <c>off_heap_message_queue</c>
process flag. <c><anno>OHMQ</anno></c> is either <c>true</c>, or
<c>false</c>. For more information, see the documentation of
<seealso marker="#process_flag_off_heap_message_queue"><c>process_flag(off_heap_message_queue,
OHMQ)</c></seealso>.</p>
</item>
<tag><c>{priority, Level}</c></tag>
<item>
<p><c><anno>Level</anno></c> is the current priority level for
the process. For more information on priorities see
<seealso marker="#process_flag_priority">process_flag(priority, Level)</seealso>.</p>
</item>
<tag><c>{reductions, <anno>Number</anno>}</c></tag>
<item>
<p><c><anno>Number</anno></c> is the number of reductions executed by
the process.</p>
</item>
<tag><c>{registered_name, <anno>Atom</anno>}</c></tag>
<item>
<p><c><anno>Atom</anno></c> is the registered name of the process. If
the process has no registered name, this tuple is not
present in the list.</p>
</item>
<tag><c>{sequential_trace_token, [] | <anno>SequentialTraceToken</anno>}</c></tag>
<item>
<p><c><anno>SequentialTraceToken</anno></c> the sequential trace token for
the process. This <c><anno>InfoTuple</anno></c> may be changed or removed
without prior notice.</p>
</item>
<tag><c>{stack_size, <anno>Size</anno>}</c></tag>
<item>
<p><c><anno>Size</anno></c> is the stack size of the process in words.</p>
</item>
<tag><c>{status, <anno>Status</anno>}</c></tag>
<item>
<p><c><anno>Status</anno></c> is the status of the process. <c><anno>Status</anno></c>
is <c>exiting</c>, <c>garbage_collecting</c>,
<c>waiting</c> (for a message), <c>running</c>,
<c>runnable</c> (ready to run, but another process is
running), or <c>suspended</c> (suspended on a "busy" port
or by the <c>erlang:suspend_process/[1,2]</c> BIF).</p>
</item>
<tag><c>{suspending, <anno>SuspendeeList</anno>}</c></tag>
<item>
<p><c><anno>SuspendeeList</anno></c> is a list of <c>{<anno>Suspendee</anno>,
<anno>ActiveSuspendCount</anno>, <anno>OutstandingSuspendCount</anno>}</c> tuples.
<c><anno>Suspendee</anno></c> is the pid of a process that have been or is to
be suspended by the process identified by <c><anno>Pid</anno></c> via the
<seealso marker="#suspend_process/2">erlang:suspend_process/2</seealso>
BIF, or the
<seealso marker="#suspend_process/1">erlang:suspend_process/1</seealso>
BIF. <c><anno>ActiveSuspendCount</anno></c> is the number of times the
<c><anno>Suspendee</anno></c> has been suspended by <c><anno>Pid</anno></c>.
<c><anno>OutstandingSuspendCount</anno></c> is the number of not yet
completed suspend requests sent by <c><anno>Pid</anno></c>. That is,
if <c><anno>ActiveSuspendCount</anno> =/= 0</c>, <c><anno>Suspendee</anno></c> is
currently in the suspended state, and if
<c><anno>OutstandingSuspendCount</anno> =/= 0</c> the <c>asynchronous</c>
option of <c>erlang:suspend_process/2</c> has been used and
the suspendee has not yet been suspended by <c><anno>Pid</anno></c>.
Note that the <c><anno>ActiveSuspendCount</anno></c> and
<c><anno>OutstandingSuspendCount</anno></c> are not the total suspend count
on <c><anno>Suspendee</anno></c>, only the parts contributed by <c>Pid</c>.
</p>
</item>
<tag><c>{total_heap_size, <anno>Size</anno>}</c></tag>
<item>
<p><c><anno>Size</anno></c> is the total size in words of all heap
fragments of the process. This currently include the stack
of the process.
</p>
</item>
<tag><c>{trace, <anno>InternalTraceFlags</anno>}</c></tag>
<item>
<p><c><anno>InternalTraceFlags</anno></c> is an integer representing
internal trace flag for this process. This <c><anno>InfoTuple</anno></c>
may be changed or removed without prior notice.</p>
</item>
<tag><c>{trap_exit, <anno>Boolean</anno>}</c></tag>
<item>
<p><c><anno>Boolean</anno></c> is <c>true</c> if the process is trapping
exits, otherwise it is <c>false</c>.</p>
</item>
</taglist>
<p>Note however, that not all implementations support every one
of the above <c><anno>Item</anno></c>s.</p>
<p>Failure: <c>badarg</c> if <c><anno>Pid</anno></c> is not a local process,
or if <c><anno>Item</anno></c> is not a valid <c><anno>Item</anno></c>.</p>
</desc>
</func>
<func>
<name name="processes" arity="0"/>
<fsummary>All processes</fsummary>
<desc>
<p>Returns a list of process identifiers corresponding to
all the processes currently existing on the local node.
</p>
<p>Note that a process that is exiting, exists but is not alive, i.e.,
<c>is_process_alive/1</c> will return <c>false</c> for a process
that is exiting, but its process identifier will be part
of the result returned from <c>processes/0</c>.
</p>
<pre>
> <input>processes().</input>
[<0.0.0>,<0.2.0>,<0.4.0>,<0.5.0>,<0.7.0>,<0.8.0>]</pre>
</desc>
</func>
<func>
<name name="purge_module" arity="1"/>
<fsummary>Remove old code for a module</fsummary>
<desc>
<p>Removes old code for <c><anno>Module</anno></c>. Before this BIF is used,
<c>erlang:check_process_code/2</c> should be called to check
that no processes are executing old code in the module.</p>
<warning>
<p>This BIF is intended for the code server (see
<seealso marker="kernel:code">code(3)</seealso>) and should not be
used elsewhere.</p>
</warning>
<p>Failure: <c>badarg</c> if there is no old code for
<c><anno>Module</anno></c>.</p>
</desc>
</func>
<func>
<name name="put" arity="2"/>
<fsummary>Add a new value to the process dictionary</fsummary>
<desc>
<p>Adds a new <c><anno>Key</anno></c> to the process dictionary, associated
with the value <c><anno>Val</anno></c>, and returns <c>undefined</c>. If
<c><anno>Key</anno></c> already exists, the old value is deleted and
replaced by <c><anno>Val</anno></c> and the function returns the old value.</p>
<note>
<p>The values stored when <c>put</c> is evaluated within
the scope of a <c>catch</c> will not be retracted if a
<c>throw</c> is evaluated, or if an error occurs.</p>
</note>
<pre>
> <input>X = put(name, walrus), Y = put(name, carpenter),</input>
<input>Z = get(name),</input>
<input>{X, Y, Z}.</input>
{undefined,walrus,carpenter}</pre>
</desc>
</func>
<func>
<name name="raise" arity="3"/>
<type name="raise_stacktrace"/>
<fsummary>Stop execution with an exception of given class, reason and call stack backtrace</fsummary>
<desc>
<p>Stops the execution of the calling process with an
exception of given class, reason and call stack backtrace
(<em>stacktrace</em>).</p>
<warning>
<p>This BIF is intended for debugging and for use in
the Erlang operating system. In general, it should
be avoided in applications, unless you know
very well what you are doing.</p>
</warning>
<p><c><anno>Class</anno></c> is one of <c>error</c>, <c>exit</c> or
<c>throw</c>, so if it were not for the stacktrace
<c>erlang:raise(<anno>Class</anno>, <anno>Reason</anno>, <anno>Stacktrace</anno>)</c> is
equivalent to <c>erlang:<anno>Class</anno>(<anno>Reason</anno>)</c>.
<c><anno>Reason</anno></c> is any term and <c><anno>Stacktrace</anno></c> is a list as
returned from <c>get_stacktrace()</c>, that is a list of
4-tuples <c>{Module, Function, Arity | Args,
Location}</c> where <c>Module</c> and <c>Function</c>
are atoms and the third element is an integer arity or an
argument list. The stacktrace may also contain <c>{Fun,
Args, Location}</c> tuples where
<c>Fun</c> is a local fun and <c>Args</c> is an argument list.</p>
<p>The <c>Location</c> element at the end is optional.
Omitting it is equivalent to specifying an empty list.</p>
<p>The stacktrace is used as the exception stacktrace for the
calling process; it will be truncated to the current
maximum stacktrace depth.</p>
<p>Because evaluating this function causes the process to
terminate, it has no return value - unless the arguments are
invalid, in which case the function <em>returns the error reason</em>, that is <c>badarg</c>. If you want to be
really sure not to return you can call
<c>error(erlang:raise(<anno>Class</anno>, <anno>Reason</anno>, <anno>Stacktrace</anno>))</c>
and hope to distinguish exceptions later.</p>
</desc>
</func>
<func>
<name name="read_timer" arity="2"/>
<fsummary>Read the state of a timer</fsummary>
<desc>
<p>
Read the state of a timer that has been created by either
<seealso marker="#start_timer/4"><c>erlang:start_timer()</c></seealso>,
or <seealso marker="#send_after/4"><c>erlang:send_after()</c></seealso>.
<c><anno>TimerRef</anno></c> identifies the timer, and
was returned by the BIF that created the timer.
</p>
<p>Currently available <c><anno>Option</anno>s</c>:</p>
<taglist>
<tag><c>{async, Async}</c></tag>
<item>
<p>
Asynchronous request for state information. <c>Async</c>
defaults to <c>false</c> which will cause the operation
to be performed synchronously. In this case, the <c>Result</c>
will be returned by <c>erlang:read_timer()</c>. When
<c>Async</c> is set to <c>true</c>, <c>erlang:read_timer()</c>
will send an asynchronous request for the state information
to the timer service that manages the timer, and then return
<c>ok</c>. A message on the format <c>{read_timer,
<anno>TimerRef</anno>, <anno>Result</anno>}</c> will be
sent to the caller of <c>erlang:read_timer()</c> when the
operation has been processed.
</p>
</item>
</taglist>
<p>
More <c><anno>Option</anno></c>s may be added in the future.
</p>
<p>
When the <c><anno>Result</anno></c> equals <c>false</c>, a
timer corresponding to <c><anno>TimerRef</anno></c> could not
be found. This can be either because the timer had expired,
had been canceled, or because <c><anno>TimerRef</anno></c>
never has corresponded to a timer. If the timer has expired,
the timeout message has been sent, but it does not tell you
whether or not it has arrived at its destination yet. When the
<c><anno>Result</anno></c> is an integer, it represents the
time in milli-seconds left until the timer will expire.
</p>
<note>
<p>
The timer service that manages the timer may be co-located
with another scheduler than the scheduler that the calling
process is executing on. If this is the case, communication
with the timer service will take much longer time than if it
is located locally. If the calling process is in critical
path, and can do other things while waiting for the result
of this operation you want to use the <c>{async, true}</c>
option. If using the <c>{async, false}</c> option, the calling
process will be blocked until the operation has been
performed.
</p>
</note>
<p>See also
<seealso marker="#send_after/4"><c>erlang:send_after/4</c></seealso>,
<seealso marker="#start_timer/4"><c>erlang:start_timer/4</c></seealso>,
and
<seealso marker="#cancel_timer/2"><c>erlang:cancel_timer/2</c></seealso>.</p>
</desc>
</func>
<func>
<name name="read_timer" arity="1"/>
<fsummary>Read the state of a timer</fsummary>
<desc>
<p>Read the state of a timer. The same as calling
<seealso marker="#read_timer/2"><c>erlang:read_timer(TimerRef,
[])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="ref_to_list" arity="1"/>
<fsummary>Text representation of a reference</fsummary>
<desc>
<p>Returns a string which corresponds to the text
representation of <c><anno>Ref</anno></c>.</p>
<warning>
<p>This BIF is intended for debugging and for use in
the Erlang operating system. It should not be used in
application programs.</p>
</warning>
</desc>
</func>
<func>
<name name="register" arity="2"/>
<fsummary>Register a name for a pid (or port)</fsummary>
<desc>
<p>Associates the name <c><anno>RegName</anno></c> with a pid or a port
identifier. <c><anno>RegName</anno></c>, which must be an atom, can be used
instead of the pid / port identifier in the send operator
(<c><anno>RegName</anno> ! Message</c>).</p>
<pre>
> <input>register(db, Pid).</input>
true</pre>
<p>Failure: <c>badarg</c> if <c><anno>PidOrPort</anno></c> is not an existing,
local process or port, if <c><anno>RegName</anno></c> is already in use,
if the process or port is already registered (already has a
name), or if <c><anno>RegName</anno></c> is the atom <c>undefined</c>.</p>
</desc>
</func>
<func>
<name name="registered" arity="0"/>
<fsummary>All registered names</fsummary>
<desc>
<p>Returns a list of names which have been registered using
<seealso marker="#register/2">register/2</seealso>.</p>
<pre>
> <input>registered().</input>
[code_server, file_server, init, user, my_db]</pre>
</desc>
</func>
<func>
<name name="resume_process" arity="1"/>
<fsummary>Resume a suspended process</fsummary>
<desc>
<p>Decreases the suspend count on the process identified by
<c><anno>Suspendee</anno></c>. <c><anno>Suspendee</anno></c> should previously have been
suspended via
<seealso marker="#suspend_process/2">erlang:suspend_process/2</seealso>,
or
<seealso marker="#suspend_process/1">erlang:suspend_process/1</seealso>
by the process calling <c>erlang:resume_process(<anno>Suspendee</anno>)</c>. When
the suspend count on <c><anno>Suspendee</anno></c> reach zero, <c><anno>Suspendee</anno></c>
will be resumed, i.e., the state of the <c>Suspendee</c> is changed
from suspended into the state <c><anno>Suspendee</anno></c> was in before it was
suspended.
</p>
<warning>
<p>This BIF is intended for debugging only.</p>
</warning>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Suspendee</anno></c> isn't a process identifier.
</item>
<tag><c>badarg</c></tag>
<item>
If the process calling <c>erlang:resume_process/1</c> had
not previously increased the suspend count on the process
identified by <c><anno>Suspendee</anno></c>.
</item>
<tag><c>badarg</c></tag>
<item>
If the process identified by <c><anno>Suspendee</anno></c> is not alive.
</item>
</taglist>
</desc>
</func>
<func>
<name name="round" arity="1"/>
<fsummary>Return an integer by rounding a number</fsummary>
<desc>
<p>Returns an integer by rounding <c><anno>Number</anno></c>.</p>
<pre>
> <input>round(5.5).</input>
6</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="self" arity="0"/>
<fsummary>Pid of the calling process</fsummary>
<desc>
<p>Returns the pid (process identifier) of the calling process.</p>
<pre>
> <input>self().</input>
<0.26.0></pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="send" arity="2"/>
<fsummary>Send a message</fsummary>
<type name="dst"/>
<desc>
<p>Sends a message and returns <c><anno>Msg</anno></c>. This is the same as
<c><anno>Dest</anno> ! <anno>Msg</anno></c>.</p>
<p><c><anno>Dest</anno></c> may be a remote or local pid, a (local) port, a
locally registered name, or a tuple <c>{<anno>RegName</anno>, <anno>Node</anno>}</c>
for a registered name at another node.</p>
</desc>
</func>
<func>
<name name="send" arity="3"/>
<type name="dst"/>
<fsummary>Send a message conditionally</fsummary>
<desc>
<p>Sends a message and returns <c>ok</c>, or does not send
the message but returns something else (see below). Otherwise
the same as
<seealso marker="#send/2">erlang:send/2</seealso>. See
also
<seealso marker="#send_nosuspend/2">erlang:send_nosuspend/2,3</seealso>.
for more detailed explanation and warnings.</p>
<p>The possible options are:</p>
<taglist>
<tag><c>nosuspend</c></tag>
<item>
<p>If the sender would have to be suspended to do the send,
<c>nosuspend</c> is returned instead.</p>
</item>
<tag><c>noconnect</c></tag>
<item>
<p>If the destination node would have to be auto-connected
before doing the send, <c>noconnect</c> is returned
instead.</p>
</item>
</taglist>
<warning>
<p>As with <c>erlang:send_nosuspend/2,3</c>: Use with extreme
care!</p>
</warning>
</desc>
</func>
<func>
<name name="send_after" arity="4"/>
<fsummary>Start a timer</fsummary>
<desc>
<p>
Starts a timer. When the timer expires, the message
<c><anno>Msg</anno></c> will be sent to the process
identified by <c><anno>Dest</anno></c>. Appart from
the format of the message sent to
<c><anno>Dest</anno></c> when the timer expires
<c>erlang:send_after/4</c> works exactly as
<seealso marker="#start_timer/4"><c>erlang:start_timer/4</c></seealso>.</p>
</desc>
</func>
<func>
<name name="send_after" arity="3"/>
<fsummary>Start a timer</fsummary>
<desc>
<p>Starts a timer. The same as calling
<seealso marker="#send_after/4"><c>erlang:send_after(<anno>Time</anno>,
<anno>Dest</anno>, <anno>Msg</anno>, [])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="send_nosuspend" arity="2"/>
<fsummary>Try to send a message without ever blocking</fsummary>
<type name="dst"/>
<desc>
<p>The same as
<seealso marker="#send/3">erlang:send(<anno>Dest</anno>, <anno>Msg</anno>, [nosuspend])</seealso>, but returns <c>true</c> if
the message was sent and <c>false</c> if the message was not
sent because the sender would have had to be suspended.</p>
<p>This function is intended for send operations towards an
unreliable remote node without ever blocking the sending
(Erlang) process. If the connection to the remote node
(usually not a real Erlang node, but a node written in C or
Java) is overloaded, this function <em>will not send the message</em> but return <c>false</c> instead.</p>
<p>The same happens, if <c><anno>Dest</anno></c> refers to a local port that
is busy. For all other destinations (allowed for the ordinary
send operator <c>'!'</c>) this function sends the message and
returns <c>true</c>.</p>
<p>This function is only to be used in very rare circumstances
where a process communicates with Erlang nodes that can
disappear without any trace causing the TCP buffers and
the drivers queue to be over-full before the node will actually
be shut down (due to tick timeouts) by <c>net_kernel</c>. The
normal reaction to take when this happens is some kind of
premature shutdown of the other node.</p>
<p>Note that ignoring the return value from this function would
result in <em>unreliable</em> message passing, which is
contradictory to the Erlang programming model. The message is
<em>not</em> sent if this function returns <c>false</c>.</p>
<p>Note also that in many systems, transient states of
overloaded queues are normal. The fact that this function
returns <c>false</c> does not in any way mean that the other
node is guaranteed to be non-responsive, it could be a
temporary overload. Also a return value of <c>true</c> does
only mean that the message could be sent on the (TCP) channel
without blocking, the message is not guaranteed to have
arrived at the remote node. Also in the case of a disconnected
non-responsive node, the return value is <c>true</c> (mimics
the behaviour of the <c>!</c> operator). The expected
behaviour as well as the actions to take when the function
returns <c>false</c> are application and hardware specific.</p>
<warning>
<p>Use with extreme care!</p>
</warning>
</desc>
</func>
<func>
<name name="send_nosuspend" arity="3"/>
<fsummary>Try to send a message without ever blocking</fsummary>
<type name="dst"/>
<desc>
<p>The same as
<seealso marker="#send/3">erlang:send(<anno>Dest</anno>, <anno>Msg</anno>, [nosuspend | <anno>Options</anno>])</seealso>,
but with boolean return value.</p>
<p>This function behaves like
<seealso marker="#send_nosuspend/2">erlang:send_nosuspend/2)</seealso>,
but takes a third parameter, a list of options. The only
currently implemented option is <c>noconnect</c>. The option
<c>noconnect</c> makes the function return <c>false</c> if
the remote node is not currently reachable by the local
node. The normal behaviour is to try to connect to the node,
which may stall the process for a shorter period. The use of
the <c>noconnect</c> option makes it possible to be
absolutely sure not to get even the slightest delay when
sending to a remote process. This is especially useful when
communicating with nodes who expect to always be
the connecting part (i.e. nodes written in C or Java).</p>
<p>Whenever the function returns <c>false</c> (either when a
suspend would occur or when <c>noconnect</c> was specified and
the node was not already connected), the message is guaranteed
<em>not</em> to have been sent.</p>
<warning>
<p>Use with extreme care!</p>
</warning>
</desc>
</func>
<func>
<name name="set_cookie" arity="2"/>
<fsummary>Set the magic cookie of a node</fsummary>
<desc>
<p>Sets the magic cookie of <c><anno>Node</anno></c> to the atom
<c><anno>Cookie</anno></c>. If <c><anno>Node</anno></c> is the local node, the function
also sets the cookie of all other unknown nodes to
<c><anno>Cookie</anno></c> (see
<seealso marker="doc/reference_manual:distributed">Distributed Erlang</seealso> in the Erlang Reference Manual).</p>
<p>Failure: <c>function_clause</c> if the local node is not
alive.</p>
</desc>
</func>
<func>
<name name="setelement" arity="3"/>
<type_desc variable="Index">1..tuple_size(<anno>Tuple1</anno>)</type_desc>
<fsummary>Set Nth element of a tuple</fsummary>
<desc>
<p>Returns a tuple which is a copy of the argument <c><anno>Tuple1</anno></c>
with the element given by the integer argument <c><anno>Index</anno></c>
(the first element is the element with index 1) replaced by
the argument <c><anno>Value</anno></c>.</p>
<pre>
> <input>setelement(2, {10, green, bottles}, red).</input>
{10,red,bottles}</pre>
</desc>
</func>
<func>
<name name="size" arity="1"/>
<fsummary>Size of a tuple or binary</fsummary>
<desc>
<p>Returns an integer which is the size of the argument
<c><anno>Item</anno></c>, which must be either a tuple or a binary.</p>
<pre>
> <input>size({morni, mulle, bwange}).</input>
3</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="spawn" arity="1"/>
<fsummary>Create a new process with a fun as entry point</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list <c>[]</c>. Otherwise works
like <seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn" arity="2"/>
<fsummary>Create a new process with a fun as entry point on a given node</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list <c>[]</c> on <c><anno>Node</anno></c>. If
<c><anno>Node</anno></c> does not exist, a useless pid is returned.
Otherwise works like
<seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn" arity="3"/>
<fsummary>Create a new process with a function as entry point</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Module</anno>:<anno>Function</anno></c> to <c><anno>Args</anno></c>. The new process
created will be placed in the system scheduler queue and be
run some time later.</p>
<p><c>error_handler:undefined_function(<anno>Module</anno>, <anno>Function</anno>, <anno>Args</anno>)</c> is evaluated by the new process if
<c><anno>Module</anno>:<anno>Function</anno>/Arity</c> does not exist (where
<c>Arity</c> is the length of <c><anno>Args</anno></c>). The error handler
can be redefined (see
<seealso marker="#process_flag/2">process_flag/2</seealso>).
If <c>error_handler</c> is undefined, or the user has
redefined the default <c>error_handler</c> its replacement is
undefined, a failure with the reason <c>undef</c> will occur.</p>
<pre>
> <input>spawn(speed, regulator, [high_speed, thin_cut]).</input>
<0.13.1></pre>
</desc>
</func>
<func>
<name name="spawn" arity="4"/>
<fsummary>Create a new process with a function as entry point on a given node</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Module</anno>:<anno>Function</anno></c> to <c><anno>Args</anno></c> on <c>Node</c>. If
<c><anno>Node</anno></c> does not exists, a useless pid is returned.
Otherwise works like
<seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_link" arity="1"/>
<fsummary>Create and link to a new process with a fun as entry point</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list []. A link is created between
the calling process and the new process, atomically.
Otherwise works like
<seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_link" arity="2"/>
<fsummary>Create and link to a new process with a fun as entry point on a specified node</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list [] on <c><anno>Node</anno></c>. A link is
created between the calling process and the new process,
atomically. If <c><anno>Node</anno></c> does not exist, a useless pid is
returned (and due to the link, an exit signal with exit
reason <c>noconnection</c> will be received). Otherwise works
like <seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_link" arity="3"/>
<fsummary>Create and link to a new process with a function as entry point</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Module</anno>:<anno>Function</anno></c> to <c><anno>Args</anno></c>. A link is created
between the calling process and the new process, atomically.
Otherwise works like
<seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_link" arity="4"/>
<fsummary>Create and link to a new process with a function as entry point on a given node</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Module</anno>:<anno>Function</anno></c> to <c><anno>Args</anno></c> on <c>Node</c>. A
link is created between the calling process and the new
process, atomically. If <c><anno>Node</anno></c> does not exist, a useless
pid is returned (and due to the link, an exit signal with exit
reason <c>noconnection</c> will be received). Otherwise works
like <seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_monitor" arity="1"/>
<fsummary>Create and monitor a new process with a fun as entry point</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list [] and reference for a monitor
created to the new process.
Otherwise works like
<seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_monitor" arity="3"/>
<fsummary>Create and monitor a new process with a function as entry point</fsummary>
<desc>
<p>A new process is started by the application
of <c><anno>Module</anno>:<anno>Function</anno></c> to <c><anno>Args</anno></c>, and the process is
monitored at the same time. Returns the pid and a reference
for the monitor.
Otherwise works like
<seealso marker="#spawn/3">spawn/3</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_opt" arity="2"/>
<type name="priority_level" />
<type name="spawn_opt_option" />
<fsummary>Create a new process with a fun as entry point</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list <c>[]</c>. Otherwise
works like
<seealso marker="#spawn_opt/4">spawn_opt/4</seealso>.</p>
<p>If the option <c>monitor</c> is given, the newly created
process will be monitored and both the pid and reference for
the monitor will be returned.</p>
</desc>
</func>
<func>
<name name="spawn_opt" arity="3"/>
<type name="priority_level" />
<type name="spawn_opt_option" />
<fsummary>Create a new process with a fun as entry point on a given node</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Fun</anno></c> to the empty list <c>[]</c> on <c><anno>Node</anno></c>. If
<c><anno>Node</anno></c> does not exist, a useless pid is returned.
Otherwise works like
<seealso marker="#spawn_opt/4">spawn_opt/4</seealso>.</p>
</desc>
</func>
<func>
<name name="spawn_opt" arity="4"/>
<type name="priority_level" />
<type name="spawn_opt_option" />
<fsummary>Create a new process with a function as entry point</fsummary>
<desc>
<p>Works exactly like
<seealso marker="#spawn/3">spawn/3</seealso>, except that an
extra option list is given when creating the process.</p>
<p>If the option <c>monitor</c> is given, the newly created
process will be monitored and both the pid and reference for
the monitor will be returned.</p>
<taglist>
<tag><c>link</c></tag>
<item>
<p>Sets a link to the parent process (like
<c>spawn_link/3</c> does).</p>
</item>
<tag><c>monitor</c></tag>
<item>
<p>Monitor the new process (just like
<seealso marker="#monitor/2">monitor/2</seealso> does).</p>
</item>
<tag><c>{priority, <anno>Level</anno>}</c></tag>
<item>
<p>Sets the priority of the new process. Equivalent to
executing
<seealso marker="#process_flag_priority">process_flag(priority, <anno>Level</anno>)</seealso> in the start function of the new process,
except that the priority will be set before the process is
selected for execution for the first time. For more information
on priorities see
<seealso marker="#process_flag_priority">process_flag(priority, Level)</seealso>.</p>
</item>
<tag><c>{fullsweep_after, <anno>Number</anno>}</c></tag>
<item>
<p>This option is only useful for performance tuning.
In general, you should not use this option unless you
know that there is problem with execution times and/or
memory consumption, and you should measure to make sure
that the option improved matters.
</p>
<p>The Erlang runtime system uses a generational garbage
collection scheme, using an "old heap" for data that has
survived at least one garbage collection. When there is
no more room on the old heap, a fullsweep garbage
collection will be done.</p>
<p>The <c>fullsweep_after</c> option makes it possible to
specify the maximum number of generational collections
before forcing a fullsweep even if there is still room on
the old heap. Setting the number to zero effectively
disables the general collection algorithm, meaning that
all live data is copied at every garbage collection.</p>
<p>Here are a few cases when it could be useful to change
<c>fullsweep_after</c>. Firstly, if binaries that are no
longer used should be thrown away as soon as possible.
(Set <c><anno>Number</anno></c> to zero.) Secondly, a process that
mostly have short-lived data will be fullsweeped seldom
or never, meaning that the old heap will contain mostly
garbage. To ensure a fullsweep once in a while, set
<c><anno>Number</anno></c> to a suitable value such as 10 or 20.
Thirdly, in embedded systems with limited amount of RAM
and no virtual memory, one might want to preserve memory
by setting <c><anno>Number</anno></c> to zero. (The value may be set
globally, see
<seealso marker="#system_flag/2">erlang:system_flag/2</seealso>.)</p>
</item>
<tag><c>{min_heap_size, <anno>Size</anno>}</c></tag>
<item>
<p>This option is only useful for performance tuning.
In general, you should not use this option unless you
know that there is problem with execution times and/or
memory consumption, and you should measure to make sure
that the option improved matters.
</p>
<p>Gives a minimum heap size in words. Setting this value
higher than the system default might speed up some
processes because less garbage collection is done.
Setting too high value, however, might waste memory and
slow down the system due to worse data locality.
Therefore, it is recommended to use this option only for
fine-tuning an application and to measure the execution
time with various <c><anno>Size</anno></c> values.</p>
</item>
<tag><c>{min_bin_vheap_size, <anno>VSize</anno>}</c></tag>
<item>
<p>This option is only useful for performance tuning.
In general, you should not use this option unless you
know that there is problem with execution times and/or
memory consumption, and you should measure to make sure
that the option improved matters.
</p>
<p>Gives a minimum binary virtual heap size in words. Setting this value
higher than the system default might speed up some
processes because less garbage collection is done.
Setting too high value, however, might waste memory.
Therefore, it is recommended to use this option only for
fine-tuning an application and to measure the execution
time with various <c><anno>VSize</anno></c> values.</p>
</item>
<tag><c>{off_heap_message_queue, <anno>OHMQ</anno>}</c></tag>
<item>
<p>Sets the state of the <c>off_heap_message_queue</c> process
flag. <c><anno>OHMQ</anno></c> should be either <c>true</c>, or
<c>false</c>. The default <c>off_heap_message_queue</c> process
flag is determined by the
<seealso marker="erl#+xohmq"><c>+xohmq</c></seealso> <c>erl</c>
command line argument. For more information, see the
documentation of
<seealso marker="#process_flag_off_heap_message_queue"><c>process_flag(off_heap_message_queue,
<anno>OHMQ</anno>)</c></seealso>.</p>
</item>
</taglist>
</desc>
</func>
<func>
<name name="spawn_opt" arity="5"/>
<type name="priority_level" />
<type name="spawn_opt_option" />
<fsummary>Create a new process with a function as entry point on a given node</fsummary>
<desc>
<p>Returns the pid of a new process started by the application
of <c><anno>Module</anno>:<anno>Function</anno></c> to <c><anno>Args</anno></c> on <c>Node</c>. If
<c><anno>Node</anno></c> does not exist, a useless pid is returned.
Otherwise works like
<seealso marker="#spawn_opt/4">spawn_opt/4</seealso>.</p>
<note><p>The <c>monitor</c> option is currently not supported by
<c>spawn_opt/5</c>.</p></note>
</desc>
</func>
<func>
<name name="split_binary" arity="2"/>
<type_desc variable="Pos">0..byte_size(Bin)</type_desc>
<fsummary>Split a binary into two</fsummary>
<desc>
<p>Returns a tuple containing the binaries which are the result
of splitting <c><anno>Bin</anno></c> into two parts at position <c><anno>Pos</anno></c>.
This is not a destructive operation. After the operation,
there will be three binaries altogether.</p>
<pre>
> <input>B = list_to_binary("0123456789").</input>
<<"0123456789">>
> <input>byte_size(B).</input>
10
> <input>{B1, B2} = split_binary(B,3).</input>
{<<"012">>,<<"3456789">>}
> <input>byte_size(B1).</input>
3
> <input>byte_size(B2).</input>
7</pre>
</desc>
</func>
<func>
<name name="start_timer" arity="4"/>
<fsummary>Start a timer</fsummary>
<desc>
<p>
Starts a timer. When the timer expires, the message
<c>{timeout, <anno>TimerRef</anno>, <anno>Msg</anno>}</c>
will be sent to the process identified by
<c><anno>Dest</anno></c>.
</p>
<p>Currently available <c><anno>Option</anno></c>s:</p>
<taglist>
<tag><c>{abs, Abs}</c></tag>
<item>
<p>
Absolute <c><anno>Time</anno></c> value. <c>Abs</c>
defaults to <c>false</c> which means that the
<c><anno>Time</anno></c> value will be interpreted
as a time in milli-seconds relative current
<seealso marker="time_correction#Erlang_Monotonic_Time">Erlang
monotonic time</seealso>. When <c>Abs</c> is set to
<c>true</c>, the <c><anno>Time</anno></c> value will
be interpreted as an absolute Erlang monotonic time of
milli-seconds
<seealso marker="#type_time_unit">time unit</seealso>.
</p>
</item>
</taglist>
<p>
More <c><anno>Option</anno></c>s may be added in the future.
</p>
<p>
The absolute point in time that the timer is set to expire on
has to be in the interval
<c>[</c><seealso marker="#system_info_start_time"><c>erlang:system_info(start_time)</c></seealso><c>,
</c><seealso marker="#system_info_end_time"><c>erlang:system_info(end_time)</c></seealso><c>]</c>.
Further, if a relative time is specified, the <c><anno>Time</anno></c> value
is not allowed to be negative.
</p>
<p>
If <c><anno>Dest</anno></c> is a <c>pid()</c>, it has to
be a <c>pid()</c> of a process created on the current
runtime system instance. This process may or may not
have terminated. If <c><anno>Dest</anno></c> is an
<c>atom()</c>, it will be interpreted as the name of a
locally registered process. The process referred to by the
name is looked up at the time of timer expiration. No error
is given if the name does not refer to a process.
</p>
<p>
If <c><anno>Dest</anno></c> is a <c>pid()</c>, the timer will
be automatically canceled if the process referred to by the
<c>pid()</c> is not alive, or when the process exits. This
feature was introduced in erts version 5.4.11. Note that
timers will not be automatically canceled when
<c><anno>Dest</anno></c> is an <c>atom()</c>.
</p>
<p>See also
<seealso marker="#send_after/4"><c>erlang:send_after/4</c></seealso>,
<seealso marker="#cancel_timer/2"><c>erlang:cancel_timer/2</c></seealso>,
and
<seealso marker="#read_timer/2"><c>erlang:read_timer/2</c></seealso>.</p>
<p>Failure: <c>badarg</c> if the arguments does not satisfy
the requirements specified above.</p>
</desc>
</func>
<func>
<name name="start_timer" arity="3"/>
<fsummary>Start a timer</fsummary>
<desc>
<p>Starts a timer. The same as calling
<seealso marker="#start_timer/4"><c>erlang:start_timer(<anno>Time</anno>,
<anno>Dest</anno>, <anno>Msg</anno>, [])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="1"/>
<fsummary>Information about context switches</fsummary>
<desc>
<p><c><anno>ContextSwitches</anno></c> is the total number of context
switches since the system started.</p>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="2"/>
<fsummary>Information about exact reductions</fsummary>
<desc>
<marker id="statistics_exact_reductions"></marker>
<note><p><c>statistics(exact_reductions)</c> is
a more expensive operation than
<seealso marker="#statistics_reductions">statistics(reductions)</seealso>
especially on an Erlang machine with SMP support.</p>
</note>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="3"/>
<fsummary>Information about garbage collection</fsummary>
<desc>
<p>This information may not be valid for all implementations.</p>
<pre>
> <input>statistics(garbage_collection).</input>
{85,23961,0}
</pre>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="4"/>
<fsummary>Information about io</fsummary>
<desc>
<p><c><anno>Input</anno></c> is the total number of bytes received
through ports, and <c><anno>Output</anno></c> is the total number of
bytes output to ports.</p>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="5"/>
<fsummary>Information about reductions</fsummary>
<desc>
<marker id="statistics_reductions"></marker>
<note>
<p>Since erts-5.5 (OTP release R11B)
this value does not include reductions performed in current
time slices of currently scheduled processes. If an
exact value is wanted, use
<seealso marker="#statistics_exact_reductions">statistics(exact_reductions)</seealso>.</p>
</note>
<pre>
> <input>statistics(reductions).</input>
{2046,11}
</pre>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="6"/>
<fsummary>Information about the run-queue</fsummary>
<desc>
<p>Returns the total length of the run queues, that is, the number
of processes that are ready to run on all available run queues.</p>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="7"/>
<fsummary>Information about run-time</fsummary>
<desc>
<p>Note that the run-time is the sum of the run-time for all
threads in the Erlang run-time system and may therefore be greater
than the wall-clock time. The time is returned in milliseconds.</p>
<pre>
> <input>statistics(runtime).</input>
{1690,1620}
</pre>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="8"/>
<fsummary>Information about each schedulers work time</fsummary>
<desc>
<marker id="statistics_scheduler_wall_time"></marker>
<p>
Returns a list of tuples with <c>{<anno>SchedulerId</anno>,
<anno>ActiveTime</anno>, <anno>TotalTime</anno>}</c>, where
<c>SchedulerId</c> is an integer id of the scheduler, <c>ActiveTime</c> is
the duration the scheduler has been busy, <c>TotalTime</c> is the total time duration since
<seealso marker="#system_flag_scheduler_wall_time">scheduler_wall_time</seealso>
activation. The time unit is not defined and may be subject to change
between releases, operating systems and system restarts.
<c>scheduler_wall_time</c> should only be used to calculate relative
values for scheduler-utilization. <c>ActiveTime</c> can never exceed <c>TotalTime</c>.
</p>
<p>The definition of a busy scheduler is when it is not idle or not
scheduling (selecting) a process or port, meaning; executing process
code, executing linked-in-driver or NIF code, executing
built-in-functions or any other runtime handling, garbage collecting
or handling any other memory management. Note, a scheduler may also be
busy even if the operating system has scheduled out the scheduler
thread.
</p>
<p>
Returns <c>undefined</c> if the system flag
<seealso marker="#system_flag_scheduler_wall_time">scheduler_wall_time</seealso>
is turned off.
</p>
<p>The list of scheduler information is unsorted and may appear in different order
between calls.
</p>
<p>Using <c>scheduler_wall_time</c> to calculate scheduler utilization.</p>
<pre>
> <input>erlang:system_flag(scheduler_wall_time, true).</input>
false
> <input>Ts0 = lists:sort(erlang:statistics(scheduler_wall_time)), ok.</input>
ok
</pre>
<p>Some time later we will take another snapshot and calculate scheduler-utilization per scheduler.</p>
<pre>
> <input>Ts1 = lists:sort(erlang:statistics(scheduler_wall_time)), ok.</input>
ok
> <input>lists:map(fun({{I, A0, T0}, {I, A1, T1}}) ->
{I, (A1 - A0)/(T1 - T0)} end, lists:zip(Ts0,Ts1)).</input>
[{1,0.9743474730177548},
{2,0.9744843782751444},
{3,0.9995902361669045},
{4,0.9738012596572161},
{5,0.9717956667018103},
{6,0.9739235846420741},
{7,0.973237033077876},
{8,0.9741297293248656}]
</pre>
<p>Using the same snapshots to calculate a total scheduler-utilization.</p>
<pre>
> <input>{A, T} = lists:foldl(fun({{_, A0, T0}, {_, A1, T1}}, {Ai,Ti}) ->
{Ai + (A1 - A0), Ti + (T1 - T0)} end, {0, 0}, lists:zip(Ts0,Ts1)), A/T.</input>
0.9769136803764825
</pre>
<note>
<p><c>scheduler_wall_time</c> is by default disabled. Use <c>erlang:system_flag(scheduler_wall_time, true)</c> to enable it. </p>
</note>
</desc>
</func>
<func>
<name name="statistics" arity="1" clause_i="9"/>
<fsummary>Information about wall-clock</fsummary>
<desc>
<p><c>wall_clock</c> can be used in the same manner as
<c>runtime</c>, except that real time is measured as
opposed to runtime or CPU time.</p>
</desc>
</func>
<func>
<name name="suspend_process" arity="2"/>
<fsummary>Suspend a process</fsummary>
<desc>
<p>Increases the suspend count on the process identified by
<c><anno>Suspendee</anno></c> and puts it in the suspended state if it isn't
already in the suspended state. A suspended process will not be
scheduled for execution until the process has been resumed.
</p>
<p>A process can be suspended by multiple processes and can
be suspended multiple times by a single process. A suspended
process will not leave the suspended state until its suspend
count reach zero. The suspend count of <c><anno>Suspendee</anno></c>
is decreased when
<seealso marker="#resume_process/1">erlang:resume_process(<anno>Suspendee</anno>)</seealso>
is called by the same process that called
<c>erlang:suspend_process(<anno>Suspendee</anno>)</c>. All increased suspend
counts on other processes acquired by a process will automatically be
decreased when the process terminates.</p>
<p>Currently the following options (<c><anno>Opt</anno></c>s) are available:</p>
<taglist>
<tag><c>asynchronous</c></tag>
<item>
A suspend request is sent to the process identified by
<c><anno>Suspendee</anno></c>. <c><anno>Suspendee</anno></c> will eventually suspend
unless it is resumed before it was able to suspend. The caller
of <c>erlang:suspend_process/2</c> will return immediately,
regardless of whether the <c><anno>Suspendee</anno></c> has suspended yet
or not. Note that the point in time when the <c><anno>Suspendee</anno></c>
will actually suspend cannot be deduced from other events
in the system. The only guarantee given is that the
<c><anno>Suspendee</anno></c> will <em>eventually</em> suspend (unless it
is resumed). If the <c>asynchronous</c> option has <em>not</em>
been passed, the caller of <c>erlang:suspend_process/2</c> will
be blocked until the <c><anno>Suspendee</anno></c> has actually suspended.
</item>
<tag><c>unless_suspending</c></tag>
<item>
The process identified by <c><anno>Suspendee</anno></c> will be suspended
unless the calling process already is suspending the
<c><anno>Suspendee</anno></c>. If <c>unless_suspending</c> is combined
with the <c>asynchronous</c> option, a suspend request will be
sent unless the calling process already is suspending the
<c><anno>Suspendee</anno></c> or if a suspend request already has been sent
and is in transit. If the calling process already is suspending
the <c><anno>Suspendee</anno></c>, or if combined with the <c>asynchronous</c>
option and a send request already is in transit,
<c>false</c> is returned and the suspend count on <c><anno>Suspendee</anno></c>
will remain unchanged.
</item>
</taglist>
<p>If the suspend count on the process identified by
<c><anno>Suspendee</anno></c> was increased, <c>true</c> is returned; otherwise,
<c>false</c> is returned.</p>
<warning>
<p>This BIF is intended for debugging only.</p>
</warning>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>
If <c><anno>Suspendee</anno></c> isn't a process identifier.
</item>
<tag><c>badarg</c></tag>
<item>
If the process identified by <c><anno>Suspendee</anno></c> is same the process as
the process calling <c>erlang:suspend_process/2</c>.
</item>
<tag><c>badarg</c></tag>
<item>
If the process identified by <c><anno>Suspendee</anno></c> is not alive.
</item>
<tag><c>badarg</c></tag>
<item>
If the process identified by <c><anno>Suspendee</anno></c> resides on another node.
</item>
<tag><c>badarg</c></tag>
<item>
If <c><anno>OptList</anno></c> isn't a proper list of valid <c><anno>Opt</anno></c>s.
</item>
<tag><c>system_limit</c></tag>
<item>
If the process identified by <c><anno>Suspendee</anno></c> has been suspended more
times by the calling process than can be represented by the
currently used internal data structures. The current system limit
is larger than 2 000 000 000 suspends, and it will never be less
than that.
</item>
</taglist>
</desc>
</func>
<func>
<name name="suspend_process" arity="1"/>
<fsummary>Suspend a process</fsummary>
<desc>
<p>Suspends the process identified by <c><anno>Suspendee</anno></c>. The
same as calling
<seealso marker="#suspend_process/2">erlang:suspend_process(<anno>Suspendee</anno>, [])</seealso>. For more information see the documentation of <seealso marker="#suspend_process/2">erlang:suspend_process/2</seealso>.
</p>
<warning>
<p>This BIF is intended for debugging only.</p>
</warning>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="1"/>
<fsummary>Set system flag backtrace_depth</fsummary>
<desc>
<p>Sets the maximum depth of call stack back-traces in the
exit reason element of <c>'EXIT'</c> tuples.</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="2"/>
<type name="cpu_topology"/>
<type name="level_entry"/>
<type name="level_tag"/>
<type name="sub_level"/>
<type name="info_list"/>
<fsummary>Set system flag cpu_topology</fsummary>
<desc>
<warning>
<p><marker id="system_flag_cpu_topology"></marker>
This argument is <em>deprecated</em> and
scheduled for removal in erts-5.10/OTP-R16. Instead of using
this argument you are advised to use the <c>erl</c> command
line argument <seealso marker="erts:erl#+sct">+sct</seealso>.
When this argument has been removed a final CPU topology to use
will be determined at emulator boot time.</p>
</warning>
<p>Sets the user defined <c><anno>CpuTopology</anno></c>. The user defined
CPU topology will override any automatically detected
CPU topology. By passing <c>undefined</c> as <c><anno>CpuTopology</anno></c>
the system will revert back to the CPU topology automatically
detected. The returned value equals the value returned
from <c>erlang:system_info(cpu_topology)</c> before the
change was made.
</p>
<p>Returns the old value of the flag.</p>
<p>The CPU topology is used when binding schedulers to logical
processors. If schedulers are already bound when the CPU
topology is changed, the schedulers will be sent a request
to rebind according to the new CPU topology.
</p>
<p>The user defined CPU topology can also be set by passing
the <seealso marker="erts:erl#+sct">+sct</seealso> command
line argument to <c>erl</c>.
</p>
<p>For information on the <c><anno>CpuTopology</anno></c> type
and more, see the documentation of
<seealso marker="#system_info_cpu_topology">erlang:system_info(cpu_topology)</seealso>,
and the <c>erl</c> <seealso marker="erts:erl#+sct">+sct</seealso>
and <seealso marker="erts:erl#+sbt">+sbt</seealso>
command line flags.
</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="3"/>
<fsummary>Set system flag dirty CPU schedulers online</fsummary>
<desc>
<p><marker id="system_flag_dirty_cpu_schedulers_online"></marker>
Sets the amount of dirty CPU schedulers online. Valid range is
<![CDATA[1 <= DirtyCPUSchedulersOnline <= N]]> where <c>N</c> is the
lesser of the return values of <c>erlang:system_info(dirty_cpu_schedulers)</c> and
<c>erlang:system_info(schedulers_online)</c>.
</p>
<p>Returns the old value of the flag.</p>
<p>Note that the number of dirty CPU schedulers online may change if the number of
schedulers online changes. For example, if there are 12 schedulers and all are
online, and 6 dirty CPU schedulers, all online as well, and <c>system_flag/2</c>
is used to set the number of schedulers online to 6, then the number of dirty
CPU schedulers online is automatically decreased by half as well, down to 3.
Similarly, the number of dirty CPU schedulers online increases proportionally
to increases in the number of schedulers online.</p>
<p><em>Note that the dirty schedulers functionality is experimental</em>, and
that you have to enable support for dirty schedulers when building OTP in order
to try out the functionality.</p>
<p>For more information see
<seealso marker="#system_info_dirty_cpu_schedulers">erlang:system_info(dirty_cpu_schedulers)</seealso>
and
<seealso marker="#system_info_dirty_cpu_schedulers_online">erlang:system_info(dirty_cpu_schedulers_online)</seealso>.
</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="4"/>
<fsummary>Set system flag fullsweep_after</fsummary>
<desc>
<p><c><anno>Number</anno></c> is a non-negative integer which indicates
how many times generational garbage collections can be
done without forcing a fullsweep collection. The value
applies to new processes; processes already running are
not affected.</p>
<p>Returns the old value of the flag.</p>
<p>In low-memory systems (especially without virtual
memory), setting the value to 0 can help to conserve
memory.</p>
<p>An alternative way to set this value is through the
(operating system) environment variable
<c>ERL_FULLSWEEP_AFTER</c>.</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="5"/>
<fsummary>Set system flag min_heap_size</fsummary>
<desc>
<p>Sets the default minimum heap size for processes. The
size is given in words. The new <c>min_heap_size</c> only
effects processes spawned after the change of
<c>min_heap_size</c> has been made.
The <c>min_heap_size</c> can be set for individual
processes by use of
<seealso marker="#spawn_opt/4">spawn_opt/N</seealso> or
<seealso marker="#process_flag/2">process_flag/2</seealso>. </p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="6"/>
<fsummary>Set system flag min_bin_vheap_size</fsummary>
<desc>
<p>Sets the default minimum binary virtual heap size for processes. The
size is given in words. The new <c>min_bin_vhheap_size</c> only
effects processes spawned after the change of
<c>min_bin_vhheap_size</c> has been made.
The <c>min_bin_vheap_size</c> can be set for individual
processes by use of
<seealso marker="#spawn_opt/4">spawn_opt/N</seealso> or
<seealso marker="#process_flag/2">process_flag/2</seealso>. </p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="7"/>
<fsummary>Set system flag multi_scheduling</fsummary>
<desc>
<p><marker id="system_flag_multi_scheduling"></marker>
If multi-scheduling is enabled, more than one scheduler
thread is used by the emulator. Multi-scheduling can be
blocked. When multi-scheduling has been blocked, only
one scheduler thread will schedule Erlang processes.</p>
<p>If <c><anno>BlockState</anno> =:= block</c>, multi-scheduling will
be blocked. If <c><anno>BlockState</anno> =:= unblock</c> and no-one
else is blocking multi-scheduling and this process has
only blocked one time, multi-scheduling will be unblocked.
One process can block multi-scheduling multiple times.
If a process has blocked multiple times, it has to
unblock exactly as many times as it has blocked before it
has released its multi-scheduling block. If a process that
has blocked multi-scheduling exits, it will release its
blocking of multi-scheduling.</p>
<p>The return values are <c>disabled</c>, <c>blocked</c>,
or <c>enabled</c>. The returned value describes the
state just after the call to
<c>erlang:system_flag(multi_scheduling, <anno>BlockState</anno>)</c>
has been made. The return values are described in the
documentation of <seealso marker="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</seealso>.</p>
<p><em>NOTE</em>: Blocking of multi-scheduling should normally
not be needed. If you feel that you need to
block multi-scheduling, think through the
problem at least a couple of times again.
Blocking multi-scheduling should only be used
as a last resort since it will most likely be
a <em>very inefficient</em> way to solve the
problem.</p>
<p>See also <seealso marker="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</seealso>,
<seealso marker="#system_info_multi_scheduling_blockers">erlang:system_info(multi_scheduling_blockers)</seealso>, and
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>.</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="8"/>
<type name="scheduler_bind_type"/>
<fsummary>Set system flag scheduler_bind_type</fsummary>
<desc>
<warning>
<p><marker id="system_flag_scheduler_bind_type"></marker>
This argument is <em>deprecated</em> and
scheduled for removal in erts-5.10/OTP-R16. Instead of using
this argument you are advised to use the <c>erl</c> command
line argument <seealso marker="erts:erl#+sbt">+sbt</seealso>.
When this argument has been removed a final scheduler bind type
to use will be determined at emulator boot time.</p>
</warning>
<p>Controls if and how schedulers are bound to logical
processors.</p>
<p>When <c>erlang:system_flag(scheduler_bind_type, <anno>How</anno>)</c> is
called, an asynchronous signal is sent to all schedulers
online which causes them to try to bind or unbind as requested.
<em>NOTE:</em> If a scheduler fails to bind, this
will often be silently ignored. This since it isn't always
possible to verify valid logical processor identifiers. If
an error is reported, it will be reported to the
<c>error_logger</c>. If you want to verify that the
schedulers actually have bound as requested, call
<seealso marker="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</seealso>.
</p>
<p>Schedulers can currently only be bound on newer Linux,
Solaris, FreeBSD, and Windows systems, but more systems will be
supported in the future.
</p>
<p>In order for the runtime system to be able to bind schedulers,
the CPU topology needs to be known. If the runtime system fails
to automatically detect the CPU topology, it can be defined.
For more information on how to define the CPU topology, see
the <c>erl</c> <seealso marker="erts:erl#+sct">+sct</seealso> command
line flag.
</p>
<p>The runtime system will by default <em>not</em> bind schedulers
to logical processors.
</p>
<p><em>NOTE:</em> If the Erlang runtime system is the only
operating system process that binds threads to logical processors,
this improves the performance of the runtime system. However,
if other operating system processes (as for example another Erlang
runtime system) also bind threads to logical processors, there
might be a performance penalty instead. In some cases this
performance penalty might be severe. If this is the case, you
are advised to not bind the schedulers.</p>
<p>Schedulers can be bound in different ways. The <c><anno>How</anno></c>
argument determines how schedulers are bound. <c><anno>How</anno></c> can
currently be one of:</p>
<taglist>
<tag><c>unbound</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt u</seealso>.
</p></item>
<tag><c>no_spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt ns</seealso>.
</p></item>
<tag><c>thread_spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt ts</seealso>.
</p></item>
<tag><c>processor_spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt ps</seealso>.
</p></item>
<tag><c>spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt s</seealso>.
</p></item>
<tag><c>no_node_thread_spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt nnts</seealso>.
</p></item>
<tag><c>no_node_processor_spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt nnps</seealso>.
</p></item>
<tag><c>thread_no_node_processor_spread</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt tnnps</seealso>.
</p></item>
<tag><c>default_bind</c></tag>
<item><p>Same as the <c>erl</c> command line argument
<seealso marker="erts:erl#+sbt">+sbt db</seealso>.
</p></item>
</taglist>
<p>The value returned equals <c><anno>How</anno></c> before the
<c>scheduler_bind_type</c> flag was changed.</p>
<p>Failure:</p>
<taglist>
<tag><c>notsup</c></tag>
<item>
<p>If binding of schedulers is not supported.</p>
</item>
<tag><c>badarg</c></tag>
<item>
<p>If <c>How</c> isn't one of the documented alternatives.</p>
</item>
<tag><c>badarg</c></tag>
<item>
<p>If no CPU topology information is available.</p>
</item>
</taglist>
<p>The scheduler bind type can also be set by passing
the <seealso marker="erts:erl#+sbt">+sbt</seealso> command
line argument to <c>erl</c>.
</p>
<p>For more information, see
<seealso marker="#system_info_scheduler_bind_type">erlang:system_info(scheduler_bind_type)</seealso>,
<seealso marker="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</seealso>,
the <c>erl</c> <seealso marker="erts:erl#+sbt">+sbt</seealso>
and <seealso marker="erts:erl#+sct">+sct</seealso> command line
flags.
</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="9"/>
<fsummary>Set system flag scheduler_wall_time</fsummary>
<desc><p><marker id="system_flag_scheduler_wall_time"></marker>
Turns on/off scheduler wall time measurements. </p>
<p>For more information see,
<seealso marker="#statistics_scheduler_wall_time">erlang:statistics(scheduler_wall_time)</seealso>.
</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="10"/>
<fsummary>Set system flag schedulers_online</fsummary>
<desc>
<p><marker id="system_flag_schedulers_online"></marker>
Sets the amount of schedulers online. Valid range is
<![CDATA[1 <= SchedulersOnline <= erlang:system_info(schedulers)]]>.
</p>
<p>Returns the old value of the flag.</p>
<p>Note that if the emulator was built with support for <seealso
marker="#system_flag_dirty_cpu_schedulers_online">dirty schedulers</seealso>,
changing the number of schedulers online can also change the number of dirty
CPU schedulers online. For example, if there are 12 schedulers and all are
online, and 6 dirty CPU schedulers, all online as well, and <c>system_flag/2</c>
is used to set the number of schedulers online to 6, then the number of dirty
CPU schedulers online is automatically decreased by half as well, down to 3.
Similarly, the number of dirty CPU schedulers online increases proportionally
to increases in the number of schedulers online.</p>
<p>For more information see,
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>,
and
<seealso marker="#system_info_schedulers_online">erlang:system_info(schedulers_online)</seealso>.
</p>
</desc>
</func>
<func>
<name name="system_flag" arity="2" clause_i="11"/>
<fsummary>Set system flag trace_control_word</fsummary>
<desc>
<p>Sets the value of the node's trace control word to
<c><anno>TCW</anno></c>. <c><anno>TCW</anno></c> should be an unsigned integer. For
more information see documentation of the
<seealso marker="erts:match_spec#set_tcw">set_tcw</seealso>
function in the match specification documentation in the
ERTS User's Guide.</p>
<p>Returns the old value of the flag.</p>
</desc>
</func>
<marker id="system_flag_time_offset"/>
<func>
<name name="system_flag" arity="2" clause_i="12"/>
<fsummary>Finalize the Time Offset</fsummary>
<desc>
<p>Finalizes the <seealso marker="#time_offset/0">time offset</seealso>
when the <seealso marker="time_correction#Single_Time_Warp_Mode">single
time warp mode</seealso> is being used. If another time warp mode than
the "single time warp mode" is used, the time offset state will be left
unchanged.</p>
<p>Returns the old state identifier. That is, if:</p>
<list>
<item><p><c>preliminary</c> is returned, finalization was
performed and the time offset is now final.</p></item>
<item><p><c>final</c> is returned, the time offset was
already in the final state. This either due to another
<c>erlang:system_flag(time_offset, finalize)</c> call, or
due to the
<seealso marker="time_correction#No_Time_Warp_Mode">no
time warp mode</seealso> being used.</p></item>
<item><p><c>volatile</c> is returned, the time offset
cannot be finalized due to the
<seealso marker="time_correction#Multi_Time_Warp_Mode">multi
time warp mode</seealso> being used.</p></item>
</list>
</desc>
</func>
<func>
<name name="system_info" arity="1" clause_i="1"/>
<name name="system_info" arity="1" clause_i="2"/>
<name name="system_info" arity="1" clause_i="3"/>
<name name="system_info" arity="1" clause_i="4"/>
<name name="system_info" arity="1" clause_i="5"/>
<type variable="Allocator" name_i="2"/>
<type variable="Version" name_i="2"/>
<type variable="Features" name_i="2"/>
<type variable="Settings" name_i="2"/>
<type variable="Alloc" name_i="3"/>
<fsummary>Information about the allocators of the system</fsummary>
<desc>
<p>
Returns various information about the
<marker id="system_info_allocator_tags">allocators</marker> of the
current system (emulator) as specified by
<c><anno>Item</anno></c>:</p>
<taglist>
<tag><marker id="system_info_allocated_areas"><c>allocated_areas</c></marker></tag>
<item>
<p>Returns a list of tuples with information about
miscellaneous allocated memory areas.</p>
<p>Each tuple contains an atom describing type of memory as
first element and amount of allocated memory in bytes as
second element. In those cases when there is information
present about allocated and used memory, a third element
is present. This third element contains the amount of
used memory in bytes.</p>
<p><c>erlang:system_info(allocated_areas)</c> is intended
for debugging, and the content is highly implementation
dependent. The content of the results will therefore
change when needed without prior notice.</p>
<p><em>Note:</em> The sum of these values is <em>not</em>
the total amount of memory allocated by the emulator.
Some values are part of other values, and some memory
areas are not part of the result. If you are interested
in the total amount of memory allocated by the emulator
see <seealso marker="#memory/0">erlang:memory/0,1</seealso>.</p>
</item>
<tag><marker id="system_info_allocator"><c>allocator</c></marker></tag>
<item>
<p>Returns <c>{<anno>Allocator</anno>, <anno>Version</anno>, <anno>Features</anno>, <anno>Settings</anno>}.</c></p>
<p>Explanation:</p>
<list type="bulleted">
<item>
<p><c><anno>Allocator</anno></c> corresponds to the <c>malloc()</c>
implementation used. If <c><anno>Allocator</anno></c> equals
<c>undefined</c>, the <c>malloc()</c> implementation
used could not be identified. Currently
<c>glibc</c> can be identified.</p>
</item>
<item>
<p><c><anno>Version</anno></c> is a list of integers (but not a
string) representing the version of
the <c>malloc()</c> implementation used.</p>
</item>
<item>
<p><c><anno>Features</anno></c> is a list of atoms representing
allocation features used.</p>
</item>
<item>
<p><c><anno>Settings</anno></c> is a list of subsystems, their
configurable parameters, and used values. Settings
may differ between different combinations of
platforms, allocators, and allocation features.
Memory sizes are given in bytes.</p>
</item>
</list>
<p>See also "System Flags Effecting erts_alloc" in
<seealso marker="erts:erts_alloc#flags">erts_alloc(3)</seealso>.</p>
</item>
<tag><marker id="system_info_alloc_util_allocators"><c>alloc_util_allocators</c></marker></tag>
<item>
<p>Returns a list of the names of all allocators
using the ERTS internal <c>alloc_util</c> framework
as atoms. For more information see the
<seealso marker="erts:erts_alloc#alloc_util">"the
alloc_util framework" section in the
erts_alloc(3)</seealso> documentation.
</p>
</item>
<tag><marker id="system_info_allocator_tuple"><c>{allocator, <anno>Alloc</anno>}</c></marker></tag>
<item>
<p>Returns information about the specified allocator.
As of erts version 5.6.1 the return value is a list
of <c>{instance, InstanceNo, InstanceInfo}</c> tuples
where <c>InstanceInfo</c> contains information about
a specific instance of the allocator. As of erts version
5.10.4 the returned list when calling
<c>erlang:system_info({allocator, mseg_alloc})</c> also
include an <c>{erts_mmap, _}</c> tuple as one element
in the list.
If <c><anno>Alloc</anno></c> is not a recognized allocator,
<c>undefined</c> is returned. If <c><anno>Alloc</anno></c> is disabled,
<c>false</c> is returned.</p>
<p><em>Note:</em> The information returned is highly
implementation dependent and may be changed, or removed
at any time without prior notice. It was initially
intended as a tool when developing new allocators, but
since it might be of interest for others it has been
briefly documented.</p>
<p>The recognized allocators are listed in
<seealso marker="erts:erts_alloc">erts_alloc(3)</seealso>.
After reading the <c>erts_alloc(3)</c> documentation,
the returned information
should more or less speak for itself. But it can be worth
explaining some things. Call counts are presented by two
values. The first value is giga calls, and the second
value is calls. <c>mbcs</c>, and <c>sbcs</c> are
abbreviations for, respectively, multi-block carriers, and
single-block carriers. Sizes are presented in bytes. When
it is not a size that is presented, it is the amount of
something. Sizes and amounts are often presented by three
values, the first is current value, the second is maximum
value since the last call to
<c>erlang:system_info({allocator, Alloc})</c>, and
the third is maximum value since the emulator was started.
If only one value is present, it is the current value.
<c>fix_alloc</c> memory block types are presented by two
values. The first value is memory pool size and
the second value used memory size.</p>
</item>
<tag><marker id="system_info_allocator_sizes"><c>{allocator_sizes, <anno>Alloc</anno>}</c></marker></tag>
<item>
<p>Returns various size information for the specified
allocator. The information returned is a subset of the
information returned by
<seealso marker="#system_info_allocator_tuple">erlang:system_info({allocator, <anno>Alloc</anno>})</seealso>.
</p>
</item>
</taglist>
</desc>
</func>
<func>
<name name="system_info" arity="1" clause_i="10"/>
<name name="system_info" arity="1" clause_i="11"/>
<type name="cpu_topology"/>
<type name="level_entry"/>
<type_desc name="cpu_topology">
<marker id="system_info_cpu_topology"></marker>
All <c><anno>LevelEntry</anno></c>s of a list
must contain the same <c><anno>LevelTag</anno></c>, except
on the top level where both <c>node</c> and
<c>processor</c> <c><anno>LevelTag</anno></c>s may co-exist.
</type_desc>
<type_desc name="level_entry">
<c>{<anno>LevelTag</anno>, <anno>SubLevel</anno>} == {<anno>LevelTag</anno>, [], <anno>SubLevel</anno>}</c>
</type_desc>
<type name="level_tag"/>
<type_desc name="level_tag">
More <c><anno>LevelTag</anno></c>s may be introduced in the future.
</type_desc>
<type name="sub_level"/>
<type name="info_list"/>
<type_desc name="info_list">
The <c>info_list()</c> may be extended in the future.
</type_desc>
<fsummary>Information about the CPU topology of the system</fsummary>
<desc>
<p>Returns various information about the
<marker id="system_info_cpu_topology_tags">CPU topology</marker>
of the current system
(emulator) as specified by <c><anno>Item</anno></c>:</p>
<taglist>
<tag><c>cpu_topology</c></tag>
<item>
<p>Returns the <c><anno>CpuTopology</anno></c> which currently is used by the
emulator. The CPU topology is used when binding schedulers
to logical processors. The CPU topology used is the
<seealso marker="erlang#system_info_cpu_topology_defined">user
defined CPU topology</seealso> if such exists; otherwise, the
<seealso marker="erlang#system_info_cpu_topology_detected">automatically
detected CPU topology</seealso> if such exists. If no CPU topology
exists, <c>undefined</c> is returned.</p>
<p><c>node</c> refers to NUMA (non-uniform memory access)
nodes, and <c>thread</c> refers to hardware threads
(e.g. Intels hyper-threads).</p>
<p>A level in the <c><anno>CpuTopology</anno></c> term can be omitted if
only one entry exists and the <c><anno>InfoList</anno></c> is empty.
</p>
<p><c>thread</c> can only be a sub level to <c>core</c>.
<c>core</c> can be a sub level to either <c>processor</c>
or <c>node</c>. <c>processor</c> can either be on the
top level or a sub level to <c>node</c>. <c>node</c>
can either be on the top level or a sub level to
<c>processor</c>. That is, NUMA nodes can be processor
internal or processor external. A CPU topology can
consist of a mix of processor internal and external
NUMA nodes, as long as each logical CPU belongs to one
and only one NUMA node. Cache hierarchy is not part of
the <c><anno>CpuTopology</anno></c> type yet, but will be in the
future. Other things may also make it into the CPU
topology in the future. In other words, expect the
<c><anno>CpuTopology</anno></c> type to change.
</p>
</item>
<tag><marker id="system_info_cpu_topology_defined"><c>{cpu_topology, defined}</c></marker></tag>
<item>
<p>Returns the user defined <c><anno>CpuTopology</anno></c>. For more
information see the documentation of
the <c>erl</c> <seealso marker="erts:erl#+sct">+sct</seealso> command
line flag, and the documentation of the
<seealso marker="#system_info_cpu_topology">cpu_topology</seealso>
argument.
</p>
</item>
<tag><marker id="system_info_cpu_topology_detected"><c>{cpu_topology, detected}</c></marker></tag>
<item>
<p>Returns the automatically detected <c><anno>CpuTopology</anno></c>. The
emulator currently only detects the CPU topology on some newer
Linux, Solaris, FreeBSD, and Windows systems. On Windows system with
more than 32 logical processors the CPU topology is not detected.
</p>
<p>For more information see the documentation of the
<seealso marker="#system_info_cpu_topology">cpu_topology</seealso>
argument.
</p>
</item>
<tag><c>{cpu_topology, used}</c></tag>
<item>
<p>Returns the <c><anno>CpuTopology</anno></c> which is used by the
emulator. For more information see the
documentation of the
<seealso marker="#system_info_cpu_topology">cpu_topology</seealso>
argument.
</p>
</item>
</taglist>
</desc>
</func>
<func>
<name name="system_info" arity="1" clause_i="6"/>
<name name="system_info" arity="1" clause_i="7"/>
<name name="system_info" arity="1" clause_i="8"/>
<name name="system_info" arity="1" clause_i="9"/>
<name name="system_info" arity="1" clause_i="12"/>
<name name="system_info" arity="1" clause_i="13"/>
<name name="system_info" arity="1" clause_i="14"/>
<name name="system_info" arity="1" clause_i="15"/>
<name name="system_info" arity="1" clause_i="16"/>
<name name="system_info" arity="1" clause_i="17"/>
<name name="system_info" arity="1" clause_i="18"/>
<name name="system_info" arity="1" clause_i="19"/>
<name name="system_info" arity="1" clause_i="20"/>
<name name="system_info" arity="1" clause_i="21"/>
<name name="system_info" arity="1" clause_i="22"/>
<name name="system_info" arity="1" clause_i="23"/>
<name name="system_info" arity="1" clause_i="24"/>
<name name="system_info" arity="1" clause_i="25"/>
<name name="system_info" arity="1" clause_i="26"/>
<name name="system_info" arity="1" clause_i="27"/>
<name name="system_info" arity="1" clause_i="28"/>
<name name="system_info" arity="1" clause_i="29"/>
<name name="system_info" arity="1" clause_i="30"/>
<name name="system_info" arity="1" clause_i="31"/>
<name name="system_info" arity="1" clause_i="32"/>
<name name="system_info" arity="1" clause_i="33"/>
<name name="system_info" arity="1" clause_i="34"/>
<name name="system_info" arity="1" clause_i="35"/>
<name name="system_info" arity="1" clause_i="36"/>
<name name="system_info" arity="1" clause_i="37"/>
<name name="system_info" arity="1" clause_i="38"/>
<name name="system_info" arity="1" clause_i="39"/>
<name name="system_info" arity="1" clause_i="40"/>
<name name="system_info" arity="1" clause_i="41"/>
<name name="system_info" arity="1" clause_i="42"/>
<name name="system_info" arity="1" clause_i="43"/>
<name name="system_info" arity="1" clause_i="44"/>
<name name="system_info" arity="1" clause_i="45"/>
<name name="system_info" arity="1" clause_i="46"/>
<name name="system_info" arity="1" clause_i="47"/>
<name name="system_info" arity="1" clause_i="48"/>
<name name="system_info" arity="1" clause_i="49"/>
<name name="system_info" arity="1" clause_i="50"/>
<name name="system_info" arity="1" clause_i="51"/>
<name name="system_info" arity="1" clause_i="52"/>
<name name="system_info" arity="1" clause_i="53"/>
<name name="system_info" arity="1" clause_i="54"/>
<name name="system_info" arity="1" clause_i="55"/>
<name name="system_info" arity="1" clause_i="56"/>
<name name="system_info" arity="1" clause_i="57"/>
<name name="system_info" arity="1" clause_i="58"/>
<name name="system_info" arity="1" clause_i="59"/>
<name name="system_info" arity="1" clause_i="60"/>
<name name="system_info" arity="1" clause_i="61"/>
<name name="system_info" arity="1" clause_i="62"/>
<name name="system_info" arity="1" clause_i="63"/>
<name name="system_info" arity="1" clause_i="64"/>
<name name="system_info" arity="1" clause_i="65"/>
<name name="system_info" arity="1" clause_i="66"/>
<name name="system_info" arity="1" clause_i="67"/>
<name name="system_info" arity="1" clause_i="68"/>
<fsummary>Information about the system</fsummary>
<desc>
<p>Returns various information about the current system
(emulator) as specified by <c><anno>Item</anno></c>:</p>
<taglist>
<tag><c>allocated_areas</c>, <c>allocator</c>,
<c>alloc_util_allocators</c>, <c>allocator_sizes</c></tag>
<item>
<p>See <seealso marker="#system_info_allocator_tags">above</seealso>.</p>
</item>
<tag><c>build_type</c></tag>
<item>
<p>Returns an atom describing the build type of the runtime
system. This is normally the atom <c>opt</c> for optimized.
Other possible return values are <c>debug</c>, <c>purify</c>,
<c>quantify</c>, <c>purecov</c>, <c>gcov</c>, <c>valgrind</c>,
<c>gprof</c>, and <c>lcnt</c>. Possible return values
may be added and/or removed at any time without prior notice.
</p>
</item>
<tag><c>c_compiler_used</c></tag>
<item>
<p>Returns a two-tuple describing the C compiler used when
compiling the runtime system. The first element is an
atom describing the name of the compiler, or <c>undefined</c>
if unknown. The second element is a term describing the
version of the compiler, or <c>undefined</c> if unknown.
</p>
</item>
<tag><c>check_io</c></tag>
<item>
<p>Returns a list containing miscellaneous information
regarding the emulators internal I/O checking. Note,
the content of the returned list may vary between
platforms and over time. The only thing guaranteed is
that a list is returned.</p>
</item>
<tag><c>compat_rel</c></tag>
<item>
<p>Returns the compatibility mode of the local node as
an integer. The integer returned represents the
Erlang/OTP release which the current emulator has been
set to be backward compatible with. The compatibility
mode can be configured at startup by using the command
line flag <c>+R</c>, see
<seealso marker="erts:erl#compat_rel">erl(1)</seealso>.</p>
</item>
<tag><c>cpu_topology</c></tag>
<item>
<p>See <seealso marker="#system_info_cpu_topology_tags">above</seealso>.</p>
</item>
<tag><c>creation</c></tag>
<item>
<p>Returns the creation of the local node as an integer.
The creation is changed when a node is restarted. The
creation of a node is stored in process identifiers, port
identifiers, and references. This makes it (to some
extent) possible to distinguish between identifiers from
different incarnations of a node. Currently valid
creations are integers in the range 1..3, but this may
(probably will) change in the future. If the node is not
alive, 0 is returned.</p>
</item>
<tag><c>debug_compiled</c></tag>
<item>
<p>Returns <c>true</c> if the emulator has been debug
compiled; otherwise, <c>false</c>.
</p>
</item>
<tag><marker id="system_info_delayed_node_table_gc"><c>delayed_node_table_gc</c></marker></tag>
<item>
<p>Returns the amount of time in seconds that garbage collection
of an entry in a node table will be delayed. This limit can be set
on startup by passing the
<seealso marker="erts:erl#+zdntgc">+zdntgc</seealso> command line
flag to <c>erl</c>. For more information see the documentation of the
command line flag.</p>
</item>
<tag><marker id="system_info_dirty_cpu_schedulers"><c>dirty_cpu_schedulers</c></marker></tag>
<item>
<p>Returns the number of dirty CPU scheduler threads used by
the emulator. Dirty CPU schedulers execute CPU-bound
native functions such as NIFs, linked-in driver code, and BIFs
that cannot be managed cleanly by the emulator's normal schedulers.
</p>
<p>The number of dirty CPU scheduler threads is determined at emulator
boot time and cannot be changed after that. The number of dirty CPU
scheduler threads online can however be changed at any time. The number of
dirty CPU schedulers can be set on startup by passing
the <seealso marker="erts:erl#+SDcpu">+SDcpu</seealso> or
<seealso marker="erts:erl#+SDPcpu">+SDPcpu</seealso> command line flags,
see <seealso marker="erts:erl#+SDcpu">erl(1)</seealso>.
</p>
<p><em>Note that the dirty schedulers functionality is experimental</em>, and
that you have to enable support for dirty schedulers when building OTP in
order to try out the functionality.</p>
<p>See also <seealso marker="#system_flag_dirty_cpu_schedulers_online">erlang:system_flag(dirty_cpu_schedulers_online, DirtyCPUSchedulersOnline)</seealso>,
<seealso marker="#system_info_dirty_cpu_schedulers_online">erlang:system_info(dirty_cpu_schedulers_online)</seealso>,
<seealso marker="#system_info_dirty_io_schedulers">erlang:system_info(dirty_io_schedulers)</seealso>,
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>,
<seealso marker="#system_info_schedulers_online">erlang:system_info(schedulers_online)</seealso>, and
<seealso marker="#system_flag_schedulers_online">erlang:system_flag(schedulers_online, SchedulersOnline)</seealso>.</p>
</item>
<tag><marker id="system_info_dirty_cpu_schedulers_online"><c>dirty_cpu_schedulers_online</c></marker></tag>
<item>
<p>Returns the number of dirty CPU schedulers online. The return value
satisfies the following relationship:
<c><![CDATA[1 <= DirtyCPUSchedulersOnline <= N]]></c>, where <c>N</c> is
the lesser of the return values of <c>erlang:system_info(dirty_cpu_schedulers)</c> and
<c>erlang:system_info(schedulers_online)</c>.
</p>
<p>The number of dirty CPU schedulers online can be set on startup by passing
the <seealso marker="erts:erl#+SDcpu">+SDcpu</seealso> command line flag, see
<seealso marker="erts:erl#+SDcpu">erl(1)</seealso>.
</p>
<p><em>Note that the dirty schedulers functionality is experimental</em>, and
that you have to enable support for dirty schedulers when building OTP in
order to try out the functionality.</p>
<p>For more information, see
<seealso marker="#system_info_dirty_cpu_schedulers">erlang:system_info(dirty_cpu_schedulers)</seealso>,
<seealso marker="#system_info_dirty_io_schedulers">erlang:system_info(dirty_io_schedulers)</seealso>,
<seealso marker="#system_info_schedulers_online">erlang:system_info(schedulers_online)</seealso>, and
<seealso marker="#system_flag_dirty_cpu_schedulers_online">erlang:system_flag(dirty_cpu_schedulers_online, DirtyCPUSchedulersOnline)</seealso>.
</p>
</item>
<tag><marker id="system_info_dirty_io_schedulers"><c>dirty_io_schedulers</c></marker></tag>
<item>
<p>Returns the number of dirty I/O schedulers as an integer. Dirty I/O schedulers
execute I/O-bound native functions such as NIFs and linked-in driver code that
cannot be managed cleanly by the emulator's normal schedulers.
</p>
<p>This value can be set on startup by passing
the <seealso marker="erts:erl#+SDio">+SDio</seealso> command line flag, see
<seealso marker="erts:erl#+SDio">erl(1)</seealso>.
</p>
<p><em>Note that the dirty schedulers functionality is experimental</em>, and
that you have to enable support for dirty schedulers when building OTP in
order to try out the functionality.</p>
<p>For more information, see
<seealso marker="#system_info_dirty_cpu_schedulers">erlang:system_info(dirty_cpu_schedulers)</seealso>,
<seealso marker="#system_info_dirty_cpu_schedulers_online">erlang:system_info(dirty_cpu_schedulers_online)</seealso>, and
<seealso marker="#system_flag_dirty_cpu_schedulers_online">erlang:system_flag(dirty_cpu_schedulers_online, DirtyCPUSchedulersOnline)</seealso>.
</p>
</item>
<tag><c>dist</c></tag>
<item>
<p>Returns a binary containing a string of distribution
information formatted as in Erlang crash dumps. For more
information see the <seealso marker="erts:crash_dump">"How to interpret the Erlang crash dumps"</seealso>
chapter in the ERTS User's Guide.</p>
</item>
<tag><marker id="system_info_dist_buf_busy_limit"><c>dist_buf_busy_limit</c></marker></tag>
<item>
<p>Returns the value of the distribution buffer busy limit
in bytes. This limit can be set on startup by passing the
<seealso marker="erts:erl#+zdbbl">+zdbbl</seealso> command line
flag to <c>erl</c>.</p>
</item>
<tag><c>dist_ctrl</c></tag>
<item>
<p>Returns a list of tuples
<c>{Node, ControllingEntity}</c>, one entry for each
connected remote node. The <c><anno>Node</anno></c> is the name of the
node and the <c><anno>ControllingEntity</anno></c> is the port or pid
responsible for the communication to that node. More
specifically, the <c><anno>ControllingEntity</anno></c> for nodes
connected via TCP/IP (the normal case) is the socket
actually used in communication with the specific node.</p>
</item>
<tag><c>driver_version</c></tag>
<item>
<p>Returns a string containing the erlang driver version
used by the runtime system. It will be on the form
<seealso marker="erts:erl_driver#version_management">"<major ver>.<minor ver>"</seealso>.</p>
</item>
<tag><c>dynamic_trace</c></tag>
<item>
<p>Returns an atom describing the dynamic trace framework
compiled into the virtual machine. It can currently be either
<c>dtrace</c>, <c>systemtap</c> or <c>none</c>. For a
commercial or standard build, this is always <c>none</c>,
the other return values indicate a custom configuration
(e.g. <c>./configure --with-dynamic-trace=dtrace</c>). See
the <seealso marker="runtime_tools:dyntrace">dyntrace
</seealso> manual page and the
<c>README.dtrace</c>/<c>README.systemtap</c> files in the
Erlang source code top directory for more information
about dynamic tracing.</p>
</item>
<tag><c>dynamic_trace_probes</c></tag>
<item>
<p>Returns a <c>boolean()</c> indicating if dynamic trace probes
(either dtrace or systemtap) are built into the
emulator. This can only be <c>true</c> if the virtual
machine was built for dynamic tracing
(i.e. <c>system_info(dynamic_trace)</c> returns
<c>dtrace</c> or <c>systemtap</c>).</p>
</item>
<tag><marker id="system_info_end_time"/><c>end_time</c></tag>
<item><p>The last <seealso marker="#monotonic_time/0">Erlang monotonic
time</seealso> in <c>native</c>
<seealso marker="#type_time_unit">time unit</seealso> that
can be represented internally in the current Erlang runtime system
instance. The time between the
<seealso marker="#system_info_start_time">start time</seealso> and
the end time is at least a quarter of a millennium.</p></item>
<tag><c>elib_malloc</c></tag>
<item>
<p>This option will be removed in a future release.
The return value will always be <c>false</c> since
the elib_malloc allocator has been removed.</p>
</item>
<tag><marker id="system_info_eager_check_io"><c>eager_check_io</c></marker></tag>
<item>
<p>
Returns the value of the <c>erl</c>
<seealso marker="erl#+secio">+secio</seealso> command line
flag which is either <c>true</c> or <c>false</c>. See the
documentation of the command line flag for information about
the different values.
</p>
</item>
<tag><c>ets_limit</c></tag>
<item>
<p>Returns the maximum number of ETS tables allowed. This limit
can be increased on startup by passing the <seealso
marker="erts:erl#+e">+e</seealso> command line flag to
<c>erl</c> or by setting the environment variable
<c>ERL_MAX_ETS_TABLES</c> before starting the Erlang runtime
system.</p>
</item>
<tag><c>fullsweep_after</c></tag>
<item>
<p>Returns <c>{fullsweep_after, integer() >= 0}</c> which is the
<c>fullsweep_after</c> garbage collection setting used
by default. For more information see
<c>garbage_collection</c> described below.</p>
</item>
<tag><c>garbage_collection</c></tag>
<item>
<p>Returns a list describing the default garbage collection
settings. A process spawned on the local node by a
<c>spawn</c> or <c>spawn_link</c> will use these
garbage collection settings. The default settings can be
changed by use of
<seealso marker="#system_flag/2">system_flag/2</seealso>.
<seealso marker="#spawn_opt/4">spawn_opt/4</seealso>
can spawn a process that does not use the default
settings.</p>
</item>
<tag><c>heap_sizes</c></tag>
<item>
<p>Returns a list of integers representing valid heap sizes
in words. All Erlang heaps are sized from sizes in this
list.</p>
</item>
<tag><c>heap_type</c></tag>
<item>
<p>Returns the heap type used by the current emulator.
Currently only the following heap type exists:</p>
<taglist>
<tag><c>private</c></tag>
<item>
<p>Each process has a heap reserved for its use and no
references between heaps of different processes are
allowed. Messages passed between processes are copied
between heaps.</p>
</item>
</taglist>
</item>
<tag><c>info</c></tag>
<item>
<p>Returns a binary containing a string of miscellaneous
system information formatted as in Erlang crash dumps.
For more information see the
<seealso marker="erts:crash_dump">"How to interpret the Erlang crash dumps"</seealso> chapter in the ERTS
User's Guide.</p>
</item>
<tag><c>kernel_poll</c></tag>
<item>
<p>Returns <c>true</c> if the emulator uses some kind of
kernel-poll implementation; otherwise, <c>false</c>.</p>
</item>
<tag><c>loaded</c></tag>
<item>
<p>Returns a binary containing a string of loaded module
information formatted as in Erlang crash dumps. For more
information see the <seealso marker="erts:crash_dump">"How to interpret the Erlang crash dumps"</seealso> chapter
in the ERTS User's Guide.</p>
</item>
<tag><marker id="logical_processors"><c>logical_processors</c></marker></tag>
<item>
<p>Returns the detected number of logical processors configured
on the system. The return value is either an integer, or
the atom <c>unknown</c> if the emulator wasn't able to
detect logical processors configured.
</p>
</item>
<tag><marker id="logical_processors_available"><c>logical_processors_available</c></marker></tag>
<item>
<p>Returns the detected number of logical processors available to
the Erlang runtime system. The return value is either an
integer, or the atom <c>unknown</c> if the emulator wasn't
able to detect logical processors available. The number
of logical processors available is less than or equal to
the number of <seealso marker="#logical_processors_online">logical
processors online</seealso>.
</p>
</item>
<tag><marker id="logical_processors_online"><c>logical_processors_online</c></marker></tag>
<item>
<p>Returns the detected number of logical processors online on
the system. The return value is either an integer,
or the atom <c>unknown</c> if the emulator wasn't able to
detect logical processors online. The number of logical
processors online is less than or equal to the number of
<seealso marker="#logical_processors">logical processors
configured</seealso>.
</p>
</item>
<tag><c>machine</c></tag>
<item>
<p>Returns a string containing the Erlang machine name.</p>
</item>
<tag><c>min_heap_size</c></tag>
<item>
<p>Returns <c>{min_heap_size, <anno>MinHeapSize</anno>}</c> where <c><anno>MinHeapSize</anno></c> is the current system wide
minimum heap size for spawned processes.</p>
</item>
<tag><c>min_bin_vheap_size</c></tag>
<item>
<p>Returns <c>{min_bin_vheap_size, <anno>MinBinVHeapSize</anno>}</c> where <c><anno>MinBinVHeapSize</anno></c> is the current system wide
minimum binary virtual heap size for spawned processes.</p>
</item>
<tag><c>modified_timing_level</c></tag>
<item>
<p>Returns the modified timing level (an integer) if
modified timing has been enabled; otherwise,
<c>undefined</c>. See the <c>+T</c> command line flag
in the documentation of the
<seealso marker="erts:erl#+T">erl(1)</seealso>
command for more information on modified timing.</p>
</item>
<tag><marker id="system_info_multi_scheduling"><c>multi_scheduling</c></marker></tag>
<item>
<p>Returns <c>disabled</c>, <c>blocked</c>, or <c>enabled</c>.
A description of the return values:</p>
<taglist>
<tag><c>disabled</c></tag>
<item>
<p>The emulator has only one scheduler thread. The
emulator does not have SMP support, or have been
started with only one scheduler thread.</p>
</item>
<tag><c>blocked</c></tag>
<item>
<p>The emulator has more than one scheduler thread,
but all scheduler threads but one have been blocked,
i.e., only one scheduler thread will schedule
Erlang processes and execute Erlang code.</p>
</item>
<tag><c>enabled</c></tag>
<item>
<p>The emulator has more than one scheduler thread,
and no scheduler threads have been blocked, i.e.,
all available scheduler threads will schedule
Erlang processes and execute Erlang code.</p>
</item>
</taglist>
<p>See also <seealso marker="#system_flag_multi_scheduling">erlang:system_flag(multi_scheduling, BlockState)</seealso>,
<seealso marker="#system_info_multi_scheduling_blockers">erlang:system_info(multi_scheduling_blockers)</seealso>, and
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>.</p>
</item>
<tag><marker id="system_info_multi_scheduling_blockers"><c>multi_scheduling_blockers</c></marker></tag>
<item>
<p>Returns a list of <c><anno>PID</anno></c>s when multi-scheduling
is blocked; otherwise, the empty list. The <c><anno>PID</anno></c>s
in the list is <c><anno>PID</anno></c>s of the processes currently
blocking multi-scheduling. A <c><anno>PID</anno></c> will only be
present once in the list, even if the corresponding
process has blocked multiple times.</p>
<p>See also <seealso marker="#system_flag_multi_scheduling">erlang:system_flag(multi_scheduling, BlockState)</seealso>,
<seealso marker="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</seealso>, and
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>.</p>
</item>
<tag><c>nif_version</c></tag>
<item>
<p>Returns a string containing the erlang NIF version
used by the runtime system. It will be on the form "<major ver>.<minor ver>".</p>
</item>
<tag><marker id="system_info_off_heap_message_queue"><c>off_heap_message_queue</c></marker></tag>
<item>
<p>Returns the default value of the <c>off_heap_message_queue</c>
process flag which is either <c>true</c> or <c>false</c>. This
default is set by the <c>erl</c> command line argument
<seealso marker="erl#+xohmq"><c>+xohmq</c></seealso>. For more information on the
<c>off_heap_message_queue</c> process flag, see documentation of
<seealso marker="#process_flag_off_heap_message_queue"><c>process_flag(off_heap_message_queue,
OHMQ)</c></seealso>.</p>
</item>
<tag><marker id="system_info_otp_release"><c>otp_release</c></marker></tag>
<item>
<p>Returns a string containing the OTP release number of the
OTP release that the currently executing ERTS application is
part of.</p>
<p>As of OTP release 17, the OTP release number corresponds to
the major OTP version number. There is no
<c>erlang:system_info()</c> argument giving the exact OTP
version. This since the exact OTP version in the general case
is hard to determine. For more information see
<seealso marker="doc/system_principles:versions">the
documentation of versions in the system principles
guide</seealso>.</p>
</item>
<tag><marker id="system_info_os_monotonic_time_source"><c>os_monotonic_time_source</c></marker></tag>
<item>
<p>Returns a list containing information about the source of
<seealso marker="erts:time_correction#OS_Monotonic_Time">OS
monotonic time</seealso> that is used by the runtime system.</p>
<p>In case <c>[]</c> is returned, no OS monotonic time is
available. The list contains two-tuples with <c>Key</c>s
as first element, and <c>Value</c>s as second element. The
order if these tuples is undefined. Currently the following
tuples may be part of the list, but more tuples may be
introduced in the future:</p>
<taglist>
<tag><c>{function, Function}</c></tag>
<item><p><c>Function</c> is the name of the funcion
used. This tuple always exist if OS monotonic time is
available to the runtime system.</p></item>
<tag><c>{clock_id, ClockId}</c></tag>
<item><p>This tuple only exist if <c>Function</c>
can be used with different clocks. <c>ClockId</c>
corresponds to the clock identifer used when calling
<c>Function</c>.</p></item>
<tag><c>{resolution, OsMonotonicTimeResolution}</c></tag>
<item><p>Highest possible
<seealso marker="time_correction#Time_Resolution">resolution</seealso>
of current OS monotonic time source as parts per
second. If no resolution information can be retreived
from the OS, <c>OsMonotonicTimeResolution</c> will be
set to the resolution of the time unit of
<c>Function</c>s return value. That is, the actual
resolution may be lower than
<c>OsMonotonicTimeResolution</c>. Also note that
the resolution does not say anything about the
<seealso marker="time_correction#Time_Accuracy">accuracy</seealso>,
and that the
<seealso marker="time_correction#Time_Precision">precision</seealso>
might not align with the resolution. You do,
however, know that the precision won't be
better than
<c>OsMonotonicTimeResolution</c>.</p></item>
<tag><c>{extended, Extended}</c></tag>
<item><p><c>Extended</c> equals <c>yes</c> if
the range of time values has been extended;
otherwise, <c>Extended</c> equals <c>no</c>. The
range needs to be extended if <c>Function</c>
returns values that wrap fast. This typically
is the case when the return value is a 32-bit
value.</p></item>
<tag><c>{parallel, Parallel}</c></tag>
<item><p><c>Parallel</c> equals <c>yes</c> if
<c>Function</c> is called in parallel from multiple
threads. If it is not called in parallel, because
calls needs to be serialized, <c>Parallel</c> equals
<c>no</c>.</p></item>
<tag><c>{time, OsMonotonicTime}</c></tag>
<item><p><c>OsMonotonicTime</c> equals current OS
monotonic time in <c>native</c>
<seealso marker="#type_time_unit">time unit</seealso>.</p></item>
</taglist>
</item>
<tag><marker id="system_info_os_system_time_source"><c>os_system_time_source</c></marker></tag>
<item>
<p>Returns a list containing information about the source of
<seealso marker="erts:time_correction#OS_System_Time">OS
system time</seealso> that is used by the runtime system.</p>
<p>The list contains two-tuples with <c>Key</c>s
as first element, and <c>Value</c>s as second element. The
order if these tuples is undefined. Currently the following
tuples may be part of the list, but more tuples may be
introduced in the future:</p>
<taglist>
<tag><c>{function, Function}</c></tag>
<item><p><c>Function</c> is the name of the funcion
used.</p></item>
<tag><c>{clock_id, ClockId}</c></tag>
<item><p>This tuple only exist if <c>Function</c>
can be used with different clocks. <c>ClockId</c>
corresponds to the clock identifer used when calling
<c>Function</c>.</p></item>
<tag><c>{resolution, OsSystemTimeResolution}</c></tag>
<item><p>Highest possible
<seealso marker="time_correction#Time_Resolution">resolution</seealso>
of current OS system time source as parts per
second. If no resolution information can be retreived
from the OS, <c>OsSystemTimeResolution</c> will be
set to the resolution of the time unit of
<c>Function</c>s return value. That is, the actual
resolution may be lower than
<c>OsSystemTimeResolution</c>. Also note that
the resolution does not say anything about the
<seealso marker="time_correction#Time_Accuracy">accuracy</seealso>,
and that the
<seealso marker="time_correction#Time_Precision">precision</seealso>
might not align with the resolution. You do,
however, know that the precision won't be
better than
<c>OsSystemTimeResolution</c>.</p></item>
<tag><c>{parallel, Parallel}</c></tag>
<item><p><c>Parallel</c> equals <c>yes</c> if
<c>Function</c> is called in parallel from multiple
threads. If it is not called in parallel, because
calls needs to be serialized, <c>Parallel</c> equals
<c>no</c>.</p></item>
<tag><c>{time, OsSystemTime}</c></tag>
<item><p><c>OsSystemTime</c> equals current OS
system time in <c>native</c>
<seealso marker="#type_time_unit">time unit</seealso>.</p></item>
</taglist>
</item>
<tag><marker id="system_info_port_parallelism"><c>port_parallelism</c></marker></tag>
<item><p>Returns the default port parallelism scheduling hint used.
For more information see the
<seealso marker="erl#+spp">+spp</seealso> command line argument
of <seealso marker="erl">erl(1)</seealso>.</p></item>
<tag><marker id="system_info_port_count"/><c>port_count</c></tag>
<item>
<p>Returns the number of ports currently existing at
the local node as an integer. The same value as
<c>length(erlang:ports())</c> returns, but more efficient.</p>
</item>
<tag><marker id="system_info_port_limit"><c>port_limit</c></marker></tag>
<item>
<p>Returns the maximum number of simultaneously existing
ports at the local node as an integer. This limit
can be configured at startup by using the
<seealso marker="erl#+Q">+Q</seealso>
command line flag of
<seealso marker="erl">erl(1)</seealso>.</p>
</item>
<tag><marker id="system_info_process_count"/><c>process_count</c></tag>
<item>
<p>Returns the number of processes currently existing at
the local node as an integer. The same value as
<c>length(processes())</c> returns, but more efficient.</p>
</item>
<tag><marker id="system_info_process_limit"><c>process_limit</c></marker></tag>
<item>
<p>Returns the maximum number of simultaneously existing
processes at the local node as an integer. This limit
can be configured at startup by using the
<seealso marker="erl#+P">+P</seealso>
command line flag of
<seealso marker="erl">erl(1)</seealso>.</p>
</item>
<tag><c>procs</c></tag>
<item>
<p>Returns a binary containing a string of process and port
information formatted as in Erlang crash dumps. For more
information see the <seealso marker="erts:crash_dump">"How to interpret the Erlang crash dumps"</seealso> chapter
in the ERTS User's Guide.</p>
</item>
<tag><marker id="system_info_scheduler_bind_type"><c>scheduler_bind_type</c></marker></tag>
<item>
<p>Returns information on how user has requested
schedulers to be bound or not bound.</p>
<p><em>NOTE:</em> Even though user has requested
schedulers to be bound, they might have silently failed
to bind. In order to inspect actual scheduler bindings call
<seealso marker="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</seealso>.
</p>
<p>For more information, see
the <c>erl</c> <seealso marker="erts:erl#+sbt">+sbt</seealso>
command line argument, and
<seealso marker="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</seealso>.
</p>
</item>
<tag><marker id="system_info_scheduler_bindings"><c>scheduler_bindings</c></marker></tag>
<item>
<p>Returns information on currently used scheduler
bindings.</p>
<p>A tuple of a size equal to
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso> is returned. The elements of the tuple are integers
or the atom <c>unbound</c>. Logical processor identifiers
are represented as integers. The <c>N</c>th
element of the tuple equals the current binding for
the scheduler with the scheduler identifier equal to
<c>N</c>. E.g., if the schedulers have been bound,
<c>element(erlang:system_info(scheduler_id),
erlang:system_info(scheduler_bindings))</c> will return
the identifier of the logical processor that the calling
process is executing on.
</p>
<p>Note that only schedulers online can be bound to logical
processors.</p>
<p>For more information, see
the <c>erl</c> <seealso marker="erts:erl#+sbt">+sbt</seealso>
command line argument,
<seealso marker="#system_info_schedulers_online">erlang:system_info(schedulers_online)</seealso>.
</p>
</item>
<tag><marker id="system_info_scheduler_id"><c>scheduler_id</c></marker></tag>
<item>
<p>Returns the scheduler id (<c>SchedulerId</c>) of the
scheduler thread that the calling process is executing
on. <c><anno>SchedulerId</anno></c> is a positive integer; where
<c><![CDATA[1 <= SchedulerId <= erlang:system_info(schedulers)]]></c>. See also
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>.</p>
</item>
<tag><marker id="system_info_schedulers"><c>schedulers</c></marker></tag>
<item>
<p>Returns the number of scheduler threads used by
the emulator. Scheduler threads online schedules Erlang
processes and Erlang ports, and execute Erlang code
and Erlang linked in driver code.</p>
<p>The number of scheduler threads is determined at
emulator boot time and cannot be changed after
that. The amount of schedulers online can
however be changed at any time.</p>
<p>See also <seealso marker="#system_flag_schedulers_online">erlang:system_flag(schedulers_online, SchedulersOnline)</seealso>,
<seealso marker="#system_info_schedulers_online">erlang:system_info(schedulers_online)</seealso>,
<seealso marker="#system_info_scheduler_id">erlang:system_info(scheduler_id)</seealso>,
<seealso marker="#system_flag_multi_scheduling">erlang:system_flag(multi_scheduling, BlockState)</seealso>,
<seealso marker="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</seealso>, and
and <seealso marker="#system_info_multi_scheduling_blockers">erlang:system_info(multi_scheduling_blockers)</seealso>.</p>
</item>
<tag><marker id="system_info_schedulers_online"><c>schedulers_online</c></marker></tag>
<item>
<p>Returns the amount of schedulers online. The scheduler
identifiers of schedulers online satisfy the following
relationship:
<c><![CDATA[1 <= SchedulerId <= erlang:system_info(schedulers_online)]]></c>.
</p>
<p>For more information, see
<seealso marker="#system_info_schedulers">erlang:system_info(schedulers)</seealso>,
and
<seealso marker="#system_flag_schedulers_online">erlang:system_flag(schedulers_online, SchedulersOnline)</seealso>.
</p> <name name="system_info" arity="1" clause_i="49"/>
</item>
<tag><c>smp_support</c></tag>
<item>
<p>Returns <c>true</c> if the emulator has been compiled
with smp support; otherwise, <c>false</c>.</p>
</item>
<tag><marker id="system_info_start_time"/><c>start_time</c></tag>
<item><p>The <seealso marker="#monotonic_time/0">Erlang monotonic
time</seealso> in <c>native</c>
<seealso marker="#type_time_unit">time unit</seealso> at the
time when current Erlang runtime system instance started. See also
<seealso marker="#system_info_end_time"><c>erlang:system_info(end_time)</c></seealso>.
</p></item>
<tag><c>system_version</c></tag>
<item>
<p>Returns a string containing version number and
some important properties such as the number of schedulers.</p>
</item>
<tag><c>system_architecture</c></tag>
<item>
<p>Returns a string containing the processor and OS
architecture the emulator is built for.</p>
</item>
<tag><c>threads</c></tag>
<item>
<p>Returns <c>true</c> if the emulator has been compiled
with thread support; otherwise, <c>false</c> is
returned.</p>
</item>
<tag><marker id="system_info_thread_pool_size"><c>thread_pool_size</c></marker></tag>
<item>
<p>Returns the number of async threads in the async thread
pool used for asynchronous driver calls
(<seealso marker="erts:erl_driver#driver_async">driver_async()</seealso>)
as an integer.</p>
</item>
<tag><marker id="system_info_time_correction"/><c>time_correction</c></tag>
<item><p>Returns a boolean value indicating whether
<seealso marker="time_correction#Time_Correction">time correction</seealso>
is enabled or not.
</p></item>
<tag><marker id="system_info_time_offset"/><c>time_offset</c></tag>
<item><p>Returns the state of the time offset:</p>
<taglist>
<tag><c>preliminary</c></tag>
<item><p>The time offset is preliminary, and will be changed
at a later time when being finalized. The preliminary time offset
is used during the preliminary phase of the
<seealso marker="time_correction#Single_Time_Warp_Mode">single
time warp mode</seealso>.</p></item>
<tag><c>final</c></tag>
<item><p>The time offset is final. This
either due to the use of the
<seealso marker="time_correction#No_Time_Warp_Mode">no
time warp mode</seealso>, or due to the time offset having
been finalized when using the
<seealso marker="time_correction#Single_Time_Warp_Mode">single
time warp mode</seealso>.</p></item>
<tag><c>volatile</c></tag>
<item><p>The time offset is volatile. That is, it may
change at any time. This due to the
<seealso marker="time_correction#Multi_Time_Warp_Mode">multi
time warp mode</seealso> being used.</p></item>
</taglist>
</item>
<tag><marker id="system_info_time_warp_mode"/><c>time_warp_mode</c></tag>
<item><p>Returns a value identifying the
<seealso marker="time_correction#Time_Warp_Modes">time warp
mode</seealso> being used:</p>
<taglist>
<tag><c>no_time_warp</c></tag>
<item><p>The <seealso marker="time_correction#No_Time_Warp_Mode">no
time warp mode</seealso> is being used.</p></item>
<tag><c>single_time_warp</c></tag>
<item><p>The <seealso marker="time_correction#Single_Time_Warp_Mode">single
time warp mode</seealso> is being used.</p></item>
<tag><c>multi_time_warp</c></tag>
<item><p>The <seealso marker="time_correction#Multi_Time_Warp_Mode">multi
time warp mode</seealso> is being used.</p></item>
</taglist>
</item>
<tag><marker id="system_info_tolerant_timeofday"><c>tolerant_timeofday</c></marker></tag>
<item>
<p>Returns whether a pre erts-7.0 backwards compatible compensation
for sudden changes of system time is <c>enabled</c> or <c>disabled</c>.
Such compensation is <c>enabled</c> when the
<seealso marker="#system_info_time_offset">time offset</seealso> is
<c>final</c>, and
<seealso marker="#system_info_time_correction">time correction</seealso>
is enabled.</p>
</item>
<tag><c>trace_control_word</c></tag>
<item>
<p>Returns the value of the node's trace control word.
For more information see documentation of the function
<c>get_tcw</c> in "Match Specifications in Erlang",
<seealso marker="erts:match_spec#get_tcw">ERTS User's Guide</seealso>.</p>
</item>
<tag><marker id="update_cpu_info"><c>update_cpu_info</c></marker></tag>
<item>
<p>The runtime system rereads the CPU information available and
updates its internally stored information about the
<seealso marker="#system_info_cpu_topology_detected">detected CPU
topology</seealso> and the amount of logical processors
<seealso marker="#logical_processors">configured</seealso>,
<seealso marker="#logical_processors_online">online</seealso>, and
<seealso marker="#logical_processors_available">available</seealso>.
If the CPU information has changed since the last time it was read,
the atom <c>changed</c> is returned; otherwise, the atom
<c>unchanged</c> is returned. If the CPU information has changed
you probably want to
<seealso marker="#system_flag_schedulers_online">adjust the amount
of schedulers online</seealso>. You typically want to have as
many schedulers online as
<seealso marker="#logical_processors_available">logical processors
available</seealso>.
</p>
</item>
<tag><marker id="system_info_version"><c>version</c></marker></tag>
<item>
<p>Returns a string containing the version number of the
emulator.</p>
</item>
<tag><c>wordsize</c></tag>
<item>
<p>Same as <c>{wordsize, internal}.</c></p>
</item>
<tag><c>{wordsize, internal}</c></tag>
<item>
<p>Returns the size of Erlang term words in bytes as an
integer, i.e. on a 32-bit architecture 4 is returned,
and on a pure 64-bit architecture 8 is returned. On a
halfword 64-bit emulator, 4 is returned, as the Erlang
terms are stored using a virtual wordsize of half the
system's wordsize.</p>
</item>
<tag><c>{wordsize, external}</c></tag>
<item>
<p>Returns the true wordsize of the emulator, i.e. the size
of a pointer, in bytes as an integer. On a pure 32-bit
architecture 4 is returned, on both a halfword and pure
64-bit architecture, 8 is returned.</p>
</item>
</taglist>
<note>
<p>The <c>scheduler</c> argument has changed name to
<c>scheduler_id</c>. This in order to avoid mixup with
the <c>schedulers</c> argument. The <c>scheduler</c>
argument was introduced in ERTS version 5.5 and renamed
in ERTS version 5.5.1.</p>
</note>
</desc>
</func>
<func>
<name name="system_monitor" arity="0"/>
<type name="system_monitor_option"/>
<fsummary>Current system performance monitoring settings</fsummary>
<desc>
<p>Returns the current system monitoring settings set by
<seealso marker="#system_monitor/2">erlang:system_monitor/2</seealso>
as <c>{<anno>MonitorPid</anno>, <anno>Options</anno>}</c>, or <c>undefined</c> if there
are no settings. The order of the options may be different
from the one that was set.</p>
</desc>
</func>
<func>
<name name="system_monitor" arity="1"/>
<type name="system_monitor_option"/>
<fsummary>Set or clear system performance monitoring options</fsummary>
<desc>
<p>When called with the argument <c>undefined</c>, all
system performance monitoring settings are cleared.</p>
<p>Calling the function with <c>{<anno>MonitorPid</anno>, <anno>Options</anno>}</c> as
argument, is the same as calling
<seealso marker="#system_monitor/2">erlang:system_monitor(<anno>MonitorPid</anno>, <anno>Options</anno>)</seealso>.</p>
<p>Returns the previous system monitor settings just like
<seealso marker="#system_monitor/0">erlang:system_monitor/0</seealso>.</p>
</desc>
</func>
<func>
<name name="system_monitor" arity="2"/>
<type name="system_monitor_option"/>
<fsummary>Set system performance monitoring options</fsummary>
<desc>
<p>Sets system performance monitoring options. <c><anno>MonitorPid</anno></c>
is a local pid that will receive system monitor messages, and
the second argument is a list of monitoring options:</p>
<taglist>
<tag><c>{long_gc, Time}</c></tag>
<item>
<p>If a garbage collection in the system takes at least
<c>Time</c> wallclock milliseconds, a message
<c>{monitor, GcPid, long_gc, Info}</c> is sent to
<c><anno>MonitorPid</anno></c>. <c>GcPid</c> is the pid that was
garbage collected and <c>Info</c> is a list of two-element
tuples describing the result of the garbage collection.
One of the tuples is <c>{timeout, GcTime}</c> where
<c>GcTime</c> is the actual time for the garbage
collection in milliseconds. The other tuples are
tagged with <c>heap_size</c>, <c>heap_block_size</c>,
<c>stack_size</c>, <c>mbuf_size</c>, <c>old_heap_size</c>,
and <c>old_heap_block_size</c>. These tuples are
explained in the documentation of the
<seealso marker="#gc_start">gc_start</seealso>
trace message (see
<seealso marker="#trace/3">erlang:trace/3</seealso>).
New tuples may be added, and the order of the tuples in
the <c>Info</c> list may be changed at any time without prior
notice.
</p>
</item>
<tag><c>{long_schedule, Time}</c></tag>
<item>
<p>If a process or port in the system runs uninterrupted
for at least <c>Time</c> wall clock milliseconds, a
message <c>{monitor, PidOrPort, long_schedule, Info}</c>
is sent to <c>MonitorPid</c>. <c>PidOrPort</c> is the
process or port that was running and <c>Info</c> is a
list of two-element tuples describing the event. In case
of a <c>pid()</c>, the tuples <c>{timeout, Millis}</c>,
<c>{in, Location}</c> and <c>{out, Location}</c> will be
present, where <c>Location</c> is either an MFA
(<c>{Module, Function, Arity}</c>) describing the
function where the process was scheduled in/out, or the
atom <c>undefined</c>. In case of a <c>port()</c>, the
tuples <c>{timeout, Millis}</c> and <c>{port_op,Op}</c>
will be present. <c>Op</c> will be one of <c>proc_sig</c>,
<c>timeout</c>, <c>input</c>, <c>output</c>,
<c>event</c> or <c>dist_cmd</c>, depending on which
driver callback was executing. <c>proc_sig</c> is an
internal operation and should never appear, while the
others represent the corresponding driver callbacks
<c>timeout</c>, <c>ready_input</c>, <c>ready_output</c>,
<c>event</c> and finally <c>outputv</c> (when the port
is used by distribution). The <c>Millis</c> value in
the <c>timeout</c> tuple will tell you the actual
uninterrupted execution time of the process or port,
which will always be <c>>=</c> the <c>Time</c> value
supplied when starting the trace. New tuples may be
added to the <c>Info</c> list in the future, and the
order of the tuples in the list may be changed at any
time without prior notice.
</p>
<p>This can be used to detect problems with NIF's or
drivers that take too long to execute. Generally, 1 ms
is considered a good maximum time for a driver callback
or a NIF. However, a time sharing system should usually
consider everything below 100 ms as "possible" and
fairly "normal". Schedule times above that might however
indicate swapping or a NIF/driver that is
misbehaving. Misbehaving NIF's and drivers could cause
bad resource utilization and bad overall performance of
the system.</p>
</item>
<tag><c>{large_heap, Size}</c></tag>
<item>
<p>If a garbage collection in the system results in
the allocated size of a heap being at least <c>Size</c>
words, a message <c>{monitor, GcPid, large_heap, Info}</c>
is sent to <c><anno>MonitorPid</anno></c>. <c>GcPid</c> and <c>Info</c>
are the same as for <c>long_gc</c> above, except that
the tuple tagged with <c>timeout</c> is not present.
<em>Note</em>: As of erts version 5.6 the monitor message
is sent if the sum of the sizes of all memory blocks allocated
for all heap generations is equal to or larger than <c>Size</c>.
Previously the monitor message was sent if the memory block
allocated for the youngest generation was equal to or larger
than <c>Size</c>.
</p>
</item>
<tag><c>busy_port</c></tag>
<item>
<p>If a process in the system gets suspended because it
sends to a busy port, a message
<c>{monitor, SusPid, busy_port, Port}</c> is sent to
<c><anno>MonitorPid</anno></c>. <c>SusPid</c> is the pid that got
suspended when sending to <c>Port</c>.</p>
</item>
<tag><c>busy_dist_port</c></tag>
<item>
<p>If a process in the system gets suspended because it
sends to a process on a remote node whose inter-node
communication was handled by a busy port, a message
<c>{monitor, SusPid, busy_dist_port, Port}</c> is sent to
<c><anno>MonitorPid</anno></c>. <c>SusPid</c> is the pid that got
suspended when sending through the inter-node
communication port <c>Port</c>.</p>
</item>
</taglist>
<p>Returns the previous system monitor settings just like
<seealso marker="#system_monitor/0">erlang:system_monitor/0</seealso>.</p>
<note>
<p>If a monitoring process gets so large that it itself
starts to cause system monitor messages when garbage
collecting, the messages will enlarge the process's
message queue and probably make the problem worse.</p>
<p>Keep the monitoring process neat and do not set the system
monitor limits too tight.</p>
</note>
<p>Failure: <c>badarg</c> if <c><anno>MonitorPid</anno></c> does not exist or is not a local process.</p>
</desc>
</func>
<func>
<name name="system_profile" arity="0"/>
<type name="system_profile_option"/>
<fsummary>Current system profiling settings</fsummary>
<desc>
<p>Returns the current system profiling settings set by
<seealso marker="#system_profile/2">erlang:system_profile/2</seealso>
as <c>{<anno>ProfilerPid</anno>, <anno>Options</anno>}</c>, or <c>undefined</c> if there
are no settings. The order of the options may be different
from the one that was set.</p>
</desc>
</func>
<func>
<name name="system_profile" arity="2"/>
<type name="system_profile_option"/>
<fsummary>Current system profiling settings</fsummary>
<desc>
<p>Sets system profiler options. <c><anno>ProfilerPid</anno></c>
is a local pid or port that will receive profiling messages. The
receiver is excluded from all profiling.
The second argument is a list of profiling options:</p>
<taglist>
<tag><c>exclusive</c></tag>
<item>
<p>
If a synchronous call to a port from a process is done, the
calling process is considered not runnable during the call
runtime to the port. The calling process is notified as
<c>inactive</c> and subsequently <c>active</c> when the port
callback returns.
</p>
</item>
<tag><c>runnable_procs</c></tag>
<item>
<p>If a process is put into or removed from the run queue a message,
<c>{profile, Pid, State, Mfa, Ts}</c>, is sent to
<c><anno>ProfilerPid</anno></c>. Running processes that is reinserted into the
run queue after having been preemptively scheduled out will not trigger this
message.
</p>
</item>
<tag><c>runnable_ports</c></tag>
<item>
<p>If a port is put into or removed from the run queue a message,
<c>{profile, Port, State, 0, Ts}</c>, is sent to
<c><anno>ProfilerPid</anno></c>.
</p>
</item>
<tag><c>scheduler</c></tag>
<item>
<p>If a scheduler is put to sleep or awoken a message,
<c>{profile, scheduler, Id, State, NoScheds, Ts}</c>, is sent
to <c><anno>ProfilerPid</anno></c>.
</p>
</item>
</taglist>
<note><p><c>erlang:system_profile</c> is considered experimental and
its behaviour may change in the future.</p>
</note>
</desc>
</func>
<func>
<name name="system_time" arity="0"/>
<fsummary>Current Erlang system time</fsummary>
<desc>
<p>Returns current
<seealso marker="time_correction#Erlang_System_Time">Erlang system time</seealso>
in <c>native</c>
<seealso marker="#type_time_unit">time unit</seealso>.</p>
<p>Calling <c>erlang:system_time()</c> is equivalent to:
<seealso marker="#monotonic_time/0"><c>erlang:monotonic_time()</c></seealso><c>
+
</c><seealso marker="#time_offset/0"><c>erlang:time_offset()</c></seealso>.</p>
<note><p>This time is <em>not</em> a monotonically increasing time
in the general case. For more information, see the documentation of
<seealso marker="time_correction#Time_Warp_Modes">time warp modes</seealso> in the
ERTS User's Guide.</p></note>
</desc>
</func>
<func>
<name name="system_time" arity="1"/>
<fsummary>Current Erlang system time</fsummary>
<desc>
<p>Returns current
<seealso marker="time_correction#Erlang_System_Time">Erlang system time</seealso>
converted into the <c><anno>Unit</anno></c> passed as argument.</p>
<p>Calling <c>erlang:system_time(<anno>Unit</anno>)</c> is equivalent to:
<seealso marker="#convert_time_unit/3"><c>erlang:convert_time_unit</c></seealso><c>(</c><seealso marker="#system_time/0"><c>erlang:system_time()</c></seealso><c>,
native, <anno>Unit</anno>)</c>.</p>
<note><p>This time is <em>not</em> a monotonically increasing time
in the general case. For more information, see the documentation of
<seealso marker="time_correction#Time_Warp_Modes">time warp modes</seealso> in the
ERTS User's Guide.</p></note>
</desc>
</func>
<func>
<name name="term_to_binary" arity="1"/>
<fsummary>Encode a term to an Erlang external term format binary</fsummary>
<desc>
<p>Returns a binary data object which is the result of encoding
<c><anno>Term</anno></c> according to the Erlang external term format.</p>
<p>This can be used for a variety of purposes, for example
writing a term to a file in an efficient way, or sending an
Erlang term to some type of communications channel not
supported by distributed Erlang.</p>
<p>See also
<seealso marker="#binary_to_term/1">binary_to_term/1</seealso>.</p>
</desc>
</func>
<func>
<name name="term_to_binary" arity="2"/>
<fsummary>Encode a term to en Erlang external term format binary</fsummary>
<desc>
<p>Returns a binary data object which is the result of encoding
<c><anno>Term</anno></c> according to the Erlang external term format.</p>
<p>If the option <c>compressed</c> is provided, the external
term format will be compressed. The compressed format is
automatically recognized by <c>binary_to_term/1</c> in R7B and later.</p>
<p>It is also possible to specify a compression level by giving
the option <c>{compressed, <anno>Level</anno>}</c>, where <c><anno>Level</anno></c> is an
integer from 0 through 9. <c>0</c> means that no compression
will be done (it is the same as not giving any <c>compressed</c> option);
<c>1</c> will take the least time but may not compress as well as
the higher levels; <c>9</c> will take the most time and may produce
a smaller result. Note the "mays" in the preceding sentence; depending
on the input term, level 9 compression may or may not produce a smaller
result than level 1 compression.</p>
<p>Currently, <c>compressed</c> gives the same result as
<c>{compressed, 6}</c>.</p>
<p>The option <c>{minor_version, <anno>Version</anno>}</c> can be use to control
some details of the encoding. This option was
introduced in R11B-4. Currently, the allowed values for <c><anno>Version</anno></c>
are <c>0</c> and <c>1</c>.</p>
<p><c>{minor_version, 1}</c> is since 17.0 the default, it forces any floats in
the term to be encoded
in a more space-efficient and exact way (namely in the 64-bit IEEE format,
rather than converted to a textual representation). <c>binary_to_term/1</c>
in R11B-4 and later is able decode this representation.</p>
<p><c>{minor_version, 0}</c> meaning that floats
will be encoded using a textual representation; this option is useful if
you want to ensure that releases prior to R11B-4 can decode resulting
binary.</p>
<p>See also
<seealso marker="#binary_to_term/1">binary_to_term/1</seealso>.</p>
</desc>
</func>
<func>
<name name="throw" arity="1"/>
<fsummary>Throw an exception</fsummary>
<desc>
<p>A non-local return from a function. If evaluated within a
<c>catch</c>, <c>catch</c> will return the value <c><anno>Any</anno></c>.</p>
<pre>
> <input>catch throw({hello, there}).</input>
{hello,there}</pre>
<p>Failure: <c>nocatch</c> if not evaluated within a catch.</p>
</desc>
</func>
<func>
<name name="time" arity="0"/>
<fsummary>Current time</fsummary>
<desc>
<p>Returns the current time as <c>{Hour, Minute, Second}</c>.</p>
<p>The time zone and daylight saving time correction depend on
the underlying OS.</p>
<pre>
> <input>time().</input>
{9,42,44}</pre>
</desc>
</func>
<func>
<name name="time_offset" arity="0"/>
<fsummary>Current time offset</fsummary>
<desc>
<p>Returns the current time offset between
<seealso marker="time_correction#Erlang_Monotonic_Time">Erlang monotonic time</seealso>
and
<seealso marker="time_correction#Erlang_System_Time">Erlang system time</seealso> in
<c>native</c> <seealso marker="#type_time_unit">time unit</seealso>.
Current time offset added to an Erlang monotonic time gives
corresponding Erlang system time.</p>
<p>The time offset may or may not change during operation depending
on the <seealso marker="time_correction#Time_Warp_Modes">time
warp mode</seealso> used.</p>
<note>
<p>A change in time offset may be observed at slightly
different points in time by different processes.</p>
<p>If the runtime system is in
<seealso marker="time_correction#Multi_Time_Warp_Mode">multi
time warp mode</seealso>, the time offset will be changed when
the runtime system detects that the
<seealso marker="time_correction#OS_System_Time">OS system
time</seealso> has changed. The runtime system will, however,
not detect this immediately when it happens. A task checking
the time offset is scheduled to execute at least once a minute,
so under normal operation this should be detected within a
minute, but during heavy load it might take longer time.</p>
</note>
</desc>
</func>
<func>
<name name="time_offset" arity="1"/>
<fsummary>Current time offset</fsummary>
<desc>
<p>Returns the current time offset between
<seealso marker="time_correction#Erlang_Monotonic_Time">Erlang monotonic time</seealso>
and
<seealso marker="time_correction#Erlang_System_Time">Erlang system time</seealso>
converted into the <c><anno>Unit</anno></c> passed as argument.</p>
<p>Same as calling
<seealso marker="#convert_time_unit/3"><c>erlang:convert_time_unit</c></seealso><c>(</c><seealso marker="#time_offset/0"><c>erlang:time_offset()</c></seealso><c>, native, <anno>Unit</anno>)</c>
however optimized for commonly used <c><anno>Unit</anno></c>s.</p>
</desc>
</func>
<func>
<name name="timestamp" arity="0"/>
<type name="timestamp"/>
<fsummary>Current Erlang System time</fsummary>
<desc>
<p>Returns current
<seealso marker="time_correction#Erlang_System_Time">Erlang system time</seealso>
on the format <c>{MegaSecs, Secs, MicroSecs}</c>. This format is
the same that <seealso marker="kernel:os#timestamp/0"><c>os:timestamp/0</c></seealso>
and the now deprecated <seealso marker="#now/0"><c>erlang:now/0</c></seealso>
uses. The reason for the existence of <c>erlang:timestamp()</c> is
purely to simplify usage for existing code that assumes this timestamp
format. Current Erlang system time can more efficiently be retrieved in
the time unit of your choice using
<seealso marker="#system_time/1"><c>erlang:system_time/1</c></seealso>.</p>
<p>The <c>erlang:timestamp()</c> BIF is equivalent to:</p><code type="none">
timestamp() ->
ErlangSystemTime = erlang:system_time(micro_seconds),
MegaSecs = ErlangSystemTime div 1000000000000,
Secs = ErlangSystemTime div 1000000 - MegaSecs*1000000,
MicroSecs = ErlangSystemTime rem 1000000,
{MegaSecs, Secs, MicroSecs}.</code>
<p>It however use a native implementation which does
not build garbage on the heap and with slightly better
performance.</p>
<note><p>This time is <em>not</em> a monotonically increasing time
in the general case. For more information, see the documentation of
<seealso marker="time_correction#Time_Warp_Modes">time warp modes</seealso> in the
ERTS User's Guide.</p></note>
</desc>
</func>
<func>
<name name="tl" arity="1"/>
<fsummary>Tail of a list</fsummary>
<desc>
<p>Returns the tail of <c><anno>List</anno></c>, that is, the list minus
the first element.</p>
<pre>
> <input>tl([geesties, guilies, beasties]).</input>
[guilies, beasties]</pre>
<p>Allowed in guard tests.</p>
<p>Failure: <c>badarg</c> if <c><anno>List</anno></c> is the empty list [].</p>
</desc>
</func>
<func>
<name name="trace" arity="3"/>
<type name="trace_flag"/>
<fsummary>Set trace flags for a process or processes</fsummary>
<desc>
<p>Turns on (if <c><anno>How</anno> == true</c>) or off (if
<c><anno>How</anno> == false</c>) the trace flags in <c><anno>FlagList</anno></c> for
the process or processes represented by <c><anno>PidSpec</anno></c>.</p>
<p><c><anno>PidSpec</anno></c> is either a pid for a local process, or one of
the following atoms:</p>
<taglist>
<tag><c>existing</c></tag>
<item>
<p>All processes currently existing.</p>
</item>
<tag><c>new</c></tag>
<item>
<p>All processes that will be created in the future.</p>
</item>
<tag><c>all</c></tag>
<item>
<p>All currently existing processes and all processes that
will be created in the future.</p>
</item>
</taglist>
<p><c><anno>FlagList</anno></c> can contain any number of the following
flags (the "message tags" refers to the list of messages
following below):</p>
<taglist>
<tag><c>all</c></tag>
<item>
<p>Set all trace flags except <c>{tracer, Tracer}</c> and
<c>cpu_timestamp</c> that are in their nature different
than the others.</p>
</item>
<tag><c>send</c></tag>
<item>
<p>Trace sending of messages.</p>
<p>Message tags: <c>send</c>,
<c>send_to_non_existing_process</c>.</p>
</item>
<tag><c>'receive'</c></tag>
<item>
<p>Trace receiving of messages.</p>
<p>Message tags: <c>'receive'</c>.</p>
</item>
<tag><c>procs</c></tag>
<item>
<p>Trace process related events.</p>
<p>Message tags: <c>spawn</c>, <c>exit</c>,
<c>register</c>, <c>unregister</c>, <c>link</c>,
<c>unlink</c>, <c>getting_linked</c>,
<c>getting_unlinked</c>.</p>
</item>
<tag><c>call</c></tag>
<item>
<p>Trace certain function calls. Specify which function
calls to trace by calling
<seealso marker="#trace_pattern/3">erlang:trace_pattern/3</seealso>.</p>
<p>Message tags: <c>call</c>, <c>return_from</c>.</p>
</item>
<tag><c>silent</c></tag>
<item>
<p>Used in conjunction with the <c>call</c> trace flag.
The <c>call</c>, <c>return_from</c> and <c>return_to</c>
trace messages are inhibited if this flag is set,
but if there are match specs they are executed as normal.</p>
<p>Silent mode is inhibited by executing
<c>erlang:trace(_, false, [silent|_])</c>,
or by a match spec executing the <c>{silent, false}</c>
function.</p>
<p>The <c>silent</c> trace flag facilitates setting up
a trace on many or even all processes in the system.
Then the interesting trace can be activated and
deactivated using the <c>{silent,Bool}</c>
match spec function, giving a high degree
of control of which functions with which
arguments that triggers the trace.</p>
<p>Message tags: <c>call</c>, <c>return_from</c>,
<c>return_to</c>. Or rather, the absence of.</p>
</item>
<tag><c>return_to</c></tag>
<item>
<p>Used in conjunction with the <c>call</c> trace flag.
Trace the actual return from a traced function back to
its caller. Only works for functions traced with
the <c>local</c> option to
<seealso marker="#trace_pattern/3">erlang:trace_pattern/3</seealso>.</p>
<p>The semantics is that a trace message is sent when a
call traced function actually returns, that is, when a
chain of tail recursive calls is ended. There will be
only one trace message sent per chain of tail recursive
calls, why the properties of tail recursiveness for
function calls are kept while tracing with this flag.
Using <c>call</c> and <c>return_to</c> trace together
makes it possible to know exactly in which function a
process executes at any time.</p>
<p>To get trace messages containing return values from
functions, use the <c>{return_trace}</c> match_spec
action instead.</p>
<p>Message tags: <c>return_to</c>.</p>
</item>
<tag><c>running</c></tag>
<item>
<p>Trace scheduling of processes.</p>
<p>Message tags: <c>in</c>, and <c>out</c>.</p>
</item>
<tag><c>exiting</c></tag>
<item>
<p>Trace scheduling of an exiting processes.</p>
<p>Message tags: <c>in_exiting</c>, <c>out_exiting</c>, and
<c>out_exited</c>.</p>
</item>
<tag><c>garbage_collection</c></tag>
<item>
<p>Trace garbage collections of processes.</p>
<p>Message tags: <c>gc_start</c>, <c>gc_end</c>.</p>
</item>
<tag><c>timestamp</c></tag>
<item>
<p>Include a time stamp in all trace messages. The time
stamp (Ts) is of the same form as returned by
<c>erlang:now()</c>.</p>
</item>
<tag><c>cpu_timestamp</c></tag>
<item>
<p>A global trace flag for the Erlang node that makes all
trace timestamps be in CPU time, not wallclock. It is
only allowed with <c>PidSpec==all</c>. If the host
machine operating system does not support high resolution
CPU time measurements, <c>trace/3</c> exits with
<c>badarg</c>. Note that most operating systems do
not synchronize this value across cores, so be prepared
that time might seem to go backwards when using this option.</p>
</item>
<tag><c>arity</c></tag>
<item>
<p>Used in conjunction with the <c>call</c> trace flag.
<c>{M, F, Arity}</c> will be specified instead of
<c>{M, F, Args}</c> in call trace messages.</p>
</item>
<tag><c>set_on_spawn</c></tag>
<item>
<p>Makes any process created by a traced process inherit
its trace flags, including the <c>set_on_spawn</c> flag.</p>
</item>
<tag><c>set_on_first_spawn</c></tag>
<item>
<p>Makes the first process created by a traced process
inherit its trace flags, excluding
the <c>set_on_first_spawn</c> flag.</p>
</item>
<tag><c>set_on_link</c></tag>
<item>
<p>Makes any process linked by a traced process inherit its
trace flags, including the <c>set_on_link</c> flag.</p>
</item>
<tag><c>set_on_first_link</c></tag>
<item>
<p>Makes the first process linked to by a traced process
inherit its trace flags, excluding
the <c>set_on_first_link</c> flag.</p>
</item>
<tag><c>{tracer, Tracer}</c></tag>
<item>
<p>Specify where to send the trace messages. <c>Tracer</c>
must be the pid of a local process or the port identifier
of a local port. If this flag is not given, trace
messages will be sent to the process that called
<c>erlang:trace/3</c>.</p>
</item>
</taglist>
<p>The effect of combining <c>set_on_first_link</c> with
<c>set_on_link</c> is the same as having
<c>set_on_first_link</c> alone. Likewise for
<c>set_on_spawn</c> and <c>set_on_first_spawn</c>.</p>
<p>If the <c>timestamp</c> flag is not given, the tracing
process will receive the trace messages described below.
<c>Pid</c> is the pid of the traced process in which
the traced event has occurred. The third element of the tuple
is the message tag.</p>
<p>If the <c>timestamp</c> flag is given, the first element of
the tuple will be <c>trace_ts</c> instead and the timestamp
is added last in the tuple.</p>
<taglist>
<tag><c>{trace, Pid, 'receive', Msg}</c></tag>
<item>
<p>When <c>Pid</c> receives the message <c>Msg</c>.</p>
</item>
<tag><c>{trace, Pid, send, Msg, To}</c></tag>
<item>
<p>When <c>Pid</c> sends the message <c>Msg</c> to
the process <c>To</c>.</p>
</item>
<tag><c>{trace, Pid, send_to_non_existing_process, Msg, To}</c></tag>
<item>
<p>When <c>Pid</c> sends the message <c>Msg</c> to
the non-existing process <c>To</c>.</p>
</item>
<tag><c>{trace, Pid, call, {M, F, Args}}</c></tag>
<item>
<p>When <c>Pid</c> calls a traced function. The return
values of calls are never supplied, only the call and its
arguments.</p>
<p>Note that the trace flag <c>arity</c> can be used to
change the contents of this message, so that <c>Arity</c>
is specified instead of <c>Args</c>.</p>
</item>
<tag><c>{trace, Pid, return_to, {M, F, Arity}}</c></tag>
<item>
<p>When <c>Pid</c> returns <em>to</em> the specified
function. This trace message is sent if both
the <c>call</c> and the <c>return_to</c> flags are set,
and the function is set to be traced on <em>local</em>
function calls. The message is only sent when returning
from a chain of tail recursive function calls where at
least one call generated a <c>call</c> trace message
(that is, the functions match specification matched and
<c>{message, false}</c> was not an action).</p>
</item>
<tag><c>{trace, Pid, return_from, {M, F, Arity}, ReturnValue}</c></tag>
<item>
<p>When <c>Pid</c> returns <em>from</em> the specified
function. This trace message is sent if the <c>call</c>
flag is set, and the function has a match specification
with a <c>return_trace</c> or <c>exception_trace</c> action.</p>
</item>
<tag><c>{trace, Pid, exception_from, {M, F, Arity}, {Class, Value}}</c></tag>
<item>
<p>When <c>Pid</c> exits <em>from</em> the specified
function due to an exception. This trace message is sent
if the <c>call</c> flag is set, and the function has
a match specification with an <c>exception_trace</c> action.</p>
</item>
<tag><c>{trace, Pid, spawn, Pid2, {M, F, Args}}</c></tag>
<item>
<p>When <c>Pid</c> spawns a new process <c>Pid2</c> with
the specified function call as entry point.</p>
<p>Note that <c>Args</c> is supposed to be the argument
list, but may be any term in the case of an erroneous
spawn.</p>
</item>
<tag><c>{trace, Pid, exit, Reason}</c></tag>
<item>
<p>When <c>Pid</c> exits with reason <c>Reason</c>.</p>
</item>
<tag><c>{trace, Pid, link, Pid2}</c></tag>
<item>
<p>When <c>Pid</c> links to a process <c>Pid2</c>.</p>
</item>
<tag><c>{trace, Pid, unlink, Pid2}</c></tag>
<item>
<p>When <c>Pid</c> removes the link from a process
<c>Pid2</c>.</p>
</item>
<tag><c>{trace, Pid, getting_linked, Pid2}</c></tag>
<item>
<p>When <c>Pid</c> gets linked to a process <c>Pid2</c>.</p>
</item>
<tag><c>{trace, Pid, getting_unlinked, Pid2}</c></tag>
<item>
<p>When <c>Pid</c> gets unlinked from a process <c>Pid2</c>.</p>
</item>
<tag><c>{trace, Pid, register, RegName}</c></tag>
<item>
<p>When <c>Pid</c> gets the name <c>RegName</c> registered.</p>
</item>
<tag><c>{trace, Pid, unregister, RegName}</c></tag>
<item>
<p>When <c>Pid</c> gets the name <c>RegName</c> unregistered.
Note that this is done automatically when a registered
process exits.</p>
</item>
<tag><c>{trace, Pid, in, {M, F, Arity} | 0}</c></tag>
<item>
<p>When <c>Pid</c> is scheduled to run. The process will
run in function <c>{M, F, Arity}</c>. On some rare
occasions the current function cannot be determined, then
the last element <c>Arity</c> is 0.</p>
</item>
<tag><c>{trace, Pid, out, {M, F, Arity} | 0}</c></tag>
<item>
<p>When <c>Pid</c> is scheduled out. The process was
running in function {M, F, Arity}. On some rare occasions
the current function cannot be determined, then the last
element <c>Arity</c> is 0.</p>
</item>
<tag><marker id="gc_start"><c>{trace, Pid, gc_start, Info}</c></marker></tag>
<item>
<p>Sent when garbage collection is about to be started.
<c>Info</c> is a list of two-element tuples, where
the first element is a key, and the second is the value.
You should not depend on the tuples have any defined
order. Currently, the following keys are defined:</p>
<taglist>
<tag><c>heap_size</c></tag>
<item>The size of the used part of the heap.</item>
<tag><c>heap_block_size</c></tag>
<item>The size of the memory block used for storing
the heap and the stack.</item>
<tag><c>old_heap_size</c></tag>
<item>The size of the used part of the old heap.</item>
<tag><c>old_heap_block_size</c></tag>
<item>The size of the memory block used for storing
the old heap.</item>
<tag><c>stack_size</c></tag>
<item>The actual size of the stack.</item>
<tag><c>recent_size</c></tag>
<item>The size of the data that survived the previous garbage
collection.</item>
<tag><c>mbuf_size</c></tag>
<item>The combined size of message buffers associated with
the process.</item>
<tag><c>bin_vheap_size</c></tag>
<item>The total size of unique off-heap binaries referenced from the process heap.</item>
<tag><c>bin_vheap_block_size</c></tag>
<item>The total size of binaries, in words, allowed in the virtual
heap in the process before doing a garbage collection. </item>
<tag><c>bin_old_vheap_size</c></tag>
<item>The total size of unique off-heap binaries referenced from the process old heap.</item>
<tag><c>bin_vheap_block_size</c></tag>
<item>The total size of binaries, in words, allowed in the virtual
old heap in the process before doing a garbage collection. </item>
</taglist>
<p>All sizes are in words.</p>
</item>
<tag><c>{trace, Pid, gc_end, Info}</c></tag>
<item>
<p>Sent when garbage collection is finished. <c>Info</c>
contains the same kind of list as in the <c>gc_start</c>
message, but the sizes reflect the new sizes after
garbage collection.</p>
</item>
</taglist>
<p>If the tracing process dies, the flags will be silently
removed.</p>
<p>Only one process can trace a particular process. For this
reason, attempts to trace an already traced process will fail.</p>
<p>Returns: A number indicating the number of processes that
matched <c><anno>PidSpec</anno></c>. If <c><anno>PidSpec</anno></c> is a pid,
the return value will be <c>1</c>. If <c><anno>PidSpec</anno></c> is
<c>all</c> or <c>existing</c> the return value will be
the number of processes running, excluding tracer processes.
If <c><anno>PidSpec</anno></c> is <c>new</c>, the return value will be
<c>0</c>.</p>
<p>Failure: If specified arguments are not supported. For
example <c>cpu_timestamp</c> is not supported on all
platforms.</p>
</desc>
</func>
<func>
<name name="trace_delivered" arity="1"/>
<fsummary>Notification when trace has been delivered</fsummary>
<desc>
<p>The delivery of trace messages is dislocated on the time-line
compared to other events in the system. If you know that the
<c><anno>Tracee</anno></c> has passed some specific point in its execution,
and you want to know when at least all trace messages
corresponding to events up to this point have reached the tracer
you can use <c>erlang:trace_delivered(<anno>Tracee</anno>)</c>. A
<c>{trace_delivered, <anno>Tracee</anno>, <anno>Ref</anno>}</c> message is sent to
the caller of <c>erlang:trace_delivered(<anno>Tracee</anno>)</c> when it
is guaranteed that all trace messages have been delivered to
the tracer up to the point that the <c><anno>Tracee</anno></c> had reached
at the time of the call to
<c>erlang:trace_delivered(<anno>Tracee</anno>)</c>.</p>
<p>Note that the <c>trace_delivered</c> message does <em>not</em>
imply that trace messages have been delivered; instead, it implies
that all trace messages that <em>should</em> be delivered have
been delivered. It is not an error if <c><anno>Tracee</anno></c> isn't, and
hasn't been traced by someone, but if this is the case,
<em>no</em> trace messages will have been delivered when the
<c>trace_delivered</c> message arrives.</p>
<p>Note that <c><anno>Tracee</anno></c> has to refer to a process currently,
or previously existing on the same node as the caller of
<c>erlang:trace_delivered(<anno>Tracee</anno>)</c> resides on.
The special <c><anno>Tracee</anno></c> atom <c>all</c> denotes all processes
that currently are traced in the node.</p>
<p>An example: Process <c>A</c> is <c><anno>Tracee</anno></c>, port <c>B</c> is
tracer, and process <c>C</c> is the port owner of <c>B</c>.
<c>C</c> wants to close <c>B</c> when <c>A</c> exits. <c>C</c>
can ensure that the trace isn't truncated by calling
<c>erlang:trace_delivered(A)</c> when <c>A</c> exits and wait
for the <c>{trace_delivered, A, <anno>Ref</anno>}</c> message before closing
<c>B</c>.</p>
<p>Failure: <c>badarg</c> if <c><anno>Tracee</anno></c> does not refer to a
process (dead or alive) on the same node as the caller of
<c>erlang:trace_delivered(<anno>Tracee</anno>)</c> resides on.</p>
</desc>
</func>
<func>
<name name="trace_info" arity="2"/>
<type name="trace_info_return"/>
<type name="trace_info_item_result"/>
<type name="trace_info_flag"/>
<type name="trace_match_spec"/>
<fsummary>Trace information about a process or function</fsummary>
<desc>
<p>Returns trace information about a process or function.</p>
<p>To get information about a process, <c><anno>PidOrFunc</anno></c> should
be a pid or the atom <c>new</c>. The atom <c>new</c> means
that the default trace state for processes to be created will
be returned. <c><anno>Item</anno></c> must have one of the following
values:</p>
<taglist>
<tag><c>flags</c></tag>
<item>
<p>Return a list of atoms indicating what kind of traces is
enabled for the process. The list will be empty if no
traces are enabled, and one or more of the followings
atoms if traces are enabled: <c>send</c>,
<c>'receive'</c>, <c>set_on_spawn</c>, <c>call</c>,
<c>return_to</c>, <c>procs</c>, <c>set_on_first_spawn</c>,
<c>set_on_link</c>, <c>running</c>,
<c>garbage_collection</c>, <c>timestamp</c>, and
<c>arity</c>. The order is arbitrary.</p>
</item>
<tag><c>tracer</c></tag>
<item>
<p>Return the identifier for process or port tracing this
process. If this process is not being traced, the return
value will be <c>[]</c>.</p>
</item>
</taglist>
<p>To get information about a function, <c>PidOrFunc</c> should
be a three-element tuple: <c>{Module, Function, Arity}</c> or
the atom <c>on_load</c>. No wildcards are allowed. Returns
<c>undefined</c> if the function does not exist or
<c>false</c> if the function is not traced at all. <c>Item</c>
must have one of the following values:</p>
<taglist>
<tag><c>traced</c></tag>
<item>
<p>Return <c>global</c> if this function is traced on
global function calls, <c>local</c> if this function is
traced on local function calls (i.e local and global
function calls), and <c>false</c> if neither local nor
global function calls are traced.</p>
</item>
<tag><c>match_spec</c></tag>
<item>
<p>Return the match specification for this function, if it
has one. If the function is locally or globally traced but
has no match specification defined, the returned value
is <c>[]</c>.</p>
</item>
<tag><c>meta</c></tag>
<item>
<p>Return the meta trace tracer process or port for this
function, if it has one. If the function is not meta
traced the returned value is <c>false</c>, and if
the function is meta traced but has once detected that
the tracer proc is invalid, the returned value is [].</p>
</item>
<tag><c>meta_match_spec</c></tag>
<item>
<p>Return the meta trace match specification for this
function, if it has one. If the function is meta traced
but has no match specification defined, the returned
value is <c>[]</c>.</p>
</item>
<tag><c>call_count</c></tag>
<item>
<p>Return the call count value for this function or
<c>true</c> for the pseudo function <c>on_load</c> if call
count tracing is active. Return <c>false</c> otherwise.
See also
<seealso marker="#trace_pattern/3">erlang:trace_pattern/3</seealso>.</p>
</item>
<tag><c>call_time</c></tag>
<item>
<p>Return the call time values for this function or
<c>true</c> for the pseudo function <c>on_load</c> if call
time tracing is active. Returns <c>false</c> otherwise.
The call time values returned, <c>[{Pid, Count, S, Us}]</c>,
is a list of each process that has executed the function and its specific counters.
See also
<seealso marker="#trace_pattern/3">erlang:trace_pattern/3</seealso>.</p>
</item>
<tag><c>all</c></tag>
<item>
<p>Return a list containing the <c>{<anno>Item</anno>, Value}</c> tuples
for all other items, or return <c>false</c> if no tracing
is active for this function.</p>
</item>
</taglist>
<p>The actual return value will be <c>{<anno>Item</anno>, Value}</c>, where
<c>Value</c> is the requested information as described above.
If a pid for a dead process was given, or the name of a
non-existing function, <c>Value</c> will be <c>undefined</c>.</p>
<p>If <c><anno>PidOrFunc</anno></c> is the <c>on_load</c>, the information
returned refers to the default value for code that will be
loaded.</p>
</desc>
</func>
<func>
<name name="trace_pattern" arity="2" clause_i="1"/>
<type name="trace_pattern_mfa"/>
<type name="trace_match_spec"/>
<fsummary>Set trace patterns for global call tracing</fsummary>
<desc>
<p>The same as
<seealso marker="#trace_pattern/3">erlang:trace_pattern(MFA, MatchSpec, [])</seealso>,
retained for backward compatibility.</p>
</desc>
</func>
<func>
<name name="trace_pattern" arity="3"/>
<type name="trace_pattern_mfa"/>
<type name="trace_match_spec"/>
<type name="trace_pattern_flag"/>
<fsummary>Set trace patterns for tracing of function calls</fsummary>
<desc>
<p>This BIF is used to enable or disable call tracing for
exported functions. It must be combined with
<seealso marker="#trace/3">erlang:trace/3</seealso>
to set the <c>call</c> trace flag for one or more processes.</p>
<p>Conceptually, call tracing works like this: Inside
the Erlang virtual machine there is a set of processes to be
traced and a set of functions to be traced. Tracing will be
enabled on the intersection of the set. That is, if a process
included in the traced process set calls a function included
in the traced function set, the trace action will be taken.
Otherwise, nothing will happen.</p>
<p>Use
<seealso marker="#trace/3">erlang:trace/3</seealso> to
add or remove one or more processes to the set of traced
processes. Use <c>erlang:trace_pattern/2</c> to add or remove
exported functions to the set of traced functions.</p>
<p>The <c>erlang:trace_pattern/3</c> BIF can also add match
specifications to an exported function. A match specification
comprises a pattern that the arguments to the function must
match, a guard expression which must evaluate to <c>true</c>
and an action to be performed. The default action is to send a
trace message. If the pattern does not match or the guard
fails, the action will not be executed.</p>
<p>The <c><anno>MFA</anno></c> argument should be a tuple like
<c>{Module, Function, Arity}</c> or the atom <c>on_load</c>
(described below). It can be the module, function, and arity
for an exported function (or a BIF in any module).
The <c>'_'</c> atom can be used to mean any of that kind.
Wildcards can be used in any of the following ways:</p>
<taglist>
<tag><c>{Module,Function,'_'}</c></tag>
<item>
<p>All exported functions of any arity named <c>Function</c>
in module <c>Module</c>.</p>
</item>
<tag><c>{Module,'_','_'}</c></tag>
<item>
<p>All exported functions in module <c>Module</c>.</p>
</item>
<tag><c>{'_','_','_'}</c></tag>
<item>
<p>All exported functions in all loaded modules.</p>
</item>
</taglist>
<p>Other combinations, such as <c>{Module,'_',Arity}</c>, are
not allowed. Local functions will match wildcards only if
the <c>local</c> option is in the <c><anno>FlagList</anno></c>.</p>
<p>If the <c><anno>MFA</anno></c> argument is the atom <c>on_load</c>,
the match specification and flag list will be used on all
modules that are newly loaded.</p>
<p>The <c><anno>MatchSpec</anno></c> argument can take any of the following
forms:</p>
<taglist>
<tag><c>false</c></tag>
<item>
<p>Disable tracing for the matching function(s). Any match
specification will be removed.</p>
</item>
<tag><c>true</c></tag>
<item>
<p>Enable tracing for the matching function(s).</p>
</item>
<tag><c><anno>MatchSpecList</anno></c></tag>
<item>
<p>A list of match specifications. An empty list is
equivalent to <c>true</c>. See the ERTS User's Guide
for a description of match specifications.</p>
</item>
<tag><c>restart</c></tag>
<item>
<p>For the <c><anno>FlagList</anno></c> option <c>call_count</c> and <c>call_time</c>:
restart the existing counters. The behaviour is undefined
for other <c><anno>FlagList</anno></c> options.</p>
</item>
<tag><c>pause</c></tag>
<item>
<p>For the <c><anno>FlagList</anno></c> option <c>call_count</c> and <c>call_time</c>: pause
the existing counters. The behaviour is undefined for
other <c>FlagList</c> options.</p>
</item>
</taglist>
<p>The <c><anno>FlagList</anno></c> parameter is a list of options.
The following options are allowed:</p>
<taglist>
<tag><c>global</c></tag>
<item>
<p>Turn on or off call tracing for global function calls
(that is, calls specifying the module explicitly). Only
exported functions will match and only global calls will
generate trace messages. This is the default.</p>
</item>
<tag><c>local</c></tag>
<item>
<p>Turn on or off call tracing for all types of function
calls. Trace messages will be sent whenever any of
the specified functions are called, regardless of how they
are called. If the <c>return_to</c> flag is set for
the process, a <c>return_to</c> message will also be sent
when this function returns to its caller.</p>
</item>
<tag><c>meta | {meta, <anno>Pid</anno>}</c></tag>
<item>
<p>Turn on or off meta tracing for all types of function
calls. Trace messages will be sent to the tracer process
or port <c><anno>Pid</anno></c> whenever any of the specified
functions are called, regardless of how they are called.
If no <c><anno>Pid</anno></c> is specified, <c>self()</c> is used as a
default tracer process.</p>
<p>Meta tracing traces all processes and does not care
about the process trace flags set by <c>trace/3</c>,
the trace flags are instead fixed to
<c>[call, timestamp]</c>.</p>
<p>The match spec function <c>{return_trace}</c> works with
meta trace and send its trace message to the same tracer
process.</p>
</item>
<tag><c>call_count</c></tag>
<item>
<p>Starts (<c><anno>MatchSpec</anno> == true</c>) or stops
(<c><anno>MatchSpec</anno> == false</c>) call count tracing for all
types of function calls. For every function a counter is
incremented when the function is called, in any process.
No process trace flags need to be activated.</p>
<p>If call count tracing is started while already running,
the count is restarted from zero. Running counters can be
paused with <c><anno>MatchSpec</anno> == pause</c>. Paused and running
counters can be restarted from zero with
<c><anno>MatchSpec</anno> == restart</c>.</p>
<p>The counter value can be read with
<seealso marker="#trace_info/2">erlang:trace_info/2</seealso>.</p>
</item>
<tag><c>call_time</c></tag>
<item>
<p>Starts (<c><anno>MatchSpec</anno> == true</c>) or stops
(<c><anno>MatchSpec</anno> == false</c>) call time tracing for all
types of function calls. For every function a counter is
incremented when the function is called. Time spent in the function
is accumulated in two other counters, seconds and micro-seconds.
The counters are stored for each call traced process.</p>
<p>If call time tracing is started while already running,
the count and time is restarted from zero. Running counters can be
paused with <c><anno>MatchSpec</anno> == pause</c>. Paused and running
counters can be restarted from zero with
<c><anno>MatchSpec</anno> == restart</c>.</p>
<p>The counter value can be read with
<seealso marker="#trace_info/2">erlang:trace_info/2</seealso>.</p>
</item>
</taglist>
<p>The <c>global</c> and <c>local</c> options are mutually
exclusive and <c>global</c> is the default (if no options are
specified). The <c>call_count</c> and <c>meta</c> options
perform a kind of local tracing, and can also not be combined
with <c>global</c>. A function can be either globally or
locally traced. If global tracing is specified for a
specified set of functions; local, meta, call time and call count
tracing for the matching set of local functions will be
disabled, and vice versa.</p>
<p>When disabling trace, the option must match the type of trace
that is set on the function, so that local tracing must be
disabled with the <c>local</c> option and global tracing with
the <c>global</c> option (or no option at all), and so forth.</p>
<p>There is no way to directly change part of a match
specification list. If a function has a match specification,
you can replace it with a completely new one. If you need to
change an existing match specification, use the
<seealso marker="#trace_info/2">erlang:trace_info/2</seealso>
BIF to retrieve the existing match specification.</p>
<p>Returns the number of exported functions that matched
the <c><anno>MFA</anno></c> argument. This will be zero if none matched at
all.</p>
</desc>
</func>
<func>
<name name="trunc" arity="1"/>
<fsummary>Return an integer by the truncating a number</fsummary>
<desc>
<p>Returns an integer by the truncating <c><anno>Number</anno></c>.</p>
<pre>
> <input>trunc(5.5).</input>
5</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="tuple_size" arity="1"/>
<fsummary>Return the size of a tuple</fsummary>
<desc>
<p>Returns an integer which is the number of elements in <c><anno>Tuple</anno></c>.</p>
<pre>
> <input>tuple_size({morni, mulle, bwange}).</input>
3</pre>
<p>Allowed in guard tests.</p>
</desc>
</func>
<func>
<name name="tuple_to_list" arity="1"/>
<fsummary>Convert a tuple to a list</fsummary>
<desc>
<p>Returns a list which corresponds to <c><anno>Tuple</anno></c>.
<c><anno>Tuple</anno></c> may contain any Erlang terms.</p>
<pre>
> <input>tuple_to_list({share, {'Ericsson_B', 163}}).</input>
[share,{'Ericsson_B',163}]</pre>
</desc>
</func>
<func>
<name name="universaltime" arity="0"/>
<fsummary>Current date and time according to Universal Time Coordinated (UTC)</fsummary>
<desc>
<p>Returns the current date and time according to Universal
Time Coordinated (UTC), also called GMT, in the form
<c>{{Year, Month, Day}, {Hour, Minute, Second}}</c> if
supported by the underlying operating system. If not,
<c>erlang:universaltime()</c> is equivalent to
<c>erlang:localtime()</c>.</p>
<pre>
> <input>erlang:universaltime().</input>
{{1996,11,6},{14,18,43}}</pre>
</desc>
</func>
<func>
<name name="universaltime_to_localtime" arity="1"/>
<fsummary>Convert from Universal Time Coordinated (UTC) to local date and time</fsummary>
<desc>
<p>Converts Universal Time Coordinated (UTC) date and time to
local date and time, if this is supported by the underlying
OS. Otherwise, no conversion is done, and
<c><anno>Universaltime</anno></c> is returned.</p>
<pre>
> <input>erlang:universaltime_to_localtime({{1996,11,6},{14,18,43}}).</input>
{{1996,11,7},{15,18,43}}</pre>
<p>Failure: <c>badarg</c> if <c>Universaltime</c> does not denote
a valid date and time.</p>
</desc>
</func>
<func>
<name name="unique_integer" arity="0"/>
<fsummary>Get a unique integer value</fsummary>
<desc>
<p>Generates and returns an
<seealso marker="doc/efficiency_guide:advanced#unique_integers">integer
unique on current runtime system instance</seealso>. The same as calling
<seealso marker="#unique_integer/1"><c>erlang:unique_integer([])</c></seealso>.</p>
</desc>
</func>
<func>
<name name="unique_integer" arity="1"/>
<fsummary>Get a unique integer value</fsummary>
<desc>
<p>Generates and returns an
<seealso marker="doc/efficiency_guide:advanced#unique_integers">integer
unique on current runtime system
instance</seealso>. The integer is unique in the
sense that this BIF, using the same set of
modifiers, will not return the same integer more
than once on the current runtime system instance.
Each integer value can of course be constructed
by other means.</p>
<p>By default, i.e. when <c>[]</c> is passed as
<c><anno>ModifierList</anno></c>, both negative and
positive integers will be returned. This is order
to be able to utilize the range of integers that do
not need to be heap allocated as much as possible.
By default the returned integers are also only
guaranteed to be unique, i.e., any integer returned
may be either smaller, or larger than previously
returned integers.</p>
<p>Currently valid <c><anno>Modifier</anno></c>s:</p>
<taglist>
<tag>positive</tag>
<item><p>Return only positive integers.</p>
<p>Note that by passing the <c>positive</c> modifier
you will get heap allocated integers (big-nums)
quicker.</p>
</item>
<tag>monotonic</tag>
<item><p>Return
<seealso marker="time_correction#Strictly_Monotonically_Increasing">strictly
monotonically increasing</seealso> integers
corresponding to creation time. That is, the integer
returned will always be larger than previously
returned integers on the current runtime system
instance.</p>
<p>These values can be used when ordering events
on the runtime system instance. That is, if both
<c>X = erlang:unique_integer([monotonic])</c> and
<c>Y = erlang:unique_integer([monotonic])</c> are
executed by different processes (or the same
process) on the same runtime system instance and
<c>X < Y</c> we know that <c>X</c> was created
before <c>Y</c>.</p>
<warning><p>Strictly monotonically increasing values
are inherently quite expensive to generate and scales
poorly. This since the values needs to be
synchronized. That is, do not pass the <c>monotonic</c>
modifier unless you really need strictly monotonically
increasing values.</p></warning>
</item>
</taglist>
<p>All currently valid <c><anno>Modifier</anno></c>s
can be combined. Repeated (valid)
<c><anno>Modifier</anno></c>s in the <c>ModifierList</c>
are ignored.</p>
<note><p>Note that the set of integers returned by
<c>unique_integer/1</c> using diffrent sets of
<c><anno>Modifier</anno></c>s <em>will overlap</em>.
For example, by calling <c>unique_integer([monotonic])</c>,
and <c>unique_integer([positive, monotonic])</c>
repeatedly, you will eventually see some integers being
returned by both calls.</p></note>
<p>Failures:</p>
<taglist>
<tag><c>badarg</c></tag>
<item>if <c><anno>ModifierList</anno></c> is not a
proper list.</item>
<tag><c>badarg</c></tag>
<item>if <c><anno>Modifier</anno></c> is not a
valid modifier.</item>
</taglist>
</desc>
</func>
<func>
<name name="unlink" arity="1"/>
<fsummary>Remove a link, if there is one, to another process or port</fsummary>
<desc>
<p>Removes the link, if there is one, between the calling
process and the process or port referred to by <c><anno>Id</anno></c>.</p>
<p>Returns <c>true</c> and does not fail, even if there is no
link to <c><anno>Id</anno></c>, or if <c><anno>Id</anno></c> does not exist.</p>
<p>Once <c>unlink(<anno>Id</anno>)</c> has returned it is guaranteed that
the link between the caller and the entity referred to by
<c><anno>Id</anno></c> has no effect on the caller in the future (unless
the link is setup again). If caller is trapping exits, an
<c>{'EXIT', <anno>Id</anno>, _}</c> message due to the link might have
been placed in the caller's message queue prior to the call,
though. Note, the <c>{'EXIT', <anno>Id</anno>, _}</c> message can be the
result of the link, but can also be the result of <c><anno>Id</anno></c>
calling <c>exit/2</c>. Therefore, it <em>may</em> be
appropriate to cleanup the message queue when trapping exits
after the call to <c>unlink(<anno>Id</anno>)</c>, as follow:</p>
<code type="none">
unlink(Id),
receive
{'EXIT', Id, _} ->
true
after 0 ->
true
end</code>
<note>
<p>Prior to OTP release R11B (erts version 5.5) <c>unlink/1</c>
behaved completely asynchronous, i.e., the link was active
until the "unlink signal" reached the linked entity. This
had one undesirable effect, though. You could never know when
you were guaranteed <em>not</em> to be effected by the link.</p>
<p>Current behavior can be viewed as two combined operations:
asynchronously send an "unlink signal" to the linked entity
and ignore any future results of the link.</p>
</note>
</desc>
</func>
<func>
<name name="unregister" arity="1"/>
<fsummary>Remove the registered name for a process (or port)</fsummary>
<desc>
<p>Removes the registered name <c><anno>RegName</anno></c>, associated with a
pid or a port identifier.</p>
<pre>
> <input>unregister(db).</input>
true</pre>
<p>Users are advised not to unregister system processes.</p>
<p>Failure: <c>badarg</c> if <c>RegName</c> is not a registered
name.</p>
</desc>
</func>
<func>
<name name="whereis" arity="1"/>
<fsummary>Get the pid (or port) with a given registered name</fsummary>
<desc>
<p>Returns the pid or port identifier with the registered name
<c>RegName</c>. Returns <c>undefined</c> if the name is not
registered.</p>
<pre>
> <input>whereis(db).</input>
<0.43.0></pre>
</desc>
</func>
<func>
<name name="yield" arity="0"/>
<fsummary>Let other processes get a chance to execute</fsummary>
<desc>
<p>Voluntarily let other processes (if any) get a chance to
execute. Using <c>erlang:yield()</c> is similar to
<c>receive after 1 -> ok end</c>, except that <c>yield()</c>
is faster.</p>
<warning><p>There is seldom or never any need to use this BIF,
especially in the SMP-emulator as other processes will have a
chance to run in another scheduler thread anyway.
Using this BIF without a thorough grasp of how the scheduler
works may cause performance degradation.</p></warning>
</desc>
</func>
</funcs>
</erlref>
|