4
* Copyright Ericsson AB 1999-2009. All Rights Reserved.
4
* Copyright Ericsson AB 1999-2011. All Rights Reserved.
6
6
* The contents of this file are subject to the Erlang Public License,
7
7
* Version 1.1, (the "License"); you may not use this file except in
8
8
* compliance with the License. You should have received a copy of the
9
9
* Erlang Public License along with this software. If not, it can be
10
10
* retrieved online at http://www.erlang.org/.
12
12
* Software distributed under the License is distributed on an "AS IS"
13
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
* the License for the specific language governing rights and limitations
15
15
* under the License.
118
bld_bin_list(Uint **hpp, Uint *szp, ProcBin* pb)
123
bld_bin_list(Uint **hpp, Uint *szp, ErlOffHeap* oh)
125
struct erl_off_heap_header* ohh;
123
for (; pb; pb = pb->next) {
124
Eterm val = erts_bld_uint(hpp, szp, (Uint) pb->val);
125
Eterm orig_size = erts_bld_uint(hpp, szp, pb->val->orig_size);
130
Uint refc = (Uint) erts_smp_atomic_read(&pb->val->refc);
131
tuple = TUPLE3(*hpp, val, orig_size, make_small(refc));
132
res = CONS(*hpp + 4, tuple, res);
129
for (ohh = oh->first; ohh; ohh = ohh->next) {
130
if (ohh->thing_word == HEADER_PROC_BIN) {
131
ProcBin* pb = (ProcBin*) ohh;
132
Eterm val = erts_bld_uword(hpp, szp, (UWord) pb->val);
133
Eterm orig_size = erts_bld_uint(hpp, szp, pb->val->orig_size);
138
Uint refc = (Uint) erts_smp_atomic_read(&pb->val->refc);
139
tuple = TUPLE3(*hpp, val, orig_size, make_small(refc));
140
res = CONS(*hpp + 4, tuple, res);
170
179
Eterm r = (IS_CONST(mon->ref)
172
: STORE_NC(&(pmlc->hp), &MSO(pmlc->p).externals, mon->ref));
181
: STORE_NC(&(pmlc->hp), &MSO(pmlc->p), mon->ref));
173
182
Eterm p = (IS_CONST(mon->pid)
175
: STORE_NC(&(pmlc->hp), &MSO(pmlc->p).externals, mon->pid));
184
: STORE_NC(&(pmlc->hp), &MSO(pmlc->p), mon->pid));
176
185
tup = TUPLE5(pmlc->hp, pmlc->tag, make_small(mon->type), r, p, mon->name);
178
187
pmlc->res = CONS(pmlc->hp, tup, pmlc->res);
233
242
Eterm old_res, targets = NIL;
234
243
Eterm p = (IS_CONST(lnk->pid)
236
: STORE_NC(&(pllc->hp), &MSO(pllc->p).externals, lnk->pid));
245
: STORE_NC(&(pllc->hp), &MSO(pllc->p), lnk->pid));
237
246
if (lnk->type == LINK_NODE) {
238
247
targets = make_small(ERTS_LINK_REFC(lnk));
239
248
} else if (ERTS_LINK_ROOT(lnk) != NULL) {
589
600
case am_last_calls: return 24;
590
601
case am_total_heap_size: return 25;
591
602
case am_suspending: return 26;
603
case am_min_heap_size: return 27;
604
case am_min_bin_vheap_size: return 28;
593
case am_message_binary: return 27;
606
case am_message_binary: return 29;
595
608
default: return -1;
620
633
#define ERTS_PI_1_NO_OF_KEYS (sizeof(pi_1_keys)/sizeof(Eterm))
622
635
static Eterm pi_1_keys_list;
623
static Uint pi_1_keys_list_heap[2*ERTS_PI_1_NO_OF_KEYS];
637
static Eterm pi_1_keys_list_heap[2*ERTS_PI_1_NO_OF_KEYS];
626
641
process_info_init(void)
628
644
Eterm *hp = &pi_1_keys_list_heap[0];
646
Eterm *hp = erts_alloc(ERTS_ALC_T_LL_TEMP_TERM,sizeof(Eterm)*2*ERTS_PI_1_NO_OF_KEYS);
631
650
pi_1_keys_list = NIL;
1208
1227
hp = HAlloc(BIF_P, 3 + mic.sz);
1210
1229
for (i = 0; i < mic.mi_i; i++) {
1211
item = STORE_NC(&hp, &MSO(BIF_P).externals, mic.mi[i].entity);
1230
item = STORE_NC(&hp, &MSO(BIF_P), mic.mi[i].entity);
1212
1231
res = CONS(hp, item, res);
1242
1261
/* Monitor by pid. Build {process, Pid} and cons it. */
1244
Eterm pid = STORE_NC(&hp,
1245
&MSO(BIF_P).externals,
1263
Eterm pid = STORE_NC(&hp, &MSO(BIF_P), mic.mi[i].entity);
1247
1264
t = TUPLE2(hp, am_process, pid);
1249
1266
res = CONS(hp, t, res);
1267
1284
for (i = 0; i < mic.mi_i; ++i) {
1268
item = STORE_NC(&hp, &MSO(BIF_P).externals, mic.mi[i].entity);
1285
item = STORE_NC(&hp, &MSO(BIF_P), mic.mi[i].entity);
1269
1286
res = CONS(hp, item, res);
1375
case am_fullsweep_after: {
1377
(void) erts_bld_uint(NULL, &hsz, MAX_GEN_GCS(rp));
1378
hp = HAlloc(BIF_P, hsz);
1379
res = erts_bld_uint(&hp, NULL, MAX_GEN_GCS(rp));
1383
case am_min_heap_size: {
1385
(void) erts_bld_uint(NULL, &hsz, MIN_HEAP_SIZE(rp));
1386
hp = HAlloc(BIF_P, hsz);
1387
res = erts_bld_uint(&hp, NULL, MIN_HEAP_SIZE(rp));
1391
case am_min_bin_vheap_size: {
1393
(void) erts_bld_uint(NULL, &hsz, MIN_VHEAP_SIZE(rp));
1394
hp = HAlloc(BIF_P, hsz);
1395
res = erts_bld_uint(&hp, NULL, MIN_VHEAP_SIZE(rp));
1358
1399
case am_total_heap_size: {
1359
1400
ErlMessage *mp;
1360
1401
Uint total_heap_size;
1433
1474
DECL_AM(minor_gcs);
1436
hp = HAlloc(BIF_P, 3+2+3+2+3);
1437
t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp)));
1439
res = CONS(hp, t, NIL);
1441
t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp)));
1443
res = CONS(hp, t, res);
1477
hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2 + 3+2 + 3); /* last "3" is for outside tuple */
1479
t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp))); hp += 3;
1480
res = CONS(hp, t, NIL); hp += 2;
1481
t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp))); hp += 3;
1482
res = CONS(hp, t, res); hp += 2;
1484
t = TUPLE2(hp, am_min_heap_size, make_small(MIN_HEAP_SIZE(rp))); hp += 3;
1485
res = CONS(hp, t, res); hp += 2;
1486
t = TUPLE2(hp, am_min_bin_vheap_size, make_small(MIN_VHEAP_SIZE(rp))); hp += 3;
1487
res = CONS(hp, t, res); hp += 2;
1448
1491
case am_group_leader: {
1449
1492
int sz = NC_HEAP_SIZE(rp->group_leader);
1450
1493
hp = HAlloc(BIF_P, 3 + sz);
1451
res = STORE_NC(&hp, &MSO(BIF_P).externals, rp->group_leader);
1494
res = STORE_NC(&hp, &MSO(BIF_P), rp->group_leader);
1474
1517
case am_binary: {
1476
(void) bld_bin_list(NULL, &sz, MSO(rp).mso);
1519
(void) bld_bin_list(NULL, &sz, &MSO(rp));
1477
1520
hp = HAlloc(BIF_P, sz);
1478
res = bld_bin_list(&hp, NULL, MSO(rp).mso);
1521
res = bld_bin_list(&hp, NULL, &MSO(rp));
1502
1545
case am_backtrace: {
1503
1546
erts_dsprintf_buf_t *dsbufp = erts_create_tmp_dsbuf(0);
1504
1547
erts_stack_dump(ERTS_PRINT_DSBUF, (void *) dsbufp, rp);
1505
res = new_binary(BIF_P, (byte *) dsbufp->str, (int) dsbufp->str_len);
1548
res = new_binary(BIF_P, (byte *) dsbufp->str, dsbufp->str_len);
1506
1549
erts_destroy_tmp_dsbuf(dsbufp);
1507
1550
hp = HAlloc(BIF_P, 3);
1593
1636
if (sel == am_allocator_sizes && arity == 2) {
1594
1637
return erts_allocator_info_term(BIF_P, *tp, 1);
1638
} else if (sel == am_wordsize && arity == 2) {
1639
if (tp[0] == am_internal) {
1640
return make_small(sizeof(Eterm));
1642
if (tp[0] == am_external) {
1643
return make_small(sizeof(UWord));
1595
1646
} else if (sel == am_allocated) {
1596
1647
if (arity == 2) {
1597
1648
Eterm res = THE_NON_VALUE;
1637
1688
return erts_get_cpu_topology_term(BIF_P, *tp);
1638
1689
} else if (ERTS_IS_ATOM_STR("cpu_topology", sel) && arity == 2) {
1639
1690
Eterm res = erts_get_cpu_topology_term(BIF_P, *tp);
1691
if (res == THE_NON_VALUE)
1640
1693
ERTS_BIF_PREP_TRAP1(ret, erts_format_cpu_topology_trap, BIF_P, res);
1642
1695
#if defined(PURIFY) || defined(VALGRIND)
1897
static int is_snif_term(Eterm module_atom) {
1899
Atom *a = atom_tab(atom_val(module_atom));
1900
char *aname = (char *) a->name;
1902
/* if a->name has a '.' then the bif (snif) is bogus i.e a package */
1903
for (i = 0; i < a->len; i++) {
1904
if (aname[i] == '.')
1911
static Eterm build_snif_term(Eterm **hpp, Uint *szp, int ix, Eterm res) {
1913
tup = erts_bld_tuple(hpp, szp, 3, bif_table[ix].module, bif_table[ix].name, make_small(bif_table[ix].arity));
1914
res = erts_bld_cons( hpp, szp, tup, res);
1918
static Eterm build_snifs_term(Eterm **hpp, Uint *szp, Eterm res) {
1920
for (i = 0; i < BIF_SIZE; i++) {
1921
if (is_snif_term(bif_table[i].module)) {
1922
res = build_snif_term(hpp, szp, i, res);
1844
1928
BIF_RETTYPE system_info_1(BIF_ALIST_1)
1889
2002
BIF_RET(db_get_trace_control_word_0(BIF_P));
1890
2003
} else if (ERTS_IS_ATOM_STR("ets_realloc_moves", BIF_ARG_1)) {
1891
2004
BIF_RET((erts_ets_realloc_always_moves) ? am_true : am_false);
2005
} else if (ERTS_IS_ATOM_STR("ets_always_compress", BIF_ARG_1)) {
2006
BIF_RET((erts_ets_always_compress) ? am_true : am_false);
2007
} else if (ERTS_IS_ATOM_STR("snifs", BIF_ARG_1)) {
2012
build_snifs_term(NULL, szp, NIL);
2013
hp = HAlloc(BIF_P, size);
2014
res = build_snifs_term(&hp, NULL, NIL);
1892
2016
} else if (BIF_ARG_1 == am_sequential_tracer) {
1893
2017
val = erts_get_system_seq_tracer();
1894
2018
ASSERT(is_internal_pid(val) || is_internal_port(val) || val==am_false)
1896
2020
res = TUPLE2(hp, am_sequential_tracer, val);
1898
2022
} else if (BIF_ARG_1 == am_garbage_collection){
1899
Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs);
1900
hp = HAlloc(BIF_P, 3+2);
1901
res = TUPLE2(hp, am_fullsweep_after, make_small(val));
1903
res = CONS(hp, res, NIL);
2023
Uint val = (Uint) erts_smp_atomic32_read(&erts_max_gen_gcs);
2025
hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2);
2027
tup = TUPLE2(hp, am_fullsweep_after, make_small(val)); hp += 3;
2028
res = CONS(hp, tup, NIL); hp += 2;
2030
tup = TUPLE2(hp, am_min_heap_size, make_small(H_MIN_SIZE)); hp += 3;
2031
res = CONS(hp, tup, res); hp += 2;
2033
tup = TUPLE2(hp, am_min_bin_vheap_size, make_small(BIN_VH_MIN_SIZE)); hp += 3;
2034
res = CONS(hp, tup, res); hp += 2;
1905
2037
} else if (BIF_ARG_1 == am_fullsweep_after){
1906
Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs);
2038
Uint val = (Uint) erts_smp_atomic32_read(&erts_max_gen_gcs);
1907
2039
hp = HAlloc(BIF_P, 3);
1908
2040
res = TUPLE2(hp, am_fullsweep_after, make_small(val));
2042
} else if (BIF_ARG_1 == am_min_heap_size) {
2043
hp = HAlloc(BIF_P, 3);
2044
res = TUPLE2(hp, am_min_heap_size,make_small(H_MIN_SIZE));
2046
} else if (BIF_ARG_1 == am_min_bin_vheap_size) {
2047
hp = HAlloc(BIF_P, 3);
2048
res = TUPLE2(hp, am_min_bin_vheap_size,make_small(BIN_VH_MIN_SIZE));
1910
2050
} else if (BIF_ARG_1 == am_process_count) {
1911
2051
BIF_RET(make_small(erts_process_count()));
1912
2052
} else if (BIF_ARG_1 == am_process_limit) {
1934
2074
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
1936
2076
ASSERT(dsbufp && dsbufp->str);
1937
res = new_binary(BIF_P, (byte *) dsbufp->str, (int) dsbufp->str_len);
2077
res = new_binary(BIF_P, (byte *) dsbufp->str, dsbufp->str_len);
1938
2078
erts_destroy_info_dsbuf(dsbufp);
1940
2080
} else if (ERTS_IS_ATOM_STR("dist_ctrl", BIF_ARG_1)) {
2017
2157
BIF_RET(erts_alloc_util_allocators((void *) BIF_P));
2019
2159
else if (BIF_ARG_1 == am_elib_malloc) {
2020
#ifdef ELIB_ALLOC_IS_CLIB
2021
struct elib_stat stat;
2023
DECL_AM(max_alloced_size);
2024
DECL_AM(alloced_size);
2026
DECL_AM(no_alloced_blocks);
2027
DECL_AM(no_free_blocks);
2028
DECL_AM(smallest_alloced_block);
2029
DECL_AM(largest_free_block);
2042
/* First find out the heap size needed ... */
2047
build_elib_malloc_term:
2049
atoms[length] = AM_heap_size;
2050
ints[length++] = erts_bld_uint(hpp, szp,
2051
(Uint) stat.mem_total*sizeof(Uint));
2052
atoms[length] = AM_max_alloced_size;
2053
ints[length++] = erts_bld_uint(hpp, szp,
2054
(Uint) stat.mem_max_alloc*sizeof(Uint));
2055
atoms[length] = AM_alloced_size;
2056
ints[length++] = erts_bld_uint(hpp, szp,
2057
(Uint) stat.mem_alloc*sizeof(Uint));
2058
atoms[length] = AM_free_size;
2059
ints[length++] = erts_bld_uint(hpp, szp,
2060
(Uint) stat.mem_free*sizeof(Uint));
2061
atoms[length] = AM_no_alloced_blocks;
2062
ints[length++] = erts_bld_uint(hpp, szp, (Uint) stat.mem_blocks);
2063
atoms[length] = AM_no_free_blocks;
2064
ints[length++] = erts_bld_uint(hpp, szp, (Uint) stat.free_blocks);
2065
atoms[length] = AM_smallest_alloced_block;
2066
ints[length++] = erts_bld_uint(hpp, szp,
2067
(Uint) stat.min_used*sizeof(Uint));
2068
atoms[length] = AM_largest_free_block;
2069
ints[length++] = erts_bld_uint(hpp, szp,
2070
(Uint) stat.max_free*sizeof(Uint));
2074
ASSERT(length <= sizeof(atoms)/sizeof(Eterm));
2075
ASSERT(length <= sizeof(ints)/sizeof(Eterm));
2077
res = erts_bld_2tup_list(hpp, szp, length, atoms, ints);
2080
/* ... and then build the term */
2081
hp = HAlloc(BIF_P, sz);
2088
goto build_elib_malloc_term;
2095
#else /* #ifdef ELIB_ALLOC_IS_CLIB */
2097
#endif /* #ifdef ELIB_ALLOC_IS_CLIB */
2160
/* To be removed in R15 */
2101
2163
else if (BIF_ARG_1 == am_os_version) {
2102
2164
int major, minor, build;
2207
2269
} else if (ERTS_IS_ATOM_STR("cpu_topology", BIF_ARG_1)) {
2208
2270
res = erts_get_cpu_topology_term(BIF_P, am_used);
2209
2271
BIF_TRAP1(erts_format_cpu_topology_trap, BIF_P, res);
2272
} else if (ERTS_IS_ATOM_STR("update_cpu_info", BIF_ARG_1)) {
2273
if (erts_update_cpu_info()) {
2274
ERTS_DECL_AM(changed);
2275
BIF_RET(AM_changed);
2278
ERTS_DECL_AM(unchanged);
2279
BIF_RET(AM_unchanged);
2210
2281
#if defined(__GNUC__) && defined(HAVE_SOLARIS_SPARC_PERFMON)
2211
2282
} else if (ERTS_IS_ATOM_STR("ultrasparc_read_tick1", BIF_ARG_1)) {
2212
2283
register unsigned high asm("%l0");
2279
2350
/* Arguments that are unusual follow ... */
2280
2351
else if (ERTS_IS_ATOM_STR("logical_processors", BIF_ARG_1)) {
2281
int no = erts_get_cpu_configured(erts_cpuinfo);
2353
erts_get_logical_processors(&no, NULL, NULL);
2283
2355
BIF_RET(make_small((Uint) no));
2456
2530
BIF_RET(erts_sched_stat_term(BIF_P, 1));
2457
2531
} else if (ERTS_IS_ATOM_STR("taints", BIF_ARG_1)) {
2458
2532
BIF_RET(erts_nif_taints(BIF_P));
2533
} else if (ERTS_IS_ATOM_STR("reader_groups_map", BIF_ARG_1)) {
2534
BIF_RET(erts_get_reader_groups_map(BIF_P));
2535
} else if (ERTS_IS_ATOM_STR("dist_buf_busy_limit", BIF_ARG_1)) {
2538
(void) erts_bld_uint(NULL, &hsz, erts_dist_buf_busy_limit);
2539
hp = hsz ? HAlloc(BIF_P, hsz) : NULL;
2540
res = erts_bld_uint(&hp, NULL, erts_dist_buf_busy_limit);
2461
2544
BIF_ERROR(BIF_P, BADARG);
2571
2654
hp = HAlloc(BIF_P, 3 + mic.sz);
2573
2656
for (i = 0; i < mic.mi_i; i++) {
2574
item = STORE_NC(&hp, &MSO(BIF_P).externals, mic.mi[i].entity);
2657
item = STORE_NC(&hp, &MSO(BIF_P), mic.mi[i].entity);
2575
2658
res = CONS(hp, item, res);
2592
2675
for (i = 0; i < mic.mi_i; i++) {
2594
item = STORE_NC(&hp, &MSO(BIF_P).externals, mic.mi[i].entity);
2677
item = STORE_NC(&hp, &MSO(BIF_P), mic.mi[i].entity);
2595
2678
t = TUPLE2(hp, am_process, item);
2597
2680
res = CONS(hp, t, res);
2648
2731
erts_doforall_links(prt->nlinks, &one_link_size, &size);
2650
2733
for (bp = prt->bp; bp; bp = bp->next)
2651
size += sizeof(ErlHeapFragment) + (bp->size - 1)*sizeof(Eterm);
2734
size += sizeof(ErlHeapFragment) + (bp->alloc_size - 1)*sizeof(Eterm);
2653
2736
if (prt->linebuf)
2654
2737
size += sizeof(LineBuf) + prt->linebuf->ovsiz;
2964
3047
res = erts_run_queues_len(NULL);
2965
3048
BIF_RET(make_small(res));
2966
3049
} else if (BIF_ARG_1 == am_wall_clock) {
2969
3052
wall_clock_elapsed_time_both(&w1, &w2);
2970
b1 = erts_make_integer(w1,BIF_P);
2971
b2 = erts_make_integer(w2,BIF_P);
3053
b1 = erts_make_integer((Uint) w1,BIF_P);
3054
b2 = erts_make_integer((Uint) w2,BIF_P);
2972
3055
hp = HAlloc(BIF_P,3);
2973
3056
res = TUPLE2(hp, b1, b2);
3312
3402
else if (ERTS_IS_ATOM_STR("fake_scheduler_bindings", tp[1])) {
3313
3403
return erts_fake_scheduler_bindings(BIF_P, tp[2]);
3405
else if (ERTS_IS_ATOM_STR("reader_groups_map", tp[1])) {
3407
if (is_not_small(tp[2]))
3408
BIF_ERROR(BIF_P, BADARG);
3409
groups = signed_val(tp[2]);
3410
if (groups < (Sint) 1 || groups > (Sint) INT_MAX)
3411
BIF_ERROR(BIF_P, BADARG);
3413
BIF_RET(erts_debug_reader_groups_map(BIF_P, (int) groups));
3331
3431
if (ERTS_IS_ATOM_STR("available_internal_state", BIF_ARG_1)
3332
3432
&& (BIF_ARG_2 == am_true || BIF_ARG_2 == am_false)) {
3333
long on = (long) (BIF_ARG_2 == am_true);
3334
long prev_on = erts_smp_atomic_xchg(&available_internal_state, on);
3433
erts_aint_t on = (erts_aint_t) (BIF_ARG_2 == am_true);
3434
erts_aint_t prev_on = erts_smp_atomic_xchg(&available_internal_state, on);
3336
3436
erts_dsprintf_buf_t *dsbufp = erts_create_logger_dsbuf();
3337
3437
erts_dsprintf(dsbufp, "Process %T ", BIF_P->id);
3596
else if (ERTS_IS_ATOM_STR("binary_loop_limit", BIF_ARG_1)) {
3597
/* Used by binary_module_SUITE (stdlib) */
3599
if (is_atom(BIF_ARG_2) && ERTS_IS_ATOM_STR("default", BIF_ARG_2)) {
3600
max_loops = erts_binary_set_loop_limit(-1);
3601
BIF_RET(make_small(max_loops));
3602
} else if (term_to_Uint(BIF_ARG_2, &max_loops) != 0) {
3603
max_loops = erts_binary_set_loop_limit(max_loops);
3604
BIF_RET(make_small(max_loops));
3496
3607
else if (ERTS_IS_ATOM_STR("re_loop_limit", BIF_ARG_1)) {
3497
3608
/* Used by re_SUITE (stdlib) */
3498
3609
Uint max_loops;
3518
3629
else if (ERTS_IS_ATOM_STR("hipe_test_reschedule_suspend", BIF_ARG_1)) {
3519
3630
/* Used by hipe test suites */
3520
long flag = erts_smp_atomic_read(&hipe_test_reschedule_flag);
3631
erts_aint_t flag = erts_smp_atomic_read(&hipe_test_reschedule_flag);
3521
3632
if (!flag && BIF_ARG_2 != am_false) {
3522
3633
erts_smp_atomic_set(&hipe_test_reschedule_flag, 1);
3523
3634
erts_suspend(BIF_P, ERTS_PROC_LOCK_MAIN, NULL);
3593
3704
#ifdef ERTS_ENABLE_LOCK_COUNT
3594
3705
static Eterm lcnt_build_lock_stats_term(Eterm **hpp, Uint *szp, erts_lcnt_lock_stats_t *stats, Eterm res) {
3595
unsigned long tries = 0, colls = 0;
3706
Uint tries = 0, colls = 0;
3596
3707
unsigned long timer_s = 0, timer_ns = 0, timer_n = 0;
3597
3708
unsigned int line = 0;
3605
3716
* [{{file, line}, {tries, colls, {seconds, nanoseconds, n_blocks}}}]
3608
ethr_atomic_read(&stats->tries, (long *)&tries);
3609
ethr_atomic_read(&stats->colls, (long *)&colls);
3719
tries = (Uint) ethr_atomic_read(&stats->tries);
3720
colls = (Uint) ethr_atomic_read(&stats->colls);
3611
3722
line = stats->line;
3612
3723
timer_s = stats->timer.s;
3653
3764
type = am_atom_put(ltype, strlen(ltype));
3655
3765
name = am_atom_put(lock->name, strlen(lock->name));
3657
3767
if (lock->flag & ERTS_LCNT_LT_ALLOC) {
3658
3768
/* use allocator types names as id's for allocator locks */
3659
ltype = ERTS_ALC_A2AD(signed_val(lock->id));
3769
ltype = (char *) ERTS_ALC_A2AD(signed_val(lock->id));
3660
3770
id = am_atom_put(ltype, strlen(ltype));
3661
3771
} else if (lock->flag & ERTS_LCNT_LT_PROCLOCK) {
3662
3772
/* use registered names as id's for process locks if available */
3726
3836
#ifdef ERTS_ENABLE_LOCK_COUNT
3727
3837
Eterm res = NIL;
3728
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3729
erts_smp_block_system(0);
3731
if (BIF_ARG_1 == am_info) {
3841
if (BIF_ARG_1 == am_enabled) {
3842
#ifdef ERTS_ENABLE_LOCK_COUNT
3848
#ifdef ERTS_ENABLE_LOCK_COUNT
3850
else if (BIF_ARG_1 == am_info) {
3732
3851
erts_lcnt_data_t *data;
3733
3852
Uint hsize = 0;
3856
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3857
erts_smp_block_system(0);
3737
3859
erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_SUSPEND);
3739
3860
data = erts_lcnt_get_data();
3741
3862
/* calculate size */
3750
3871
res = lcnt_build_result_term(&hp, NULL, data, res);
3752
3873
erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_SUSPEND);
3875
erts_smp_release_system();
3876
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3755
3879
} else if (BIF_ARG_1 == am_clear) {
3880
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3881
erts_smp_block_system(0);
3756
3883
erts_lcnt_clear_counters();
3885
erts_smp_release_system();
3886
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3759
3889
} else if (is_tuple(BIF_ARG_1)) {
3761
3890
Eterm* tp = tuple_val(BIF_ARG_1);
3762
3892
switch (arityval(tp[0])) {
3764
if (ERTS_IS_ATOM_STR("process_locks", tp[1])) {
3765
if (tp[2] == am_true) {
3766
prev = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK);
3767
if (prev) res = am_true;
3768
else res = am_false;
3770
} else if (tp[2] == am_false) {
3771
prev = erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_PROCLOCK);
3772
if (prev) res = am_true;
3773
else res = am_false;
3894
if (ERTS_IS_ATOM_STR("copy_save", tp[1])) {
3895
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3896
erts_smp_block_system(0);
3897
if (tp[2] == am_true) {
3899
res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_COPYSAVE) ? am_true : am_false;
3901
} else if (tp[2] == am_false) {
3903
res = erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_COPYSAVE) ? am_true : am_false;
3906
erts_smp_release_system();
3907
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3908
BIF_ERROR(BIF_P, BADARG);
3910
erts_smp_release_system();
3911
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3914
} else if (ERTS_IS_ATOM_STR("process_locks", tp[1])) {
3915
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3916
erts_smp_block_system(0);
3917
if (tp[2] == am_true) {
3919
res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK) ? am_true : am_false;
3921
} else if (tp[2] == am_false) {
3923
res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK) ? am_true : am_false;
3926
erts_smp_release_system();
3927
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3928
BIF_ERROR(BIF_P, BADARG);
3930
erts_smp_release_system();
3931
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3784
erts_smp_release_system();
3785
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3787
3942
BIF_ERROR(BIF_P, BADARG);
3788
#ifdef ERTS_ENABLE_LOCK_COUNT
3790
erts_smp_release_system();
3791
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);