Notes of AUPE, chp 1

1. File IO: buffered & unbuffered (From Section 1.5)

C标准库(stdio.h)提供的文件读写函数,如fread和fwrite是有缓存的。缓存写意味着内容不一定会立即写到磁盘上。其好处在于用户不需要考虑读写缓存,接口已经做了缓存;

系统(unistd.h)所提供的读写接口,如read和write是没有缓存的。这样写的内容会立即反映到磁盘上,适用于不能丢数据的场景。但是接口读写的buffer大小对效率会有影响

2. Process Control (From Section 1.6)

Process:

There are three primary functions for process control: fork, exec, and waitpid.

Control-D, or ^D, is the default end-of-file character.

Threads:

All the threads within a process share the same address space, file descriptors, stacks, and process-related attributes.

As with processes, threads are identified by IDs. Thread IDs, however, are local to a process.

Functions to control threads parallel those used to control processes.

3. Time

If the calendar time is stored as a signed 32-bit integer, in what year will it overflow?

对于calendar time,如果是32位有符号整型的时间值,只能计算到2038年(共68年)的秒数,会在2039年中溢出(具体哪天?)。如果是32位无符号整型,能计算到2109年(共139年)的秒数,在2110年溢出(具体哪天?)。

If the process time is stored as a signed 32-bit integer, and if the system counts 100 ticks per second, after how many days will the value overflow?

对于process time,如果是32位有符号整型的时间值,那么有

signed        100         248 day(0.6 year)

signed        60           414 day(1 year)

signed        50           497 day(1 year)

unsigned   100         497 day(1 year)

unsigned   60           828 day(2 year)

unsigned   50           994 day(2 year)

Advertisements

About chill

不再执意欢喜反倒让人欢喜
This entry was posted in Notes of APUE2. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s