万本电子书0元读

万本电子书0元读

顶部广告

Hands-On System Programming with C++电子书

售       价:¥

1人正在读 | 0人评论 9.8

作       者:Dr. Rian Quinn

出  版  社:Packt Publishing

出版时间:2018-12-26

字       数:66.2万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
A hands-on guide to making system programming with C++ easy Key Features *Write system-level code leveraging C++17 *Learn the internals of the Linux Application Binary Interface (ABI) and apply it to system programming *Explore C++ concurrency to take advantage of server-level constructs Book Description C++ is a general-purpose programming language with a bias toward system programming as it provides ready access to hardware-level resources, efficient compilation, and a versatile approach to higher-level abstractions. This book will help you understand the benefits of system programming with C++17. You will gain a firm understanding of various C, C++, and POSIX standards, as well as their respective system types for both C++ and POSIX. After a brief refresher on C++, Resource Acquisition Is Initialization (RAII), and the new C++ Guideline Support Library (GSL), you will learn to program Linux and Unix systems along with process management. As you progress through the chapters, you will become acquainted with C++'s support for IO. You will then study various memory management methods, including a chapter on allocators and how they benefit system programming. You will also explore how to program file input and output and learn about POSIX sockets. This book will help you get to grips with safely setting up a UDP and TCP server/client. Finally, you will be guided through Unix time interfaces, multithreading, and error handling with C++ exceptions. By the end of this book, you will be comfortable with using C++ to program high-quality systems. What you will learn *Understand the benefits of using C++ for system programming *Program Linux/Unix systems using C++ *Discover the advantages of Resource Acquisition Is Initialization (RAII) *Program both console and file input and output *Uncover the POSIX socket APIs and understand how to program them *Explore advanced system programming topics, such as C++ allocators *Use POSIX and C++ threads to program concurrent systems *Grasp how C++ can be used to create performant system applications Who this book is for If you are a fresh developer with intermediate knowledge of C++ but little or no knowledge of Unix and Linux system programming, this book will help you learn system programming with C++ in a practical way.
目录展开

Title Page

Copyright and Credits

Hands-On System Programming with C++

Dedication

About Packt

Why subscribe?

Packt.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

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

Getting Started with System Programming

Technical requirements

Understanding system calls

The anatomy of a system call

Learning about different types of system calls

Console input/output

Memory allocation

File input/output

Networking

Time

Threading and process creation

System call security risks

SYSRET

Meltdown and Spectre

Benefits of using C++ when system programming

Type safety in C++

Objects of C++

Templates used in C++

Functional programming associated with C++

Error handling mechanism in C++

APIs and C++ containers in C++

Summary

Questions

Further reading

Learning the C, C++17, and POSIX Standards

Technical requirements

Beginning with the C standard language

How the standard is organized

Environment

Language

Libraries

How a C program starts

All about linking

Static libraries

Dynamic libraries

Scope

Pointers and arrays

Libraries

Learning about the C++ standard

How the standard is organized

General conventions and concepts

Language syntax

Libraries

Linking C++ applications

Scope

Pointers versus references

Libraries

Beginning with the POSIX standard

Memory management

Filesystems

Sockets

Threading

Summary

Questions

Further reading

System Types for C and C++

Technical requirements

Exploring C and C++ default types

Character types

Integer types

Floating – point numbers

Boolean

Learning standard integer types

Structure packing

Summary

Questions

Further reading

C++, RAII, and the GSL Refresher

Technical requirements

A brief overview of C++17

Language changes

Initializers in if/switch statements

Additions to compile-time facilities

Namespaces

Structured bindings

Inline variables

Changes in the library

String View

std::any, std::variant, and std::optional

Resource Acquisition Is Initialization (RAII)

The Guideline Support Library (GSL)

Pointer ownership

Pointer arithmetic

Contracts

Utilities

Summary

Questions

Further Reading

Programming Linux/Unix Systems

Technical requirements

The Linux ABI

The System V ABI

The register layout

The stack frame

Function prologs and epilogs

The calling convention

