当前位置:网站首页>Program counter of JVM runtime data area
Program counter of JVM runtime data area
2022-07-06 17:14:00 【Smart popcorn】
1. Introduce
The program counter is also called PC register , Its full name is Program Counter Register, It's a literal translation , It can be seen as an abstract simulation of real physical registers .

Its main function is to store the address of the next instruction , You can see the following , from 5 Get the corresponding operation instructions at the position of , Put in PC Access in register , Then the execution engine will read , Translate operation instructions into machine instructions , Perform a series of operations such as addition, subtraction, multiplication and division .

Take a look back. , As shown in the figure below .

2. characteristic
It also has the following features .
- The memory occupied is very small , Almost negligible , Very fast .
- Thread private , Each thread has a piece , There will be no thread safety issues
- One thread corresponds to one method , The program counter stores the instruction address of the method running in the thread , But if the local method is executed , The instruction address is underfine, Can't record , Because he only records Java Method
- Branch loop Jump depends on this counter
- stay JVM The only one in the specification will not OOM Region
3.CPU Time slice
Let's talk about CPU The concept of time slice , This is a CPU The time allocated to the execution of each program .
For a single core CPU, There is no concept of parallel , But because CPU Time slice switching , It will give us an illusion of concurrency , That is, multiple programs are running at the same time , Because each program may only run 10ns Time for , Switch back and forth , But in essence, it is a single thread operation .
But for multicore CPU, Multiple programs are assigned to different cores for processing , Different threads perform different jobs at the same time , But for every core , There will be concurrent operations , That is, each thread alternates ,
4. Two questions
PC What's the use of registers storing bytecode instruction addresses ?
In the case of multithreading , Executing a method will involve multiple threads , So record the instruction address , Otherwise, the switched thread will execute from the beginning , That must be wrong .
take 4*100 For the meter relay , The relay man is 100 rice ,200 rice ,300 Wait at a place of meters , Instead of starting from scratch , The position of the relay is equivalent to the instruction address .
PC Why should registers be thread private ?

hypothesis PC Registers are shared by threads , So what problems will it bring , Suppose three threads execute three different methods .
The first thread 1 Execute to order 5 了 , Start switching , Threads 2 Execute the final execution to the instruction 7, Will command 5 Cover the position of , Wait for the thread 123 It's all done , Threads 1 Start again , Is from the instruction 17 It's going to work , But it only executed the instruction originally 5, But there's no record , It will definitely cause confusion in the procedure , So the program counter has to be thread private .
Share daily
If you've ever hated your parents for being incompetent , No vision , It means that you have gone beyond the limitations of your parents , And this is the situation they do everything they want to see .
边栏推荐
- 8086 CPU 内部结构
- The "advertising maniacs" in this group of programmers turned Tiktok advertisements into ar games
- Shell_ 07_ Functions and regular expressions
- yum install xxx报错
- 连接局域网MySql
- Interpretation of Flink source code (III): Interpretation of executiongraph source code
- 吴军三部曲见识(四) 大家智慧
- Ce n'est qu'en apprenant que c est à la hauteur des attentes Top5 s1e8 | s1e9: caractères et chaînes & opérateurs arithmétiques
- Go language uses the thrift protocol to realize the client and service end reports not enough arguments in call to oprot Writemessagebegin error resolution
- Flink 解析(二):反压机制解析
猜你喜欢

Flink源码解读(二):JobGraph源码解读

Compile homework after class

Resume of a microservice architecture teacher with 10 years of work experience

Assembly language segment definition

The daemon thread starts redis and modifies the configuration file

The "advertising maniacs" in this group of programmers turned Tiktok advertisements into ar games

When it comes to Google i/o, this is how ByteDance is applied to flutter

High performance mysql (Third Edition) notes
![[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.](/img/ef/2072aac5f85c7daf39174784dec7ee.jpg)
[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.

字节跳动技术面试官现身说法:我最想pick什么样的候选人
随机推荐
High performance mysql (Third Edition) notes
Activiti目录(四)查询代办/已办、审核
IDEA断点调试技巧,多张动图包教包会。
Yum install XXX reports an error
Idea breakpoint debugging skills, multiple dynamic diagram package teaching package meeting.
Flink parsing (VI): savepoints
姚班智班齐上阵,竞赛高手聚一堂,这是什么神仙编程大赛?
In the command mode in the VI editor, delete the character usage at the current cursor__ Command.
Shell_ 07_ Functions and regular expressions
Alibaba cloud server docker installation mysql5.5
Prototype chain inheritance
TCP's three handshakes and four waves
Compile homework after class
Flink 解析(五):State与State Backend
DS18B20數字溫度計系統設計
Notes on how the network is connected
GCC error: terminate called after throwing an instance of 'std:: regex_ error‘ what(): regex
koa中间件
Train 100 pictures for 1 hour, and the style of the photos changes at will. There is a demo at the end of the article | siggraph 2021
8086 CPU 内部结构