Runtime
- Where does thread scheduling happen? Where is the thread state stored?
- It depends.
- First, there are three types of threads: https://softwareengineering.stackexchange.com/questions/107938/threads-kernel-threads-vs-kernel-supported-threads-vs-user-level-threads
- Green thread or user-level threads are run in user-space and implemented inside the language runtime.
- There are M-N model to match green threads with kernel-supported threads
- Trading off multi-core and low-cost context switch
- Kernel-supported thread is pre-emptive, while user thread is corporative
pthread
- an API standard for threading. Not tied to language but tied to OS and the specific
pthread
implementation. - Might or might not involve kernel. In Linux, it is 1-1 and scheduled by kernel.
- https://stackoverflow.com/questions/8639150/is-pthread-library-actually-a-user-thread-solution
- an API standard for threading. Not tied to language but tied to OS and the specific
- Thread models
- Java: JVM manages a thing called "Stack Area"
- https://stackoverflow.com/questions/16264118/how-jvm-stack-heap-and-threads-are-mapped-to-physical-memory-or-operation-syste Am I right that memory for jvm heap is allocated from data segment of the OS process that represents jvm? My assumption is based on that jvm is essentially just a process, and each process has text, data, and stack segments, and malloc() essentially grabs a slab of memory from the data segment. Am I right? – Rustam Issabekov May 9 '13 at 5:11
- https://stackoverflow.com/questions/36898701/how-does-java-jvm-allocate-stack-for-each-thread
- Go: https://stackoverflow.com/questions/34501210/how-goroutine-scheduling-works
- Java: JVM manages a thing called "Stack Area"
- How much stack usage is too much? https://softwareengineering.stackexchange.com/questions/310658/how-much-stack-usage-is-too-much
ulimit -s
!