1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
6 #include "malloc.h" /* so that acid generated from proc.c includes malloc data structures */
8 typedef struct Sched Sched;
20 void (*fn)(uintptr*, int32);
26 runtime_sigprof(uint8 *pc __attribute__ ((unused)),
27 uint8 *sp __attribute__ ((unused)),
28 uint8 *lr __attribute__ ((unused)))
32 if(prof.fn == nil || prof.hz == 0)
37 runtime_unlock(&prof);
41 // n = runtime·gentraceback(pc, sp, lr, gp, 0, prof.pcbuf, nelem(prof.pcbuf));
43 prof.fn(prof.pcbuf, n);
44 runtime_unlock(&prof);
48 runtime_setcpuprofilerate(void (*fn)(uintptr*, int32), int32 hz)
50 // Force sane arguments.
58 // Stop profiler on this cpu so that it is safe to lock prof.
59 // if a profiling signal came in while we had prof locked,
61 runtime_resetcpuprofiler(0);
66 runtime_unlock(&prof);
67 // runtime_lock(&runtime_sched);
68 // runtime_sched.profilehz = hz;
69 // runtime_unlock(&runtime_sched);
72 runtime_resetcpuprofiler(hz);