diff options
author | Erlang/OTP <[email protected]> | 2013-04-26 12:33:20 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2013-04-26 12:33:20 +0200 |
commit | bfc0387a40097414f5e1af11d01ec621296cc33f (patch) | |
tree | 3bbfb75ecf0bf3c726cf1683650bce5b71aa6940 /erts/emulator/beam/beam_emu.c | |
parent | 32b32fb6dd9e4c501c434789625e270e437960e3 (diff) | |
parent | c599f85af779db465348f0413f9ff245d741d699 (diff) | |
download | otp-bfc0387a40097414f5e1af11d01ec621296cc33f.tar.gz otp-bfc0387a40097414f5e1af11d01ec621296cc33f.tar.bz2 otp-bfc0387a40097414f5e1af11d01ec621296cc33f.zip |
Merge branch 'pan/monitor_long_schedule' into maint-r15
* pan/monitor_long_schedule:
Skip testcase on platforms w/o pipes/usleep
Add documentation for new system_monitor
Add long_schedule detection for ports and testcases
Add erlang:system_monitor(Pid,[{long_schedule,Millis}])
Diffstat (limited to 'erts/emulator/beam/beam_emu.c')
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 6d3b15cd46..c5c57c1125 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -934,6 +934,7 @@ extern int count_instructions; # define NOINLINE #endif + /* * The following functions are called directly by process_main(). * Don't inline them. @@ -1184,6 +1185,9 @@ void process_main(void) Eterm pt_arity; /* Used by do_put_tuple */ + Uint64 start_time = 0; /* Monitor long schedule */ + BeamInstr* start_time_i = NULL; + ERL_BITS_DECLARE_STATEP; /* Has to be last declaration */ @@ -1206,6 +1210,16 @@ void process_main(void) do_schedule: reds_used = REDS_IN(c_p) - FCALLS; do_schedule1: + + if (start_time != 0) { + Sint64 diff = erts_timestamp_millis() - start_time; + if (diff > 0 && (Uint) diff > erts_system_monitor_long_schedule) { + BeamInstr *inptr = find_function_from_pc(start_time_i); + BeamInstr *outptr = find_function_from_pc(c_p->i); + monitor_long_schedule_proc(c_p,inptr,outptr,(Uint) diff); + } + } + PROCESS_MAIN_CHK_LOCKS(c_p); ERTS_SMP_UNREQ_PROC_MAIN_LOCK(c_p); #if HALFWORD_HEAP @@ -1214,11 +1228,18 @@ void process_main(void) ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); c_p = schedule(c_p, reds_used); ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); + start_time = 0; #ifdef DEBUG pid = c_p->id; /* Save for debugging purpouses */ #endif ERTS_SMP_REQ_PROC_MAIN_LOCK(c_p); PROCESS_MAIN_CHK_LOCKS(c_p); + + if (erts_system_monitor_long_schedule != 0) { + start_time = erts_timestamp_millis(); + start_time_i = c_p->i; + } + reg = ERTS_PROC_GET_SCHDATA(c_p)->x_reg_array; freg = ERTS_PROC_GET_SCHDATA(c_p)->f_reg_array; #if !HEAP_ON_C_STACK @@ -6476,6 +6497,7 @@ apply_fun(Process* p, Eterm fun, Eterm args, Eterm* reg) } + static Eterm new_fun(Process* p, Eterm* reg, ErlFunEntry* fe, int num_free) { |