售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Why subscribe?
Contributors
About the author
About the reviewers
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Essential Features
Preprocessor directives
Macros
Defining a macro
Variadic macros
Advantages and disadvantages of macros
Conditional compilation
Variable pointers
Syntax
Arithmetic on variable pointers
Generic pointers
Size of a pointer
Dangling pointers
Some details about functions
Anatomy of a function
Importance in design
Stack management
Pass-by-value versus pass-by-reference
Function pointers
Structures
Why structures?
Why user-defined types?
What do structures do?
Memory layout
Nested structures
Structure pointers
Summary
From Source to Binary
Compilation pipeline
Building a C project
Header files versus source files
Example source files
Building the example
Step 1 – Preprocessing
Step 2 – Compilation
Step 3 – Assembly
Step 4 – Linking
Supporting new architectures
Step details
Preprocessor
Compiler
Abstract syntax tree
Assembler
Linker
How does the linker work?
Linker can be fooled!
C++ name mangling
Summary
Object Files
Application binary interface (ABI)
Object file formats
Relocatable object files
Executable Object Files
Static libraries
Dynamic libraries
Manual loading of shared libraries
Summary
Process Memory Structure
Process memory layout
Discovering memory structure
Probing static memory layout
BSS segment
Data segment
Text segment
Probing dynamic memory layout
Memory mappings
Stack segment
Heap segment
Summary
Stack and Heap
Stack
Probing the Stack
Points on using the Stack memory
Heap
Heap memory allocation and deallocation
Heap memory principles
Memory management in constrained environments
Memory-constrained environments
Packed structures
Compression
External data storage
Performant environments
Caching
Allocation and deallocation cost
Memory pools
Summary
OOP and Encapsulation
Object-oriented thinking
Mental concepts
Mind maps and object models
Objects are not in code
Object attributes
Domain
Relations among objects
Object-oriented operations
Objects have behaviors
C is not object-oriented, but why?
Encapsulation
Attribute encapsulation
Behavior encapsulation
Information hiding
Summary
Composition and Aggregation
Relations between classes
Object versus class
Composition
Aggregation
Summary
Inheritance and Polymorphism
Inheritance
The nature of inheritance
The first approach for having inheritance in C
The second approach to inheritance in C
Comparison of two approaches
Polymorphism
What is polymorphism?
Why do we need polymorphism?
How to have polymorphic behavior in C
Summary
Abstraction and OOP in C++
Abstraction
Object-oriented constructs in C++
Encapsulation
Inheritance
Polymorphism
Abstract classes
Summary
Unix – History and Architecture
Unix history
Multics OS and Unix
BCPL and B
The way to C
Unix architecture
Philosophy
Unix onion
Shell interface to user applications
Kernel interface to shell ring
Kernel
Hardware
Summary
System Calls and Kernels
System calls
System calls under the microscope
Bypassing standard C – calling a system call directly
Inside the syscall function
Add a system call to Linux
Kernel development
Writing a Hello World system call for Linux
Building the kernel
Unix kernels
Monolithic kernels versus microkernels
Linux
Kernel modules
Adding a kernel module to Linux
Summary
The Most Recent C
C11
Finding a supported version of C standard
Removal of the gets function
Changes to fopen function
Bounds-checking functions
No-return functions
Type generic macros
Unicode
Anonymous structures and anonymous unions
Multithreading
A bit about C18
Summary
Concurrency
Introducing concurrency
Parallelism
Concurrency
Task scheduler unit
Processes and threads
Happens-before constraint
When to use concurrency
Shared states
Summary
Synchronization
Concurrency issues
Intrinsic concurrency issues
Post-synchronization issues
Synchronization techniques
Busy-waits and spin locks
Sleep/notify mechanism
Semaphores and mutexes
Multiple processor units
Spin locks
Condition variables
Concurrency in POSIX
Kernels supporting concurrency
Multi-processing
Multithreading
Summary
Thread Execution
Threads
POSIX threads
Spawning POSIX threads
Example of race condition
Example of data race
Summary
Thread Synchronization
POSIX concurrency control
POSIX mutexes
POSIX condition variables
POSIX barriers
POSIX semaphores
POSIX threads and memory
Stack memory
Heap memory
Memory visibility
Summary
Process Execution
Process execution APIs
Process creation
Process execution
Comparing process creation and process execution
Process execution steps
Shared states
Sharing techniques
POSIX shared memory
Data race example using shared memory
File system
Multithreading versus multi-processing
Multithreading
Single-host multi-processing
Distributed multi-processing
Summary
Process Synchronization
Single-host concurrency control
Named POSIX semaphores
Named mutexes
The first example
The second example
Step 1 – Global declarations
Step 2 – Cancellation flag's shared memory
Step 3 – Named mutex's shared memory
Step 4 – Setting the cancellation flag
Step 5 – The main function
Named condition variables
Step 1 – Class of shared memory
Step 2 – Class of shared 32-bit integer counter
Step 3 – Class of shared mutex
Step 4 – Class of shared condition variable
Step 5 – The main logic
Distributed concurrency control
Summary
Single-Host IPC and Sockets
IPC techniques
Communication protocols
Protocol characteristics
Content type
Length of messages
Sequentiality
Single-host communication
File descriptors
POSIX signals
POSIX pipes
POSIX message queues
Unix domain sockets
Introduction to socket programming
Computer networks
Physical layer
Link layer
Network layer
Transport layer
Application layer
Internet protocol suite
What is socket programming?
What is a socket?
POSIX socket library
Sockets have their own descriptors!
Summary
Socket Programming
Socket programming review
Calculator project
Source hierarchy
Build the project
Run the project
Application protocol
Serialization/deserialization library
Server-side serializer/deserializer functions
Client-side serializer/deserializer functions
Calculator service
Unix domain sockets
UDS stream server
UDS stream client
UDS datagram server
UDS datagram client
Network sockets
TCP server
TCP client
UDP server
The UDP client
Summary
Integration with Other Languages
Why integration is possible?
Obtaining the necessary materials
Stack library
Integration with C++
Name mangling in C++
C++ code
Integration with Java
Writing the Java part
Writing the native part
Integration with Python
Integration with Go
Summary
Unit Testing and Debugging
Software testing
Unit testing
Test doubles
Component testing
Testing libraries for C
CMocka
Google Test
Debugging
Bug categories
Debuggers
Memory checkers
Thread debuggers
Performance profilers
Summary
Build Systems
What is a build system?
Make
CMake – not a build system!
Ninja
Bazel
Comparing build systems
Summary
Epilogue
Other Books You May Enjoy
Leave a review - let other readers know what you think
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