Program Counter Program counter What do you do?
With it, the bytecode interpreter can know which of the next bytecode instructions to execute.
This program counter is required either to remove an instruction or branch, loop, jump, interrupt, or thread recovery.
Where does the program counter exist?
The virtual machine differs from the hardware, and the program counter of the composition principle is stored with CS and IP register to represent the instruction address.
Java has the program counter in memory.
Do I seem to have heard of the program counter in the operating system?
is a bit similar to the program counters in the operating system.
At one point, a processor executes only one thread, and the hotspot uses the native threading model, the OS thread, and the Java thread 1:1 mapping.
In the operating system, when multiple threads switch execution, each thread needs to record where it was interrupted so that it can continue to execute after the thread is resumed.
Referring to the thread control block (TCB) in the operating system, when the thread switches to save the context state, including the instruction counter PC, the thread is interrupted and then switched back to know where to start to continue execution.
In Java, too, when multiple threads are executing, they are also rotated between threads, and when a thread switches back, it needs a program counter to indicate where to start execution for that thread.
So it's good to understand that Java's program counters are ' thread-private ' and each thread has one.
I heard that the program counter can also be empty?
When Java executes the native method, it does not work in Java, but instead calls the methods in the operating system, so the Java program counter is not needed at this time, and is empty.
Since the program counter is empty at this time, when the native method is finished, where should it go?
http://ms.csdn.net/geek/187200
Not to be continued.
Java memory Area--in-depth understanding of Java Virtual Machine Learning notes (i)