aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
AgeCommit message (Collapse)Author
2013-02-20runtime: allow cgo callbacks on non-Go threadsRuss Cox
Fixes #4435. R=golang-dev, iant, alex.brainman, minux.ma, dvyukov CC=golang-dev https://golang.org/cl/7304104
2013-02-20runtime: introduce entersyscallblock()Dmitriy Vyukov
In preparation for the new scheduler. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7386044
2013-02-20runtime: fix deadlock detector false negativeDmitriy Vyukov
Fixes #4819. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7322086
2013-02-20runtime: ensure forward progress of runtime.Gosched() for locked goroutinesDmitriy Vyukov
The removed code leads to the situation when M executes the same locked G again and again. This is https://golang.org/cl/7310096 but with return instead of break in the nested switch. Fixes #4820. R=golang-dev, alex.brainman, rsc CC=golang-dev https://golang.org/cl/7304102
2013-02-15undo CL 7310096 / 59da6744d66dRuss Cox
broke windows build ««« original CL description runtime: ensure forward progress of runtime.Gosched() for locked goroutines The removed code leads to the situation when M executes the same locked G again and again. Fixes #4820. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7310096 »»» TBR=dvyukov CC=golang-dev https://golang.org/cl/7343050
2013-02-15runtime: make return from main wait for active panicRuss Cox
Arguably if this happens the program is buggy anyway, but letting the panic continue looks better than interrupting it. Otherwise things like this are possible, and confusing: $ go run x.go panic: $ echo $? 0 $ Fixes #3934. R=golang-dev, r CC=golang-dev https://golang.org/cl/7322083
2013-02-15runtime: ensure forward progress of runtime.Gosched() for locked goroutinesDmitriy Vyukov
The removed code leads to the situation when M executes the same locked G again and again. Fixes #4820. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7310096
2013-02-14runtime: move stack management related code to stack.cDmitriy Vyukov
No code changes. This is mainly in preparation to scheduler changes, oldstack/newstack are not related to scheduling. R=golang-dev, minux.ma, rsc CC=golang-dev https://golang.org/cl/7311085
2013-02-06runtime/race: switch to explicit race context instead of goroutine id'sDmitriy Vyukov
Removes limit on maximum number of goroutines ever existed. code.google.com/p/goexecutor tests now pass successfully. Also slightly improves performance. Before: $ time ./flate.test -test.short real 0m9.314s After: $ time ./flate.test -test.short real 0m8.958s Fixes #4286. The runtime is built from llvm rev 174312. R=rsc CC=golang-dev https://golang.org/cl/7218044
2013-02-01runtime: cgo-related fixesRuss Cox
* Separate internal and external LockOSThread, for cgo safety. * Show goroutine that made faulting cgo call. * Never start a panic due to a signal caused by a cgo call. Fixes #3774. Fixes #3775. Fixes #3797. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7228081
2013-01-30runtime: local allocation in mprof.gocJan Ziak
Binary data in mprof.goc may prevent the garbage collector from freeing memory blocks. This patch replaces all calls to runtime·mallocgc() with calls to an allocator private to mprof.goc, thus making the private memory invisible to the garbage collector. The addrhash variable is moved outside of the .bss section. R=golang-dev, dvyukov, rsc, minux.ma CC=dave, golang-dev, remyoudompheng https://golang.org/cl/7135063
2013-01-29runtime: dump the full stack of a throwing goroutineDmitriy Vyukov
Useful for debugging of runtime bugs. + Do not print "stack segment boundary" unless GOTRACEBACK>1. + Do not traceback system goroutines unless GOTRACEBACK>1. R=rsc, minux.ma CC=golang-dev https://golang.org/cl/7098050
2013-01-26runtime: avoid defining the same variable in more than one translation unitShenghou Ma
For gccgo runtime and Darwin where -fno-common is the default. R=iant, dave CC=golang-dev https://golang.org/cl/7094061
2013-01-10runtime: faster segmented stacksDmitriy Vyukov
benchmark old ns/op new ns/op delta BenchmarkStackGrowth 665 548 -17.59% BenchmarkStackGrowth-2 333 274 -17.72% BenchmarkStackGrowth-4 224 168 -25.00% BenchmarkStackGrowth-8 124 91 -26.21% BenchmarkStackGrowth-16 82 70 -14.55% BenchmarkStackGrowth-32 73 59 -19.49% R=nigeltao, minux.ma, rsc CC=golang-dev https://golang.org/cl/7026044
2013-01-10runtime: less aggressive per-thread stack segment cachingDmitriy Vyukov
Introduce global stack segment cache and limit per-thread cache size. This greatly reduces StackSys memory on workloads that create lots of threads. benchmark old ns/op new ns/op delta BenchmarkStackGrowth 665 656 -1.35% BenchmarkStackGrowth-2 333 328 -1.50% BenchmarkStackGrowth-4 224 172 -23.21% BenchmarkStackGrowth-8 124 91 -26.13% BenchmarkStackGrowth-16 82 47 -41.94% BenchmarkStackGrowth-32 73 40 -44.79% BenchmarkStackGrowthDeep 97231 94391 -2.92% BenchmarkStackGrowthDeep-2 47230 58562 +23.99% BenchmarkStackGrowthDeep-4 24993 49356 +97.48% BenchmarkStackGrowthDeep-8 15105 30072 +99.09% BenchmarkStackGrowthDeep-16 10005 15623 +56.15% BenchmarkStackGrowthDeep-32 12517 13069 +4.41% TestStackMem#1,MB 310 12 -96.13% TestStackMem#2,MB 296 14 -95.27% TestStackMem#3,MB 479 14 -97.08% TestStackMem#1,sec 3.22 2.26 -29.81% TestStackMem#2,sec 2.43 2.15 -11.52% TestStackMem#3,sec 2.50 2.38 -4.80% R=sougou, no.smile.face, rsc CC=golang-dev, msolomon https://golang.org/cl/7029044
2012-12-19runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to ↵Jingcheng Zhang
avoid confusion with the global "m" and "g". R=golang-dev, minux.ma, rsc CC=bradfitz, golang-dev https://golang.org/cl/6939064
2012-11-27runtime: use reflect·call() to enter the function gc()Jan Ziak
Garbage collection code (to be merged later) is calling functions which have many local variables. This increases the probability that the stack capacity won't be big enough to hold the local variables. So, start gc() on a bigger stack to eliminate a potentially large number of calls to runtime·morestack(). R=rsc, remyoudompheng, dsymonds, minux.ma, iant, iant CC=golang-dev https://golang.org/cl/6846044
2012-10-26runtime: switch to 64-bit goroutine idsDmitriy Vyukov
Fixes #4275. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6759053
2012-10-21runtime: store types of allocated objectsJan Ziak
R=rsc CC=golang-dev https://golang.org/cl/6569057
2012-10-07race: runtime changesDmitriy Vyukov
This is a part of a bigger change that adds data race detection feature: https://golang.org/cl/6456044 R=rsc CC=gobot, golang-dev https://golang.org/cl/6535050
2012-09-24runtime: prepare for 64-bit intsRuss Cox
This CL makes the runtime understand that the type of the len or cap of a map, slice, or string is 'int', not 'int32', and it is also careful to distinguish between function arguments and results of type 'int' vs type 'int32'. In the runtime, the new typedefs 'intgo' and 'uintgo' refer to Go int and uint. The C types int and uint continue to be unavailable (cause intentional compile errors). This CL does not change the meaning of int, but it should make the eventual change of the meaning of int on amd64 a bit smoother. Update #2188. R=iant, r, dave, remyoudompheng CC=golang-dev https://golang.org/cl/6551067
2012-09-18runtime: refactor goroutine blockingDmitriy Vyukov
The change is a preparation for the new scheduler. It introduces runtime.park() function, that will atomically unlock the mutex and park the goroutine. It will allow to remove the racy readyonstop flag that is difficult to implement w/o the global scheduler mutex. R=rsc, remyoudompheng, dave CC=golang-dev https://golang.org/cl/6501077
2012-07-04runtime: move panic/defer/recover-related stuff to a separate fileDmitriy Vyukov
Move panic/defer/recover-related stuff from proc.c/runtime.c to a new file panic.c. No semantic changes. proc.c is 1800+ LOC and is a bit difficult to work with. R=golang-dev, dave, r CC=golang-dev https://golang.org/cl/6343071
2012-07-03runtime: refactor proc.cDmitriy Vyukov
1. Rename 'g' and 'm' local vars to 'gp' and 'mp' (convention already used in some functions) 'g' and 'm' are global vars that mean current goroutine and current machine, when they are shadowed by local vars, it's confusing, no ability to debug log both, etc. 2. White-space shuffling. No semantic changes. In preparation to bigger changes. R=golang-dev, dave CC=golang-dev https://golang.org/cl/6355061
2012-05-30runtime: update field types in preparation for GC changesJan Ziak
R=rsc, remyoudompheng, minux.ma, ality CC=golang-dev https://golang.org/cl/6242061
2012-05-30runtime: handle windows exceptions, even in cgo programsAlex Brainman
Fixes #3543. R=golang-dev, kardianos, rsc CC=golang-dev, hectorchu, vcc.163 https://golang.org/cl/6245063
2012-05-15runtime: refactor helpgc functionality in preparation for parallel GCDmitriy Vyukov
Parallel GC needs to know in advance how many helper threads will be there. Hopefully it's the last patch before I can tackle parallel sweep phase. The benchmarks are unaffected. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6200064
2012-04-02runtime: fix a commentMaxim Pimenov
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5975043
2012-03-27runtime: work around false negative in deadlock detectionRuss Cox
Not a complete fix for issue 3342, but fixes the trivial case. There may still be a race in the instants before and after a scavenger-induced garbage collection. Intended to be "obviously safe": a call to runtime·gosched before main.main is no different than a call to runtime.Gosched at the beginning of main.main, and it is (or had better be) safe to call runtime.Gosched at any point during main. Update #3342. R=iant CC=golang-dev https://golang.org/cl/5919052
2012-03-27undo CL 5844051 / 5d0322034aa8Mikio Hara
Breaks closure test when GOMAXPROCS=2 or more. ««« original CL description runtime: restore deadlock detection in the simplest case. Fixes #3342. R=iant, r, dave, rsc CC=golang-dev, remy https://golang.org/cl/5844051 »»» R=rsc CC=golang-dev https://golang.org/cl/5924045
2012-03-26runtime: restore deadlock detection in the simplest case.Rémy Oudompheng
Fixes #3342. R=iant, r, dave, rsc CC=golang-dev, remy https://golang.org/cl/5844051
2012-03-15runtime: do not handle signals before configuring handlerRuss Cox
There was a small window during program initialization where a signal could come in before the handling mechanisms were set up to handle it. Delay the signal-handler installation until we're ready for the signals. Fixes #3314. R=golang-dev, dsymonds, mikioh.mikioh CC=golang-dev https://golang.org/cl/5833049
2012-03-155l, 6l, 8l: fix stack split logic for stacks near default segment sizeRuss Cox
Fixes #3310. R=golang-dev, r CC=golang-dev https://golang.org/cl/5823051
2012-03-05runtime: wait for main goroutine before setting GOMAXPROCS.Rémy Oudompheng
Fixes #3182. R=golang-dev, dvyukov, rsc CC=golang-dev, remy https://golang.org/cl/5732057
2012-03-01runtime: run init on main threadRuss Cox
Fixes #3125. R=golang-dev, r, minux.ma CC=golang-dev https://golang.org/cl/5714049
2012-02-28runtime/pprof: support OS X CPU profilingRuss Cox
Work around profiling kernel bug with signal masks. Still broken on 64-bit Snow Leopard kernel, but I think we can ignore that one and let people upgrade to Lion. Add new trivial tools addr2line and objdump to take the place of the GNU tools of the same name, since those are not installed on OS X. Adapt pprof to invoke 'go tool addr2line' and 'go tool objdump' if the system tools do not exist. Clean up disassembly of base register on amd64. Fixes #2008. R=golang-dev, bradfitz, mikioh.mikioh, r, iant CC=golang-dev https://golang.org/cl/5697066
2012-02-22runtime: goroutine profile, stack dumpsRuss Cox
R=golang-dev, r, r CC=golang-dev https://golang.org/cl/5687076
2012-02-19runtime: fix another memory leakRuss Cox
morebuf holds a pc/sp from the last stack split or reflect.call or panic/recover. If the pc is a closure, the reference will keep it from being collected. moreargp holds a pointer to the arguments from the last stack split or reflect.call or panic/recover. Normally it is a stack pointer and thus not of interest, but in the case of reflect.call it is an allocated argument list and holds up the arguments to the call. R=golang-dev, r CC=golang-dev https://golang.org/cl/5674109
2012-02-19runtime: fix tiny memory leakRuss Cox
The m->cret word holds the C return value when returning across a stack split boundary. It was not being cleared after use, which means that the return value (if a C function) or else the value of AX/R0 at the time of the last stack unsplit was being kept alive longer than necessary. Clear it. I think the effect here should be very small, but worth fixing anyway. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5677092
2012-02-17runtime: rename Cgocalls and Goroutines to NumCgoCall and NumGoroutine, ↵David Symonds
respectively. Update some other docs too. Update #2955. R=rsc CC=golang-dev https://golang.org/cl/5676060
2012-02-16runtime: release unused memory to the OS.Sébastien Paolacci
Periodically browse MHeap's freelists for long unused spans and release them if any. Current hardcoded settings: - GC is forced if none occured over the last 2 minutes. - spans are handed back after 5 minutes of uselessness. SysUnused (for Unix) is a wrapper on madvise MADV_DONTNEED on Linux and MADV_FREE on BSDs. R=rsc, dvyukov, remyoudompheng CC=golang-dev https://golang.org/cl/5451057
2012-02-14runtime: on 386, fix FP control word on all threads, not just initial threadRuss Cox
It is possible that Linux and Windows copy the FP control word from the parent thread when creating a new thread. Empirically, Darwin does not. Reset the FP control world in all cases. Enable the floating-point strconv test. Fixes #2917 (again). R=golang-dev, r, iant CC=golang-dev https://golang.org/cl/5660047
2012-02-08runtime, pprof: add profiling of thread creationRuss Cox
Same idea as heap profile: how did each thread get created? Low memory (256 bytes per OS thread), high reward for programs that suddenly have many threads running. Fixes #1477. R=golang-dev, r, dvyukov CC=golang-dev https://golang.org/cl/5639059
2012-02-02runtime: add runtime.cputicks() and seed fastrand with itDamian Gryski
This patch adds a function to get the current cpu ticks. This is deemed to be 'sufficiently random' to use to seed fastrand to mitigate the algorithmic complexity attacks on the hash table implementation. On AMD64 we use the RDTSC instruction. For 386, this instruction, while valid, is not recognized by 8a so I've inserted the opcode by hand. For ARM, this routine is currently stubbed to return a constant 0 value. Future work: update 8a to recognize RDTSC. Fixes #2630. R=rsc CC=golang-dev https://golang.org/cl/5606048
2011-12-16runtime: make more build-friendlyRuss Cox
Collapse the arch,os-specific directories into the main directory by renaming xxx/foo.c to foo_xxx.c, and so on. There are no substantial edits here, except to the Makefile. The assumption is that the Go tool will #define GOOS_darwin and GOARCH_amd64 and will make any file named something like signals_darwin.h available as signals_GOOS.h during the build. This replaces what used to be done with -I$(GOOS). There is still work to be done to make runtime build with standard tools, but this is a big step. After this we will have to write a script to generate all the generated files so they can be checked in (instead of generated during the build). R=r, iant, r, lucio.dere CC=golang-dev https://golang.org/cl/5490053
2011-11-14syscall: take over env implementationRuss Cox
The environment is needed by package time, which we want not to depend on os (so that os can use time.Time), so push down into syscall. Delete syscall.Sleep, now unnecessary. The package os environment API is preserved; it is only the implementation that is moving to syscall. Delete os.Envs, which was undocumented, uninitialized on Windows and Plan 9, and not maintained by Setenv and Clearenv. Code can call os.Environ instead. R=golang-dev, r CC=golang-dev https://golang.org/cl/5370091
2011-11-11runtime: remove declarations of nonexistent functionsIan Lance Taylor
R=rsc, r CC=golang-dev https://golang.org/cl/5369089
2011-11-09runtime: add timer support, use for package timeRuss Cox
This looks like it is just moving some code from time to runtime (and translating it to C), but the runtime can do a better job managing the goroutines, and it needs this functionality for its own maintenance (for example, for the garbage collector to hand back unused memory to the OS on a time delay). Might as well have just one copy of the timer logic, and runtime can't depend on time, so vice versa. It also unifies Sleep, NewTicker, and NewTimer behind one mechanism, so that there are no claims that one is more efficient than another. (For example, today people recommend using time.After instead of time.Sleep to avoid blocking an OS thread.) Fixes #1644. Fixes #1731. Fixes #2190. R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov CC=golang-dev https://golang.org/cl/5334051
2011-11-08runtime: add comments for various functions in proc.cIan Lance Taylor
R=rsc CC=golang-dev https://golang.org/cl/5357047
2011-11-08runtime: add windows callback testsAlex Brainman
Just a copy of cgo callback tests from misc/cgo/test. R=rsc CC=golang-dev, hectorchu https://golang.org/cl/5331062