Tuesday, November 20, 2007

Unix 系統間的歧異

2.1 The Diversity of Unix Systems / Unix 系統間的歧異

Of the programs discussed in this book, the first to be developed was Autoconf. Its development was determined by the history of the Unix operating system.

在本書所討論的工具程式中,第一個被發展出來的工具是 Autoconf ,這個工具的發展與 Unix 作業系統的歷史習習相關。

The first version of Unix was written by Dennis Ritchie and Ken Thompson at Bell Labs in 1969. During the 1970s, Bell Labs was not permitted to sell Unix commercially, but did distribute Unix to universities at relatively low cost. The University of California at Berkeley added their own improvements to the Unix sources; the result was known as the BSD version of Unix.

第一版的 Unix 是在 1969 年由 Dennis Ritchie 與 Ken Thompson 在 Bell Labs 所寫出來的。在 1970 年代,雖然 Bell Labs 的母公司並未將 Unix 商業化販售,但是 Bell Labs 還是有將 Unix 以相對低廉的價格散佈到大學校園內。加州大學柏克萊分校的研究人員將他們的研究成果加入了 Unix 的原始碼中,這個增強後的版本就是後來為眾人所知的 BSD 版 Unix 系統。

In the early 1980s, AT&T signed an agreement permitting them to sell Unix commercially. The first AT&T version of Unix was known as System III.

在 1980 年前期 AT&T 開始商業販售 Unix 作業系統,第一個 AT&T 的 Unix 版本稱為 System III

As the popularity of Unix increased during the 1980s, several other companies modified the Unix sources to create their own variants. Examples include SunOS from Sun Microsystems, Ultrix from Digital Equipment Corporation, and HP-UX from Hewlett Packard.

Unix 在 1980 年代開始普及,許多其他的公司也修改了 Unix 的原始碼並衍伸出自己的作業系統。比如,昇陽電腦的 SunOS ,迪吉多電腦的 Ultrix,以及惠普電腦的 HP-UX 。

Although all of the Unix variants were fundamentally similar, there were various differences between them. They had slightly different sets of header files and slightly different lists of functions in the system libraries, as well as more significant differences in areas such as terminal handling and job control.

雖然所有由 Unix 衍伸出的作業系統在設計上的出發點是相似的,但仍有相當的相異。他們有不同的標頭檔,系統函式庫所提供的函式呼叫也不太一樣,在終端機的控制以及工作的管理上也有可觀的差異。

The emerging POSIX standards helped to eliminate some of these differences. However, in some areas POSIX introduced new features, leading to more variants. Also, different systems adopted the POSIX standard at different times, leading to further disparities.

雖然 POSIX 標準的推出協助消弭了一些歧異,但是,因為 POSIX 也提出了一些新的功能,所以 POSIX 也引出了更多歧異。此外,隨著 POSIX 的改版,新舊版本的標準間也存在著差異,連帶使得不同時期推出的作業系統也因為採用了不同版本的標準而有歧異。

All of these variations caused problems for programs distributed as source code. Even a function as straightforward as memcpy was not available everywhere; the BSD system library provided the similar function bcopy instead, but the order of arguments was reversed.

當以原始碼形式散佈程式時,這些作業系統間的歧異會造成困擾。就算是 memcpy 這類基本的函式也不見得在所有平台上都支援;比如說,在 BSD 的系統函式庫中,提供這項功能的是叫做 bcopy 的函式,不過他的參數順序與 memcpy 是正好顛倒的。

Program authors who wanted their programs to run on a wide variety of Unix variants had to be familiar with the detailed differences between the variants. They also had to worry about the ways in which the variants changed from one version to another, as variants on the one hand converged on the POSIX standard and on the other continued to introduce new and different features.

如果程式設計師想讓程式能在各種由 Unix 衍伸出的系統上運作,他就得對各家衍伸系統間的差異非常了解。另外,作業系統可能為了符合 POSIX 標準或是引入新的功能而改版,進而造成版本間的歧異,這也是程式設計師得面對的問題。

While it was generally possible to use #ifdef to identify particular systems and versions, it became increasingly difficult to know which versions had which features. It became clear that some more organized approach was needed to handle the differences between Unix variants.

一般來講可以用 #ifdef 來辨認出平台所採用的作業系統與版本,但是,,要知道哪個版本有什麼功能則是越來越不容易。因此,程式設計師們漸漸明確的知道,需要一個系統化的方法來處理不同 Unix 衍伸系統間的差異。

No comments: