Linux System Programming

Robert Love

Mentioned 5

This book is about writing software that makes the most effective use of the system you're running on -- code that interfaces directly with the kernel and core system libraries, including the shell, text editor, compiler, debugger, core utilities, and system daemons. The majority of both Unix and Linux code is still written at the system level, and Linux System Programming focuses on everything above the kernel, where applications such as Apache, bash, cp, vim, Emacs, gcc, gdb, glibc, ls, mv, and X exist. Written primarily for engineers looking to program (better) at the low level, this book is an ideal teaching tool for any programmer. Even with the trend toward high-level development, either through web software (such as PHP) or managed code (C#), someone still has to write the PHP interpreter and the C# virtual machine. Linux System Programming gives you an understanding of core internals that makes for better code, no matter where it appears in the stack. Debugging high-level code often requires you to understand the system calls and kernel behavior of your operating system, too. Key topics include: An overview of Linux, the kernel, the C library, and the C compiler Reading from and writing to files, along with other basic file I/O operations, including how the Linux kernel implements and manages file I/O Buffer size management, including the Standard I/O library Advanced I/O interfaces, memory mappings, and optimization techniques The family of system calls for basic process management Advanced process management, including real-time processes File and directories-creating, moving, copying, deleting, and managing them Memory management -- interfaces for allocating memory, managing the memory you have, and optimizing your memory access Signals and their role on a Unix system, plus basic and advanced signal interfaces Time, sleeping, and clock management, starting with the basics and continuing through POSIX clocks and high resolution timers With Linux System Programming, you will be able to take an in-depth look at Linux from both a theoretical and an applied perspective as you cover a wide range of programming topics.

More on Amazon.com

Mentioned in questions and answers.

Why create system call is called creat?

Also, why a define for a buffer size is called BUFSIZ and not BUFSIZE?

Are there any other such examples?

Related: (taken from comments)
What did Ken Thompson mean when he said, “I'd spell create with an 'e'.”

From LSP (page 28):

Yes, this function’s name is missing an e. Ken Thompson, the creator of Unix, once joked that the missing letter was his largest regret in the design of Unix.

What is good book for industry level C++ programming? I am not looking for a beginners C++ book that talks about datatypes and control structures. I am looking for a more advanced book. For example, how to build system applications using C++. Any kind of guidance will be very helpful.

If you're looking for books on refining your craft in C++ as a language, you don't get much better than Scott Meyers' Effective C++ and More Effective C++ and Herb Sutter's Exceptional C++, More Exceptional C++ and Exceptional C++ Style. All are packed with invaluable information on bringing your facility with the language from the intermediate to the advanced level.

System-level programming is specific to operating system, so the books diverge based on your platform. Ones I've found very helpful (albeit not C++ specific) are: Windows System Programming, by Johnson M. Hart, Advanced Windows Debugging, by Mario Hewardt and Daniel Pravat, and Linux System Programming, by Robert Love.

All of these books (as well as Peter Alexander's excellent suggestion of Modern C++ Design) are available on O'Reilly's Safari service, which is a pretty cost-effective way of doing a lot of technical reading on the cheap and well worth checking out if you're considering going on a studying binge.

Lakos' Large Scale C++ Software Design is quite a good intermediate-advanced level book about C++ software architecture. It's a little out of date - predating widespread use of templates for example - but it is quite a good book on the subject.

Lakos worked for Mentor Graphics in the 1980s when first generation workstations were the technology du jour. This was an era when the difference in performance and memory footprint between C and C++ apps was regarded as significant. This 'old school' approach discusses efficient C++ systems architecture in some depth, which is a bit of a unique selling point for this book.

These are the best two books I have seen and read

Advanced C++ Programing Styles and Idioms

C++ Common Knowledge

Modern C++ Design by Andrei Alexandrescu is probably the most advanced C++ book out there. It's more about very advanced design patterns rather than building software.

I am learning Operating Systems, their different perspectives like different scheduling algorithms etc. My question is: Can I make my own OS as a final year project? Please suggest some good resources (i.e video training is appreciated) that helps me understand and mainly gives me the ability to DEVELOP at least a SMALL OS.

Linux System Programming: Talking Directly to the Kernel and C Library

this book is for those who are going to start with OS , it tells u the functions and the programming side of OS to keep it interesting . Andrew Tanenbaum's "Operating Systems, Design & Implementation is a harder book to start with .

Is there any book/resource that one can refer to, to be able to write programs at kernel/system level.. I'm looking for a programming book that could serve as a guide to write kernel codes / system level programming etc.. I have Tannenbaum's Design and Implementation. It addresses theoretical aspects well .But a book that teaches programming in such topics would be helpful. I want to be capable of implementing thread library, scheduler et al ..

thanks

I would like to suggest both the books by Robert Love. I've read a bit of the first one and its excellent. The latter was recommended by a friend.

Linux Kernel Development

Linux System Programming: Talking Directly to the Kernel and C Library

I'm new to C programming and Linux at this time, still struggling my way through a whole lot of things. I'm trying understand whether or not there's any official documentation available for all C related structures and methods available for Linux. I'm aware that we have Linux man page for almost everything, however I'm unable to find any structure definition in there.

For eg. I wish to find out more about sockaddr_in and sockaddr structure. When I search google I come with up with a lots of result, including an MSDN documentation page describing this structure. However, I'm looking for something more official (something similar to MSDN) for linux specific C programming (structures, methods etc.). I'm unsure if any such documentation exist, or if I'm misunderstanding something. Please help me find it in case it exists.

Many Thanks in advance !

If you can buy books, here are some books that explain well mostly used structures in C. I would recommend you to start with The Linux Documentation Project so you can start with the basic structures:

The Linux Documentation Project's Programming using C-API

Richars Steven's book Unix Network Programming, Volume 1 The Sockets Networking API

Robert Love's Linux System Programming

Robert Love's Linux Kernel Development, 3rd Edition

Richard Stone's Beginning Linux Programming, 4th Edition

Michael Kerrisk The Linux Programming Interface

Except these books man pages, GNU libc can be read for more information.

I hope that helps. Cheers