Exception handling and debugging

Virtual memory layout

Executable and Linkable Format (ELF)

ELF sections

ELF segments

The Unix filesystem

Unix processes

The fork() function

The wait() function

Interprocess communication (IPC)

Unix pipes

Unix shared memory

The exec() function

Output redirection

Unix signals

Summary

Questions

Further reading

Learning to Program Console Input/Output

Technical requirements

Learning about stream-based IO

The basics of stream

Advantages and disadvantages of C++ stream-based IO

Advantages of C++ stream-based IO

Disadvantages of C++ stream-based IO

Beginning with user-defined types

Safety and implicit memory management

Common debugging patterns

Performance of C++ streams

Learning about manipulators

Recreating the echo program

Understanding the Serial Echo server example

Summary

Questions

Further reading

A Comprehensive Look at Memory Management

Technical requirements

Learning about the new and delete functions

The basics for writing a program

Aligning memory

nothrow

Placement of new

Overloading

Understanding smart pointers and ownership

The std::unique_ptr{} pointer

The std::shared_ptr pointer

Learning about mapping and permissions

The basics

Permissions

Smart pointers and mmap()

Shared memory

Learning importance of memory fragmentation

External fragmentation

Internal fragmentation

Internal over external fragmentation

External over internal fragmentation

Summary

Questions

Further reading

Learning to Program File Input/Output

Technical requirements

Opening a file

Different ways to open a file

Modes for opening a file

Reading and writing to a file

Reading from a file

Reading by field

Reading bytes

Reading by line

Writing to a file

Writing by field

Writing bytes

Understanding file utilities

Paths

Understanding the logger example

Learning about the tail file example

Comparing C++ versus mmap benchmark

Summary

Questions

Further reading

A Hands-On Approach to Allocators

Technical requirements

Introducing the C++ allocators

Learning about the basic allocator

Understanding the allocator's properties and options

Learning the properties

The value pointer type

Equality

Different allocation types

Copying equal allocators

Moving equal allocators

Exploring some optional properties

Optional functions

Studying an example of stateless, cache–aligned allocator

Compiling and testing

Studying an example of a stateful, memory–pool allocator

Compiling and testing

Summary

Questions

Further reading

Programming POSIX Sockets Using C++

Technical requirements

Beginning with POSIX sockets

Beginning with APIs

The socket() API

The bind() and connect() APIs

The listen() and accept() APIs

The send(), recv(), sendto(), and recvfrom() APIs

Studying an example on the UDP echo server

Server

The client logic

Compiling and testing

Studying an example on the TCP echo server

Server

The client logic

Compiling and testing

Exploring an example on TCP Logger

Server

The client logic

Compiling and testing

Trying out an example for processing packets

The client logic

Compiling and testing

Processing an example of processing JSON

Server

The client logic

Compiling and testing

Summary

Questions

Further reading

Time Interfaces in Unix

Technical requirements

Learning about POSIX time.h APIs

Learning about the types of APIs

The time() API

The ctime() typedef

The localtime() and gmtime() APIs

The asctime() function

The strftime() function

The difftime() function

The mktime() function

The clock() function

Exploring C++ Chrono APIs

The system_clock() API

The time_point API

Duration

The steady_clock function

The high_resolution_clock function

Studying an example on the read system clock

Compiling and testing

Studying an example on high-resolution timer

Compiling and testing

Summary

Questions

Further reading

Learning to Program POSIX and C++ Threads

Technical requirements

Understanding POSIX threads

The basics of POSIX threads

Yielding

Synchronization

Exploring C++ threads

The basics of C++ threads

Yielding

Synchronization

Studying an example on parallel computation

Compiling and testing

Studying an example on benchmarking with threads

Compiling and testing

Studying an example on thread logging

Compiling and testing

Summary

Questions

Further reading

Error – Handling with Exceptions

Technical requirements

Error handling POSIX-style

Learning about set jump exceptions

Understanding exception support in C++

Studying an example on exception benchmark

Compiling and testing

Summary

Questions

Further reading

Assessments

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部