Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
cppg
toBeTopJavaer
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
toBeTopJavaer
/
docs
/
basics
/
concurrent-coding
/
concurrent.md
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
13 lines (7 loc) · 1.38 KB
master
Breadcrumbs
toBeTopJavaer
/
docs
/
basics
/
concurrent-coding
/
concurrent.md
Copy path
Top
File metadata and controls
Code
Blame
13 lines (7 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
并发
(
Concurrent
),
在操作系统中
,
是指一个时间段中有几个程序都处于已启动运行到运行完毕之间
,
且这几个程序都是在同一个处理机上运行
。
那么
,
操作系统是如何实现这种并发的呢
?
现在我们用到操作系统
,
无论是Windows
、
Linux还是MacOS等其实都是
**
多用户多任务分时操作系统
**。
使用这些操作系统的用户是可以
“
同时
”
干多件事的
。
但是实际上
,
对于单CPU的计算机来说
,
在CPU中
,
同一时间是只能干一件事儿的
。
为了看起来像是
“
同时干多件事
”,
分时操作系统是把CPU的时间划分成长短基本相同的时间区间
,
即
”
时间片
”,
通过操作系统的管理
,
把这些时间片依次轮流地分配给各个用户使用
。
如果某个作业在时间片结束之前
,
整个任务还没有完成
,
那么该作业就被暂停下来
,
放弃CPU
,
等待下一轮循环再继续做
.
此时CPU又分配给另一个作业去使用
。
由于计算机的处理速度很快
,
只要时间片的间隔取得适当
,
那么一个用户作业从用完分配给它的一个时间片到获得下一个CPU时间片
,
中间有所
”
停顿
”,
但用户察觉不出来
,
好像整个系统全由它
”
独占
”
似的
。
所以
,
在单CPU的计算机中
,
我们看起来
“
同时干多件事
”,
其实是通过CPU时间片技术
,
并发完成的
。
You can’t perform that action at this time.