Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
執行緒
|
245
printf("The TIDs are equal!\n");
else
printf("The TIDs are unequal!\n");
終止執行緒
執行緒建立的反向操作是執行緒終止。執行緒終止類似於行程終止,只差在執行緒終止
時,行程中的其餘執行緒仍會繼續執行。在某些執行緒模式中,像是每連線執行緒(見
第
7
章〈每連線執行緒〉一節),執行緒會被頻繁地建立和銷毀。
執行緒在幾種情況下可能會終止執行,所有這些情況皆類似於行程的終止:
•
如果一個執行緒從它的起始常式(
start routine
)返回。這類似於
main()
的遇尾返回
(
falling off the end
)。
•
如果一個執行緒調用了
pthread_exit()
函式(隨後會討論到),它就會終止執行。這
類似於叫用
exit()
。
•
如果一個執行緒被另一個執行緒經由
pthread_cancel()
給取消了,它就會終止執行。
這類似於經由
kill()
傳送
SIGKILL
信號。
.
這三個例子只會殺掉當前的執行緒。在下列情況中,一個行程裡的所有執行緒都會被殺
掉,這因而會殺掉整個行程:
•
行程從它的
main()
函式返回。
.
•
行程經由
exit()
終止執行。
•
行程經由
execve()
執行一個新的二元映像(
binary image
)。
信號可以殺掉一個行程或是個別的執行緒,這取決於信號的發送方式。
Pthread
讓信號
的處理變得相當複雜;在多執行緒程式中最好儘量減少信號的使用。第
10
章對信號有
完整的說明。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
優雅的SciPy|Python科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812