4
* Copyright Ericsson AB 1999-2009. All Rights Reserved.
4
* Copyright Ericsson AB 1999-2010. 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.
589
591
case am_last_calls: return 24;
590
592
case am_total_heap_size: return 25;
591
593
case am_suspending: return 26;
594
case am_min_heap_size: return 27;
595
case am_min_bin_vheap_size: return 28;
593
case am_message_binary: return 27;
597
case am_message_binary: return 29;
595
599
default: return -1;
1362
case am_fullsweep_after: {
1364
(void) erts_bld_uint(NULL, &hsz, MAX_GEN_GCS(rp));
1365
hp = HAlloc(BIF_P, hsz);
1366
res = erts_bld_uint(&hp, NULL, MAX_GEN_GCS(rp));
1370
case am_min_heap_size: {
1372
(void) erts_bld_uint(NULL, &hsz, MIN_HEAP_SIZE(rp));
1373
hp = HAlloc(BIF_P, hsz);
1374
res = erts_bld_uint(&hp, NULL, MIN_HEAP_SIZE(rp));
1378
case am_min_bin_vheap_size: {
1380
(void) erts_bld_uint(NULL, &hsz, MIN_VHEAP_SIZE(rp));
1381
hp = HAlloc(BIF_P, hsz);
1382
res = erts_bld_uint(&hp, NULL, MIN_VHEAP_SIZE(rp));
1358
1386
case am_total_heap_size: {
1359
1387
ErlMessage *mp;
1360
1388
Uint total_heap_size;
1433
1461
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);
1464
hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2 + 3+2 + 3); /* last "3" is for outside tuple */
1466
t = TUPLE2(hp, AM_minor_gcs, make_small(GEN_GCS(rp))); hp += 3;
1467
res = CONS(hp, t, NIL); hp += 2;
1468
t = TUPLE2(hp, am_fullsweep_after, make_small(MAX_GEN_GCS(rp))); hp += 3;
1469
res = CONS(hp, t, res); hp += 2;
1471
t = TUPLE2(hp, am_min_heap_size, make_small(MIN_HEAP_SIZE(rp))); hp += 3;
1472
res = CONS(hp, t, res); hp += 2;
1473
t = TUPLE2(hp, am_min_bin_vheap_size, make_small(MIN_VHEAP_SIZE(rp))); hp += 3;
1474
res = CONS(hp, t, res); hp += 2;
1898
1928
} else if (BIF_ARG_1 == am_garbage_collection){
1899
1929
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);
1931
hp = HAlloc(BIF_P, 3+2 + 3+2 + 3+2);
1933
tup = TUPLE2(hp, am_fullsweep_after, make_small(val)); hp += 3;
1934
res = CONS(hp, tup, NIL); hp += 2;
1936
tup = TUPLE2(hp, am_min_heap_size, make_small(H_MIN_SIZE)); hp += 3;
1937
res = CONS(hp, tup, res); hp += 2;
1939
tup = TUPLE2(hp, am_min_bin_vheap_size, make_small(BIN_VH_MIN_SIZE)); hp += 3;
1940
res = CONS(hp, tup, res); hp += 2;
1905
1943
} else if (BIF_ARG_1 == am_fullsweep_after){
1906
1944
Uint val = (Uint) erts_smp_atomic_read(&erts_max_gen_gcs);
1907
1945
hp = HAlloc(BIF_P, 3);
1908
1946
res = TUPLE2(hp, am_fullsweep_after, make_small(val));
1948
} else if (BIF_ARG_1 == am_min_heap_size) {
1949
hp = HAlloc(BIF_P, 3);
1950
res = TUPLE2(hp, am_min_heap_size,make_small(H_MIN_SIZE));
1952
} else if (BIF_ARG_1 == am_min_bin_vheap_size) {
1953
hp = HAlloc(BIF_P, 3);
1954
res = TUPLE2(hp, am_min_bin_vheap_size,make_small(BIN_VH_MIN_SIZE));
1910
1956
} else if (BIF_ARG_1 == am_process_count) {
1911
1957
BIF_RET(make_small(erts_process_count()));
1912
1958
} else if (BIF_ARG_1 == am_process_limit) {
3653
3706
type = am_atom_put(ltype, strlen(ltype));
3655
3707
name = am_atom_put(lock->name, strlen(lock->name));
3657
3709
if (lock->flag & ERTS_LCNT_LT_ALLOC) {
3658
3710
/* use allocator types names as id's for allocator locks */
3659
ltype = ERTS_ALC_A2AD(signed_val(lock->id));
3711
ltype = (char *) ERTS_ALC_A2AD(signed_val(lock->id));
3660
3712
id = am_atom_put(ltype, strlen(ltype));
3661
3713
} else if (lock->flag & ERTS_LCNT_LT_PROCLOCK) {
3662
3714
/* use registered names as id's for process locks if available */
3726
3778
#ifdef ERTS_ENABLE_LOCK_COUNT
3727
3779
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) {
3783
if (BIF_ARG_1 == am_enabled) {
3784
#ifdef ERTS_ENABLE_LOCK_COUNT
3790
#ifdef ERTS_ENABLE_LOCK_COUNT
3792
else if (BIF_ARG_1 == am_info) {
3732
3793
erts_lcnt_data_t *data;
3733
3794
Uint hsize = 0;
3798
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3799
erts_smp_block_system(0);
3737
3801
erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_SUSPEND);
3739
3802
data = erts_lcnt_get_data();
3741
3804
/* calculate size */
3750
3813
res = lcnt_build_result_term(&hp, NULL, data, res);
3752
3815
erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_SUSPEND);
3817
erts_smp_release_system();
3818
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3755
3821
} else if (BIF_ARG_1 == am_clear) {
3822
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3823
erts_smp_block_system(0);
3756
3825
erts_lcnt_clear_counters();
3827
erts_smp_release_system();
3828
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3759
3831
} else if (is_tuple(BIF_ARG_1)) {
3761
3832
Eterm* tp = tuple_val(BIF_ARG_1);
3762
3834
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;
3836
if (ERTS_IS_ATOM_STR("copy_save", tp[1])) {
3837
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3838
erts_smp_block_system(0);
3839
if (tp[2] == am_true) {
3841
res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_COPYSAVE) ? am_true : am_false;
3843
} else if (tp[2] == am_false) {
3845
res = erts_lcnt_clear_rt_opt(ERTS_LCNT_OPT_COPYSAVE) ? am_true : am_false;
3848
erts_smp_release_system();
3849
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3850
BIF_ERROR(BIF_P, BADARG);
3852
erts_smp_release_system();
3853
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3856
} else if (ERTS_IS_ATOM_STR("process_locks", tp[1])) {
3857
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
3858
erts_smp_block_system(0);
3859
if (tp[2] == am_true) {
3861
res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK) ? am_true : am_false;
3863
} else if (tp[2] == am_false) {
3865
res = erts_lcnt_set_rt_opt(ERTS_LCNT_OPT_PROCLOCK) ? am_true : am_false;
3868
erts_smp_release_system();
3869
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
3870
BIF_ERROR(BIF_P, BADARG);
3872
erts_smp_release_system();
3873
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
3884
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);