1. Trang chủ
  2. » Công Nghệ Thông Tin

beginning linux programming,3rd ed 2004

891 1.3K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Beginning Linux Programming

    • Cover

  • About Neil Matthew

  • About Rick Stones

  • Contents

  • Foreword by Alan Cox

  • Introduction

  • Chapter 1: Getting Started

    • An Introduction to UNIX, Linux, and GNU

      • What Is UNIX?

        • A Brief History of UNIX

        • UNIX Philosophy

      • What Is Linux?

      • The GNU Project and the Free Software Foundation

      • Linux Distributions

    • Programming Linux

      • Linux Programs

      • The C Compiler

        • Try It Out-Our First Linux C Program

      • Development System Roadmap

      • Applications

      • Header Files

      • Library Files

      • Static Libraries

        • Try It Out-Static Libraries

      • Shared Libraries

    • Getting Help

      • Try It Out-Manual Pages and info

    • Summary

  • Chapter 2: Shell Programming

    • Why Program with a Shell?

      • A Bit of Philosophy

      • What Is a Shell?

      • Pipes and Redirection

        • Redirecting Output

        • Redirecting Input

        • Pipes

    • The Shell as a Programming Language

      • Interactive Programs

      • Creating a Script

      • Making a Script Executable

    • Shell Syntax

      • Variables

        • Quoting

          • Try It Out-Variables

      • Environment Variables

      • Parameter Variables

        • Try It Out-Parameter and Environment Variables

      • Conditions

        • The test, or [, Command

      • Control Structures

        • if

          • Try It Out-Using the if Command

        • elif

          • Try It Out-Doing Further Checks with an elif

        • A Problem with Variables

        • for

          • Try It Out-for Loop with Fixed Strings

          • Try It Out-for Loop with Wildcard Expansion

        • while

          • Try It Out-Here We Go Again, Again

        • until

        • case

          • Try It Out-Case I: User Input

          • Try It Out-Case II: Putting Patterns Together

          • Try It Out-Case IIl: Executing Multiple Statements

        • Lists

          • Try It Out-AND Lists

          • Try It Out-OR Lists

        • Statement Blocks

      • Functions

        • Try It Out-A Simple Function

        • Try It Out-Returning a Value

      • Commands

        • break

        • The : Command

        • continue

        • The . Command

          • Try It Out-The Dot Command

        • echo

        • eval

        • exec

        • exit n

        • export

          • Try It Out-Exporting Variables

        • expr

        • printf

        • return

        • set

        • shift

        • trap

          • Try It Out-Trapping Signals

        • unset

        • Two More Useful Commands and Regular Expressions

          • Try It Out-find with Tests

          • Try It Out-Basic grep Usage

          • Try It Out-Regular Expressions

      • Command Execution

        • Arithmetic Expansion

        • Parameter Expansion

          • Try It Out-Parameter Processing

      • Here Documents

        • Try It Out-Using Here Documents

        • Try It Out-Another Use for a Here Document

      • Debugging Scripts

    • Going Graphical-The Dialog Utility

      • Try It Out-Using the dialog Utility

      • Try It Out

    • Putting It All Together

      • Requirements

      • Design

        • Try It Out-A CD Application

      • Notes on the Application

    • Summary

  • Chapter 3: Working with Files

    • Linux File Structure

      • Directories

      • Files and Devices

        • /dev/console

        • /dev/tty

        • /dev/null

    • System Calls and Device Drivers

    • Library Functions

    • Low-Level File Access

      • write

      • read

      • open

      • Initial Permissions

        • umask

        • close

        • ioctl

          • Try It Out-A File Copy Program

      • Other System Calls for Managing Files

        • lseek

        • fstat, stat, and lstat

        • dup and dup2

    • The Standard I/O Library

      • fopen

      • fread

      • fwrite

      • fclose

      • fflush

      • fseek

      • fgetc, getc, and getchar

      • fputc, putc, and putchar

      • fgets and gets

    • Formatted Input and Output

      • printf, fprintf, and sprintf

      • scanf, fscanf, and sscanf

      • Other Stream Functions

        • Try It Out-Another File Copy Program

      • Stream Errors

      • Streams and File Descriptors

    • File and Directory Maintenance

      • chmod

      • chown

      • unlink, link, and symlink

      • mkdir and rmdir

      • chdir and getcwd

    • Scanning Directories

      • opendir

      • readdir

      • telldir

      • seekdir

      • closedir

        • Try It Out-A Directory-Scanning Program

    • Errors

      • strerror

      • perror

    • The /proc File System

    • Advanced Topics: fcntl and mmap

      • fcntl

      • mmap

        • Try It Out-Using mmap

    • Summary

  • Chapter 4: The Linux Environment

    • Program Arguments

      • Try It Out-Program Arguments

      • getopt

        • Try It Out-getopt

      • getopt_long

    • Environment Variables

      • Try It Out-getenv and putenv

      • Use of Environment Variables

      • The environ Variable

        • Try It Out-environ

    • Time and Date

      • Try It Out-time

      • Try It Out-gmtime

      • Try It Out-ctime

      • Try It Out-strftime and strptime

    • Temporary Files

      • Try It Out-tmpnam and tmpfile

    • User Information

      • Try It Out-User Information

    • Host Information

      • Try It Out-Host Information

    • Logging

      • Try It Out-syslog

      • Try It Out-logmask

    • Resources and Limits

      • Try It Out-Resource Limits

    • Summary

  • Chapter 5: Terminals

    • Reading from and Writing to the Terminal

      • Try It Out-Menu Routines in C

      • Canonical versus Non-Canonical Modes

      • Handling Redirected Output

        • Try It Out-Checking for Output Redirection

    • Talking to the Terminal

      • Try It Out-Using /dev/tty

    • The Terminal Driver and the General Terminal Interface

      • Overview

      • Hardware Model

    • The termios Structure

      • Input Modes

      • Output Modes

      • Control Modes

      • Local Modes

      • Special Control Characters

        • Characters

        • The TIME and MIN Values

        • Accessing Terminal Modes from the Shell

        • Setting Terminal Modes from the Command Prompt

      • Terminal Speed

      • Additional Functions

        • Try It Out-A Password Program with termios

        • Try It Out-Reading Each Character

    • Terminal Output

      • Terminal Type

      • Identify Your Terminal Type

      • Using terminfo Capabilities

        • Try It Out-Total Terminal Control

    • Detecting Keystrokes

      • Try It Out-Your Very Own kbhit

    • Virtual Consoles

    • Pseudo Terminals

    • Summary

  • Chapter 6: Managing Text-Based Screens with curses

    • Compiling with curses

    • Concepts

      • Try It Out-A Simple curses Program

    • Initialization and Termination

    • Output to the Screen

    • Reading from the Screen

    • Clearing the Screen

    • Moving the Cursor

    • Character Attributes

      • Try It Out-Moving, Inserting, and Attributes

    • The Keyboard

      • Keyboard Modes

      • Keyboard Input

        • Try It Out-Keyboard Modes and Input

    • Windows

      • The WINDOW Structure

      • Generalized Functions

      • Moving and Updating a Window

        • Try It Out-Multiple Windows

      • Optimizing Screen Refreshes

    • Subwindows

      • Try It Out-Subwindows

    • The Keypad

      • Try It Out-Using the Keypad

    • Color

      • Try It Out--Colors

      • Redefining Colors

    • Pads

      • Try It Out-Using a Pad

    • The CD Collection Application

      • Try It Out-A New CD Collection Application

      • Try It Out-Looking at main

      • Try It Out-The Menu

      • Try It Out-Database File Manipulation

      • Try It Out-Querying the CD Database

    • Summary

  • Chapter 7: Data Management

    • Managing Memory

      • Simple Memory Allocation

        • Try It Out-Simple Memory Allocation

      • Allocating Lots of Memory

        • Try It Out-Asking for All Physical Memory

        • Try It Out-Available Memory

      • Abusing Memory

        • Try It Out-Abuse Your Memory

      • The Null Pointer

        • Try It Out-Accessing a Null Pointer

      • Freeing Memory

        • Try It Out-Freeing Memory

      • Other Memory Allocation Functions

    • File Locking

      • Creating Lock Files

        • Try It Out-Creating a Lock File

        • Try It Out-Cooperative Lock Files

      • Locking Regions

        • The F_GETLK Command

        • The F_SETLK Command

        • The F_SETLKW Command

      • Use of read and write with Locking

        • Try It Out-Locking a File with fcntl

        • Try It Out-Testing Locks on a File

      • Competing Locks

        • Try It Out-Competing Locks

      • Other Lock Commands

      • Deadlocks

    • Databases

      • The dbm Database

        • Introduction to dbm

        • Getting dbm

        • Troubleshooting and Reinstalling dbm

      • The dbm Routines

      • dbm Access Functions

        • dbm_open

        • dbm_store

        • dbm_fetch

        • dbm_close

          • Try It Out-A Simple dbm Database

      • Additional dbm Functions

        • dbm_delete

        • dbm_error

        • dbm_clearerr

        • dbm_firstkey and dbm_nextkey

          • Try It Out-Retrieving and Deleting

    • The CD Application

      • Updating the Design

      • The CD Database Application Using dbm

        • Try It Out-cd_data.h

        • Try It Out-app_ui.c

        • Try It Out-cd_access.c

    • Summary

  • Chapter 8: MySQL

    • Installation

      • Precompiled Packages

      • Post-Install Configuration

      • Post-Installation Troubleshooting

    • MySQL Administration

      • Commands

        • myisamchk

        • mysql

        • mysqladmin

        • mysqlbug

        • mysqlimport

        • mysqlshow

      • Creating Users and Giving Them Permissions

        • grant

        • revoke

      • Passwords

      • Creating a Database

        • Data Types

        • Boolean

        • Character

        • Number

        • Temporal

      • Creating a Table

      • Graphical Tools

    • Accessing MySQL Data from C

      • Connection Routines

      • Error Handling

      • Executing SQL Statements

        • SQL Statements That Return No Data

        • Discovering What You Inserted

          • Try It Out

          • Try It Out

        • Statements That Return Data

        • Processing Returned Data

      • Miscellaneous Functions

    • The CD Database Application

      • Creating the Tables

      • Adding Some Data

        • Try It Out

      • Accessing the Application Data from C

        • Interface Definition

        • Test Application Interface

        • Implementing the Interface

    • Summary

  • Chapter 9: Development Tools

    • Problems of Multiple Source Files

    • The make Command and Makefiles

      • The Syntax of Makefiles

      • Options and Parameters to make

        • Dependencies

        • Rules

          • Try It Out-A Simple Makefile

      • Comments in a Makefile

      • Macros in a Makefile

        • Try It Out-A Makefile with Macros

      • Multiple Targets

        • Try It Out-Multiple Targets

      • Built-in Rules

      • Suffix and Pattern Rules

      • Managing Libraries with make

        • Try It Out-Managing a Library

      • Advanced Topic: Makefiles and Subdirectories

      • GNU make and gcc

        • Try It Out-gcc -MM

    • Source Code Control

      • RCS

        • The rcs Command

        • The ci Command

        • The co Command

        • The rlog Command

        • The rcsdiff Command

        • Identifying Revisions

          • Try It Out-GNU make with RCS

        • The ident Command

          • Try It Out-ident

        • SCCS

        • Comparing RCS and SCCS

        • CVS

          • Using CVS Locally

          • Accessing CVS over a Network

        • gCVS

        • BitKeeper

    • Writing a Manual Page

    • Distributing Software

      • The patch Program

      • Other Distribution Utilities

    • RPM Packages

      • Working with RPM Package Files

      • Installing RPM Packages

      • Building RPM Packages

        • Gathering the Software

        • Creating an RPM Spec File

        • Building an RPM Package with rpmbuild

    • Other Package Formats

    • Development Environments

      • xwpe

      • C-Forge

      • KDevelop

      • Other Environments

    • Summary

  • Chapter 10: Debugging

    • Types of Errors

    • General Debugging Techniques

      • A Program with Bugs

      • Code Inspection

      • Instrumentation

        • Try It Out-Debug Information

      • Debugging without Recompiling

      • Controlled Execution

    • Debugging with gdb

      • Starting gdb

      • Running a Program

      • Stack Trace

      • Examining Variables

      • Listing the Program

      • Setting Breakpoints

      • Patching with the Debugger

      • Learning More about gdb

    • More Debugging Tools

      • Lint: Removing the Fluff from Your Programs

      • Function Call Tools

        • ctags

        • cxref

        • cflow

      • Execution Profiling with prof/gprof

    • Assertions

      • Try It Out-assert

    • Memory Debugging

      • ElectricFence

        • Try It Out-ElectricFence

      • valgrind

        • Try It Out-valgrind

    • Summary

  • Chapter 11: Processes and Signals

    • What Is a Process?

    • Process Structure

      • The Process Table

      • Viewing Processes

      • System Processes

      • Process Scheduling

    • Starting New Processes

      • Try It Out-system

      • Replacing a Process Image

        • Try It Out-execlp

      • Duplicating a Process Image

        • Try It Out-fork

      • Waiting for a Process

        • Try It Out-wait

      • Zombie Processes

        • Try It Out-Zombies

      • Input and Output Redirection

        • Try It Out-Redirection

      • Threads

    • Signals

      • Try It Out-Signal Handling

      • Sending Signals

        • Try It Out-An Alarm Clock

      • A Robust Signals Interface

        • Try It Out-sigaction

      • Signal Sets

        • sigaction Flags

        • Common Signal Reference

    • Summary

  • Chapter 12: POSIX Threads

    • What Is a Thread?

      • Advantages and Drawbacks of Threads

    • A First Threads Program

      • Try It Out-A Simple Threaded Program

    • Simultaneous Execution

      • Try It Out-Simultaneous Execution of Two Threads

    • Synchronization

      • Synchronization with Semaphores

        • Try It Out-A Thread Semaphore

      • Synchronization with Mutexes

        • Try It Out-A Thread Mutex

    • Thread Attributes

      • Try It Out-Setting the Detached State Attribute

      • Thread Attributes-Scheduling

        • Try It Out-Scheduling

    • Canceling a Thread

      • Try It Out-Canceling a Thread

    • Threads in Abundance

      • Try It Out-Many Threads

    • Summary

  • Chapter 13: Inter-Process Communication: Pipes

    • What Is a Pipe?

    • Process Pipes

      • popen

      • pclose

        • Try It Out-Reading Output from an External Program

    • Sending Output to popen

      • Try It Out-Sending Output to an External Program

      • Passing More Data

        • Try It Out-Reading Larger Amounts of Data from a Pipe

      • How popen Is Implemented

        • Try It Out-popen Starts a Shell

    • The Pipe Call

      • Try It Out-The pipe Function

      • Try It Out-Pipes across a fork

    • Parent and Child Processes

      • Try It Out-Pipes and exec

      • Reading Closed Pipes

      • Pipes Used as Standard Input and Output

        • File Descriptor Manipulation by close and dup

          • Try It Out-Pipes and dup

    • Named Pipes: FIFOs

      • Try It Out-Creating a Named Pipe

      • Accessing a FIFO

        • Try It Out-Accessing a FIFO File

      • Opening a FIFO with open

        • Try It Out-Opening FIFO Files

      • O_RDONLY and O_WRONLY with No O_NONBLOCK

      • O_RDONLY with O_NONBLOCK and O_WRONLY

      • Reading and Writing FIFOs

        • Try It Out-Inter-Process Communication with FIFOs

      • Advanced Topic: Client/Server Using FIFOs

        • Try It Out-An Example Client/Server Application

    • The CD Database Application

      • Aims

      • Implementation

        • Try It Out-The Header File, cliserv.h

      • Client Interface Functions

        • Try It Out-The Client's Interpreter

      • Searching the Database

        • Try It Out-Searching

      • The Server Interface

        • Try It Out-server.c

      • The Pipe

        • Try It Out-Pipes Implementation Header

        • Server-Side Functions

          • Try It Out-Server Functions

          • Try It Out-Plumbing the Pipes

        • Client-Side Functions

          • Try It Out-Client Functions

          • Try It Out-Getting Server Results

        • Application Summary

    • Summary

  • Chapter 14: Semaphores, Shared Memory, and Message Queues

    • Semaphores

      • Semaphore Definition

      • A Theoretical Example

      • Linux Semaphore Facilities

        • semget

        • semop

        • semctl

      • Using Semaphores

        • Try It Out-Semaphores

    • Shared Memory

      • shmget

      • shmat

      • shmdt

      • shmctl

        • Try It Out-Shared Memory

    • Message Queues

      • msgget

      • msgsnd

      • msgrcv

      • msgctl

        • Try It Out-Message Queues

    • The CD Database Application

      • Try It Out-Revising the Server Functions

      • Try It Out-Revising the Client Functions

    • IPC Status Commands

      • Semaphores

      • Shared Memory

      • Message Queues

    • Summary

  • Chapter 15: Sockets

    • What Is a Socket?

    • Socket Connections

      • Try It Out-A Simple Local Client

      • Try It Out-A Simple Local Server

      • Socket Attributes

        • Socket Domains

        • Socket Types

        • Socket Protocols

      • Creating a Socket

      • Socket Addresses

      • Naming a Socket

      • Creating a Socket Queue

      • Accepting Connections

      • Requesting Connections

      • Closing a Socket

      • Socket Communications

        • Try It Out-Network Client

        • Try It Out-Network Server

      • Host and Network Byte Ordering

    • Network Information

      • Try It Out-Network Information

      • Try It Out-Connecting to a Standard Service

      • The Internet Daemon (inetd)

      • Socket Options

    • Multiple Clients

      • Try It Out-A Server for Multiple Clients

      • select

        • Try It Out-select

      • Multiple Clients

        • Try It Out-An Improved Multiple Client/Server

    • Datagrams

    • Summary

  • Chapter 16: Programming GNOME Using GTK+

    • Introducing X

      • X Server

      • X Client

      • X Protocol

      • Xlib

      • Toolkits

      • Window Managers

      • Other Ways to GUI-Platform-Independent Windowing APIs

    • Introducing GTK+

      • GLib Type System

      • GTK+ Object System

      • Introducing GNOME

      • Installing the GNOME/GTK+ Development Libraries

        • Try it Out-A Plain GtkWindow

    • Events, Signals, and Callbacks

      • Try It Out-A Callback Function

    • Packing Box Widgets

      • Try It Out-Widget Container Layout

    • GTK+ Widgets

      • GtkWindow

      • GtkEntry

        • Try It Out-Username and Password Entry

      • GtkSpinButton

        • Try It Out-GtkSpinButton

      • GtkButton

        • GtkToggleButton

        • GtkCheckButton

        • GtkRadioButton

          • Try It Out-GtkCheckButton, GtkToggleButton, and GtkRadioButton

      • GtkTreeView

        • Try It Out-GtkTreeView

    • GNOME Widgets

      • Try It Out-A GNOME Window

    • GNOME Menus

      • Try It Out-GNOME Menus

      • Try It Out-Menus with GNOME Macros

    • Dialogs

      • GtkDialog

      • Modal Dialog Box

      • Nonmodal Dialogs

      • GtkMessageDialog

    • CD Database Application

      • Try It Out-cdapp_gnome.h

      • Try It Out-interface.c

      • Try It Out-callbacks.c

      • Try It Out-main.c

    • Summary

  • Chapter 17: Programming KDE Using Qt

    • Introducing KDE and Qt

    • Installing Qt

      • Try It Out-QMainWindow

    • Signals and Slots

      • Try It Out-Signals and Slots

    • Try It Out-Using QBoxLayout Classes

    • Qt Widgets

    • QLineEdit

      • Try It Out-QLineEdit

    • Qt Buttons

      • QButton-The Button Base Class

      • QPushButton

      • QCheckBox

      • QRadioButton

        • Try It Out-QButtons

      • QComboBox

      • Try It Out-QComboBox

        • QListView

        • Try It Out-QListView

    • Dialogs

      • QDialog

        • Modal Dialogs

        • Nonmodal Dialogs

        • Semimodal Dialog

      • QMessageBox

      • QInputDialog

      • Using qmake to Simplify Writing Makefiles

    • Menus and Toolbars

      • Try It Out-A KDE Application with Menus and Toolbars

    • CD Database Application Using KDE/Qt

      • Try It Out-MainWindow

      • Try It Out-AddCdDialog

      • Try It Out-LogonDialog

      • Try It Out-main.cpp

    • Summary

  • Chapter 18: Device Drivers

    • Writing Device Drivers

    • Devices

      • Device Classes

      • User and Kernel Space

        • What Goes Where?

        • Building Modules

        • Data Types

          • Try It Out-A Kernel Module

    • Character Devices

      • File Operations

    • A Sample Driver: schar

      • The MSG Macro

      • Registering the Device

      • Module Usage Count

      • Open and Release

      • Reading the Device

      • The current Task

      • Wait Queues

      • Writing to the Device

      • Nonblocking Reads

      • Seeking

      • ioctl

      • Checking User Rights

      • poll

        • Try It Out-Reading and Writing to schar

        • Try It Out-ioctl

      • Module Parameters

        • Try It Out-modinfo

      • proc File System Interface

      • How schar Behaves

    • Time and Jiffies

      • Small Delays

      • Timers

        • Try It Out-The Timer Implementation in schar

      • Giving Up the Processor

      • Task Queues

      • The Predefined Task Queues

    • Memory Management

      • Virtual Memory Areas

      • Address Space

      • Types of Memory Locations

      • Getting Memory in Device Drivers

        • kmalloc

        • vmalloc

      • Transferring Data between User and Kernel Space

      • Moving More Data

      • Simple Memory Mapping

      • I/O Memory

      • Assignment of Devices in Iomap

      • I/O Memory mmap

        • Try It Out-The Iomap Module

    • I/O Ports

      • Interrupt Handling

        • Allocating an Interrupt

        • Getting an Appropriate IRQ

      • The IRQ Handler

      • Bottom Halves

      • Re-entrancy

      • Disabling Single Interrupts

      • Atomicity

      • Protecting Critical Sections

        • Basic Spin Locks

        • Reader and Writer Locks

        • Automated Locking

    • Block Devices

      • radimo-A Simple RAM Disk Module

        • Size Issues

        • Registering a Block Device

      • Media Change

      • ioctl for Block Devices

      • The request Function

      • The Buffer Cache

        • Try It Out-radimo

      • Going Further

      • Debugging

      • Oops Tracing

    • Debugging Modules

      • The Magic Key

      • Kernel Debugger-kdb

      • Remote Debugging

      • General Notes on Debugging

    • Portability

      • Data Types

      • Endianess

      • Alignment

    • Anatomy of the Kernel Source

    • Summary

  • Chapter 19: Standards for Linux

    • The C Programming Language

      • A Brief History Lesson

      • The GNU Compiler Collection

    • gcc Options

      • Compiler Options for Standards Tracking

      • Define Options for Standard Tracking

      • Compiler Options for Warnings

    • Interfaces and the LSB

      • LSB Standard Libraries

        • A Brief History Lesson

        • Using the LSB Standard for Libraries

      • LSB Users and Groups

      • LSB System Initialization

    • The Filesystem Hierarchy Standard

    • /bin

      • /boot

      • /dev

      • /etc

      • /home

      • /lib

      • /mnt

      • /opt

      • /root

      • /sbin

      • /tmp

      • /usr

      • /var

    • Further Reading about Standards

    • Summary

  • Index

  • Team DDU

Nội dung

[...]... useful areas This book is one of them, a compendium of those programmers’ notes and scribbles, deciphered (try reading a programmer’s handwriting), edited, and brought together coherently as a book This updated third edition of Beginning Linux Programming has been reviewed and updated to reflect today’s Linux developments, including a chapter on programming with the Qt toolkit, the basis of the KDE GUI... Introduction Welcome to Beginning Linux Programming, 3rd Edition, an easy-to-use guide to developing programs for the Linux and other UNIX-style operating systems In this book we aim to give you an introduction to a wide variety of topics important to you as a developer using Linux The word beginning in the title refers more to the content than to your skill level We’ve structured the book to help you... this book Where direct comparisons exist between Linux programming and C/C++ programming, these are indicated in the text Watch out if you’re totally new to Linux This isn’t a book on installing or configuring Linux If you want to learn more about administering a Linux system, you may wish to look at some complementary books such as Running Linux, 4th Edition, by Matt Welsh, Matthias Kalle Dalheimer,... administration The Linux documentation project released a whole pile of documents covering everything from installing Linux and Windows on the same machine to wiring your coffee machine to Linux Seriously Take a look at The Linux Documentation Project on http://www.tldp.org The book world, on the other hand, seems to consist mostly of either learned tomes, detailed and very complete works that you don’t have... from a Pipe How popen Is Implemented Try It Out—popen Starts a Shell The Pipe Call Try It Out—The pipe Function Try It Out—Pipes across a fork Parent and Child Processes Try It Out—Pipes and exec Reading Closed Pipes Pipes Used as Standard Input and Output File Descriptor Manipulation by close and dup Try It Out—Pipes and dup Named Pipes: FIFOs Try It Out—Creating a Named Pipe Accessing a FIFO Try It... structured the book to help you learn more about what Linux has to offer, however much experience you have already Linux programming is a large field and we aim to cover enough about a wide range of topics to give you a good beginning in each subject Who’s This Book For? If you’re a programmer who wishes to get up to speed with the facilities that Linux (or UNIX) offers software developers, to maximize... your application’s use of the Linux system, you’ve picked up the right book Clear explanations and a tried and tested step-bystep approach will help you progress rapidly and pick up all the key techniques We assume you have some experience in C and/or C++ programming, perhaps in Windows or some other system, but we try to keep the book’s examples simple so that you don’t need to be an expert C coder to... to thank the folks at Wiley who helped us get this third edition off the ground, especially Debra Williams Cauley for acquiring and administering all the talented individuals who worked on this book; James H Russell for ensuring consistency, proper organization, presentation, and other duties; and Arthur Griffith and Tobias DiPasquale for their outstanding technical edits Thanks also to Andrew Froggatt... Try It Out—Getting Server Results Application Summary Summary Chapter 14: Semaphores, Shared Memory, and Message Queues Semaphores Semaphore Definition A Theoretical Example Linux Semaphore Facilities semget semop semctl Using Semaphores Try It Out—Semaphores Shared Memory shmget shmat shmdt shmctl Try It Out—Shared Memory Message Queues msgget msgsnd msgrcv msgctl Try It Out—Message Queues The CD Database... Threads Program Try It Out—A Simple Threaded Program Simultaneous Execution Try It Out—Simultaneous Execution of Two Threads Synchronization Synchronization with Semaphores Try It Out—A Thread Semaphore Synchronization with Mutexes Try It Out—A Thread Mutex Thread Attributes Try It Out—Setting the Detached State Attribute Thread Attributes—Scheduling Try It Out—Scheduling Canceling a Thread Try It Out—Canceling . alt="" Beginning Linux Programming Third Edition Neil Matthew Richard Stones a544977 FM.qxd 12/1/03 8:55 AM Page i a544977 FM.qxd 12/1/03 8:55 AM Page iv Beginning Linux Programming Third Edition Neil. FM.qxd 12/1/03 8:55 AM Page i Beginning Linux ® Programming Third Edition Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 Copyright © 2004 by Wiley Publishing,. Publishing, Inc. All rights reserved. Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means,

Ngày đăng: 24/04/2014, 09:06