您的位置:首页 > 运维架构 > Linux

书评:Linux System Programming

2008-04-15 16:17 323 查看
原文地址:http://books.slashdot.org/article.pl?no_d2=1&sid=08/04/14/1415215

作者:Jon Mitchell

“本文略有节选(一般都是没把握翻的哈,呵呵,书评而已,没时间深究了)”

“下载了电子版看了一下,没有想象中那么深入,也就懒得翻译了。本书评仅供参考。”

"作为刚刚从Perl转到C的Linux开发人员,我一直在寻找一些东西,能让我的K&R级别的经验变为最新的现代方法,并且希望能让我编写更可靠有效的程序。Linux 系统编程 正是我要的。本书的作者Robert Love,之前作为Novell的linux桌面的首席架构师,有多年的内核研究经验。他还是Gnome的开发人员,开发了一些我们熟知的特性,包括Beagle 和 NetworkManager。在本书中,他尝试详细介绍用于一般的系统开发任务的Linux系统调用和C的API。"

作者Robert Love
页数388
出版商O'Reilly Media
评价8/10
评论人Jon Mitchell
ISBN9780596009588
总结深入探讨Linux系统调用和C API
Getting this book out of the box, I had wrongly been expecting a cookbook style that I would get instant gratification from. Although structured around common programming tasks, it doesn't lend itself to just dipping in. The section on time lists a handful of ways that "time" is available to the programmer; jump into the middle of the section and you might miss the most suitable one for the job in hand. The book rewards reading it in larger chunks.

This doesn't mean it is necessary to read it from cover to cover. Logically organized into chapters around "things you want to do", such as file access, memory management and process management it will lead you in with a survey of techniques you might be familiar with, before drilling down with advanced methods.

Knowing advanced methods for performance is great, but not at all costs. One of the most useful and practical lessons this book gives is to encourage you to think about error conditions that may occur during a system call. Early on, in the section on reading files, a detailed example is given on reading from a file. Every possible case of return code from the read call is described together with what it means and how you should handle it — it can be surprising that 7 possible outcomes are listed, with good descriptions of what to do with each of them.

This good practice by example continues throughout the book. Every system call described also lists the errors that may occur. This does show up a slight weakness: many system calls share a common set of errors which are repeated many times in the text. If you are not paying attention it may feel like you are just flipping through man pages. However you are soon halted by the easy introduction of an advanced concept to get your teeth into.

These are done in a nicely graded level for each topic. In "file access" to give an example, you are lead from simple read/write calls, through to what the C library can provide in buffering, to improved performance using mmap. The techniques continue with descriptions of I/O schedulers and how the kernel will order hardware disk access, scatter/gather, and ends up with how it is possible to order block reads/writes yourself bypassing any scheduler.

You are hardly aware of the progression, as the pacing is very well done. New concepts clearly fit into what you have seen so far — current sections signpost the practical use of what is being explained and at what cost, allowing clear consideration of the use of advanced features against any consequences.

For process management discussion starts with fork and exec, before moving onto user ids and groups, covers daemonification and goes onto process scheduling, including real time scheduling. Throughout the book each new call is illustrated with a short code snippet showing the call being used in a practical situation.

Not everything is present and correct. The author immediately states that networking is not covered at all. This is a shame as this subject would benefit from the depth of coverage given to the topics in this book — although no doubt would increase the number of pages considerably. Perhaps scope for a second volume. The length of some sections seems odd — Asynchronous file I/O is whizzed through in a page with no code example, whereas I/O schedulers gets a luxurious 12.

On the other hand there are some unexpected and useful extras, such as a discussion in the appendix of gcc C language extensions and how they might be used to fine tune your code.

本书针对的是比较现代的Linux开发,比如2.6.22的内核,gcc 4.2和glibc 2.5。Many calls have been standardized by POSIX, and where this is so it are noted in the text, so a large portion of the content is useful on other systems. There is even the occasional mention of non-Linux system calls, the use of which is not encouraged, but shown so you know how they function if you come across them in older code.

我推荐这本书给所有打算开发Linux应用程序的人。这本书并不是Unix下C语言的入门书,所以你必须至少懂得K&R级别的知识(也就是标准C语言)。从这一级别到将内核与C库与你的应用程序完美结合的程度,这个过程将是轻松而享受的。

(这本书在china-pub上有影印版,不过还没有出。网上可以找到电子版的,用emule一搜就有了。)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: