现在的位置: 首页 > 综合 > 正文

不过英语四级,收到公司面试题!

2013年10月11日 ⁄ 综合 ⁄ 共 8652字 ⁄ 字号 评论关闭

不过英语四级,收到公司面试题如下,请把它翻译成中文:

所给文件
/*=========================================================================================================================*/
 璇锋彁渚涗竴绯诲垪鍙互璇佹槑鑷繁鑳藉姏鐨勬潗鏂欙細
 
1. 姣曚笟璁烘枃
2. 鎴愮哗鍗?/SPAN>
3. 鑷繁璁や负姣旇緝婊℃剰鐨勪綔鍝?/SPAN>
 
--------------------------------------------------------------------------------
B    璇峰皢浠ヤ笅鎶€鏈祫鏂欒瘧鎴愪腑鏂?BR>
    The philosophy of the UNIX system is to provide operating system primitives that enable users to write small, modular programs that can be used as building blocks to build more complex programs. One such primitive visible to shell users is the capability to redirect I/O. Processes conventionally have access to three files: they read from their standard input file, write to their standard output file, and write error messages to their standard error file. Processes executing at a terminal typically use the terminal for these three files, but each may be "redirected" independently.
 
    The second building block primitive is the pipe, a mechanism that allows a stream of data to be passwd between reader and writer processes. Processes can redirect their standard output to a pipe to be read by other processes that have redirected their standar input to come from the pipe. The data that the first processes write into the pipe is the input for the second processes. The second processes could also redirect their output, and so on, depending on programming need.
    When using the smaller programs as building blocks for a larger, more complex program, the programmer uses the pipe primitive and redirection of I/O to integrate the piece parts. Indeed , the system tacitly encourages such programming style so that new programs can work with  existing programs.

--------------------------------------------------------------------------------

    The kernel performs various primitive operations on behalf of user processes to support the user interface described above. Among the services provided by the kernel are:

飪?SPAN class=718400706-26042004>A)  Controlling the execution of processes by allowing their creation, termination or suspension, and communication.
飪?SPAN class=718400706-26042004>B) Scheduling processes fairly for execution on the CPU. Processes share the CPU. Processes share the CPU in a time-shared manner: the CPU executes a process, the kernel suspends it when its time quantum elapses, and the kernel schedules another process to execute. The kernel later reschedules the suspended process.
飪?SPAN class=718400706-26042004>C) Allocating main memory for an executing process. The kernel allows processes to share portions of their address space under certain conditions, but protects the private address space of a process from outside tampering. If the system runs low on free memory, the kernel frees memory by writing a process temporily to secondary memory, called a swap device. If the kernel writes entire processes to a swap device, the implementation of the UNIX system is called a swapping system; if it writes pages of memory to a swap device, it is called a paging system.
飪?SPAN class=718400706-26042004>D) Allocating secondary memory for efficient storage and retrieval of user data. This service constitutes the file system. The kernel allocates secondary storage for user files, reclaims unused storage, structures the file system in a well understood manner, and protects user files from illegal access.
飪?SPAN class=718400706-26042004>E) Allowing processes controlled access to peripheral devices such as terminals, tape drives, disk drives, and network devices.

    The kernel provides its services transparently. For example, it recognizes that a given file is a regular file or a device, but hides the distinction from user processes. Similarly, it format data in a file for internal storage, but hides the internal format from user processes, returning a unformatted byte stream. Finally, it offers necessary services so that user processes can support the services they must provide, while omitting services that can be implemented at the user level. For example, the kernel supports the services that the shell needs to act as a command interpreter: It allows the shell to read terminal input, to spawn processes dynamically, to synchronize process execution, to create pipes, and to redirect I/O. Users can construct private versions of the shell to tailor their environments to their specifications without affecting other users. These programs use the same kernel services as the standard shell.

--------------------------------------------------------------------------------
=======================================================
瀛熺綏姣?BR>骞垮窞铻嶉€氱郴缁熼泦鎴愭湁闄愬叕鍙?BR>骞垮窞甯傚ぉ娌冲尯涓北澶ч亾涓?30鍙锋眹璇氬ぇ鍘﹀悗搴? 510630
Mobile: 13570075312
Telno: 020-22646421 020-22221188-6421

/*=====================================================================================================================*/

出现了乱码,但是,还勉强可以看,我按照上面的文章进行翻译。

第一次翻译:

 UNIX系统的哲学思想是:提供给用户一个简单的操作系统。该系统让用户可以用短小的,模块化的程序作为“积木”编写更大型的程序。是重定位I/O的能力使用户使用UNIX Shell时,看起来简单了。程序通常会访问三种文件:从“标准输入文件”中读取,写入“标准输出文件”,和向“标准错误文件”写入错误信息。程序在终端机里执行,典型,这三种文件在terminal里面执行。每一种可能被独立地“重定位”
 第二种简单的“积木”是“管道”,管道是一种允许数据流能在读/写进程中传送的机制进程能重定位他们的标准输出到一个管道上来,并允许其他能重定位的进程读,标准输入来自于管道,第一个进程的数据写入管道,作为另一个进程的输入,这个进程也可以重定位自己的输出,等等,这个依赖于程序的需要当你使用一个小程序作为另一个更大的,更复杂程序的积木,程序员使用简单的管道和重定位I/O去集成各块程序。当然,系统默认鼓励编程出这样风格的新程序,以便方便与已存在的编程一起工作。内核执行各种原始操作,代表用户处理所支持上面描述的用户接口。
 用内核提供的服务中有:藉由进程创建,进程终止,进程挂起,进程通信这些操作,控制进程的执行调度进程公平地在cpu上执行,共享cpu, 进程共享时间cpu是以时间的方式进行共享的。cpu执行一个进程,当他的时间分配时间到时,内核就会挂起他,内核就会调度另一个进程,内核稍后就会重新挂起的进程的制定时间表。给一个执行的程序分配内存:内核允许进程共享他们的地址空间在特定条件下。但是,保护一个进程私有地址空间免遭篡改。假如系统在运行在低于自由空间。内核会释放内存-------------------,,,调用交换设备,假如内核读写整个进程内存用一个交换措施,而unix系统的实现叫“交换系统”,假如用a swap devic读写内存的页,则,它叫做分页系统。 分配二次内存为高效的储藏和取回用户的数据,这个服务便组成文件系统。内核为用户文件分配第二存储空间。归还未使用的空间,以一个易于理解的方式理解结构文件系统,保护用户文件免于非法的访问允许进程空间访问外围的设备比如终端机,磁带设备,磁盘设备,和网络设备。
 内核提供透明地提供服务。举例如:它识别出一个给定的文件是一般文件或者是一个设备,但它向一个用户进程隐藏了区别。类似的,它格式化数据成为一个文件为内部存储。但向用户程序隐藏了内部的格式。返回一个未格式化的字节流。最后,它提供了必要的服务,以至用户程序能够支持这个它们必须提供的服务。当遗漏能够被实现的服务时,在用户层。(注意),举例来说,内核支持一个服务:Shell需要扮演命令解释器的角色,它允许Shell读取终端输入。产生动态程序。去保持进程之间的同步。创建管道,重定位I/O,用户能构造一个私有的Shell去适应他们的环境和他们的需求规格(Specification),却没有影响到另一个用户。这些程序用相同内核的服务最为标准的Shell

/*=======================================================================================================================*/
正式译文:

 UNIX系统的哲学思想是:提供给用户一个基本系统。该系统可以让人们用短小精悍的,模块化的程序码堆切成“积木”,再用这些积木撰写更复杂的代码。像“重定向输入/输出”,也是一种积木,它使UNIX系统的Shell(译注1)的使用感觉简单了。   
 进程(译注2:)通常会访问三种文件:“标准输入文件”,“标准输出文件” 和“标准错误文件”,前者是用来读取,次者是提供写入,最后是用于写入程序的错误信息(译注3)。程序在终端机器中运行。通常,终端机都可以作为这三种“文件”之一(译注4),每一种“文件”都可以独立的,不受影响地进行“重定位”。 
 第二种积木是“管道”,管道也简单。它是一种能使数据流在“读进程”和“写进程”中传送的机制。进程能“重定向”本身的标准输出到一个管道上来,并允许其它进程读取管道,前提是,这些进程的标准输入必须是上面的管道。第一个进程的数据写入管道中,该管道便可以作为第二个进程的输入。当然,第二个进程也可重定向它们的输出,这些依赖于程序的需要。当你要使用一个短小程序作为另一个大且复杂程序的积木时,用户可以选择简单的“管道”和“重定向输入输出”做为程序块。当然,系统许默并鼓励用这样的风格撰写程序,以便与已存在的程序一起工作。为了支持上面所描述的用户程序接口,系统内核会执行各种原始操作来实现之。
 内核提供的服务之中有:
 进程创建,终止,挂起和通信,这些操作控制着进程的执行。进程被调度之后由处理器公平地执行。进程以时间轮片方式共享处理器时间。处理器执行一个程序,当它的时间片用尽后,内核就会将它挂起。接着调度另一个进程。之后内核就会重新调度被挂起的进程。
 内核给一个执行着的进程分配内存。除了保护进程私有地址空间免遭篡改外,在特定的条件下,内核也允许进程共享它们的地址空间。假如内存可用空间不足时,内核将进程信息临时调出外存中,外存称为交换区(swap device)。UNIX系统有二种内存管理方式,其一内存将整个进程信息写入交换区中,称为“分段系统”。其二内存将页面写入交换区中,称为“分页系统”(译注5)。 
 为让用户高效快捷地在外存中读取数据,内核提供一个服务,该服务称为“文件系统”。文件系统使用一种非常容易理解的方式进行管理,即用户数据以文件形式存储在外存,用户数据受文件系统保护免于非法访问,未使用的外存便由文件系统回收。
 允许进程访问外设,比如终端机,磁带,磁盘和网络设备。内核透明地提供这些服务。举例子来说,内核能识别喂给他的文件是一般文件(file),还是一个设备(device)(译注6),但用户程序对此毫不知情。类似的,内核将数据格式化成为文件形式存储在外存里,但用户程序对文件的内部格式毫不知情。用户使用的是原始未格式化的字节流(译注7)。
 最后,内核提供了一些必要的服务。就算在用户层中遗漏任何未被实现的服务时,用户程序也能够实现它。举例子来说,内核支持一个称为Shell的服务。该服务扮演命令解释器的角色,它从终端读取输入程序,动态地运行输入的进程行,可保持进程之间的同步。Shell还可创建管道,重定向输入输出,支持用户根据自己的环境和需求构造私有的Shell,却不会影响到另一个用户。所有Shell都使用相同的内核服务。

 

翻译说明:
1:由于翻译追求的是“信,雅,达”,本人在意译的时候,同一个单词在不同的语境中会不一样如user有时候翻译为:使用者,程序员,用户,人们等。下同:
2:在一片简短的文章里,如何显示自己的能力呢?我在翻译过程中,我一般尽量解释文章概念,或者通过代码来解释文章中的概念。

 

user:     使用者,程序员,用户。
primitive: 原始的,简单的,基本!
programs:  程序,程序码,进程!
secondary memory: 第二存储器,翻译为“外存”

 
译注1:“Shell”这些选择不译,Shell的意思为操作系统的终端解释器,如UNIX/Linux的Termial解释器,DOS/Window9X的Command,WindowsNT  4/5的Explorer等
译注2:Process:一般翻译成进程,但有时候也可翻译为程序,这需要根据语境的需求。
译注3:“标准输入文件”,“标准输出文件” 和“标准错误文件”相当于C++语言的cout, cin, cerr,请代码A3
译注4:一般终端机都会有“键盘”,“显示器”,前者是“标准输入文件”,后者是“标准输出文件”,这里的文件为泛指,在UNIX里,任何  设备都可以当成一个文件,包括键盘,显示器,鼠标,磁盘等。
译注5:操作系统可分页和分段,可分页或分段的称分页系统,分段系统。在原文中并没有出现分段的词,但从文章的语义中,意思为分段。
译注6:文章我尽量在翻译中“信”的基础上,达到“雅”,原问并没有出现“喂给”的单词,但是,我认为这样翻译会生动,也符合原意。
译注7:这个句话的意思是:文件存储在文件系统中,是经过格式化了(比如增加各种标志位,便于让文件系统控制),但是,原来用户 的数据是未格式化的,但是,文件系统接受用户读取文件的请求后,会负责还原。

为了说明什么是“标准输入文件”,“标准输出文件”,“标准出错文件”,写入如下代码解释:

/*=====================================
该程序载自《C++标准程序库》13章p603页,
极度显示了cout,cin, cerr的运用

该程序为:有个函数从stream读取浮点数
一直读到end-of-file为止,在此基础俘获异常
显示在cerr里
======================================*/
#include "stdafx.h"
#include <iostream>
#include <cstdlib>

namespace MyLib{
 double ReadAndProcessSum(std::istream& strm)
 {
  using std::ios;
  double value, sum;

  ios::io_state odlExceptions = strm.exceptions();

  strm.exceptions(ios::failbit | ios::badbit);

  try {
   sum = 0;
   while (strm >> value) {
    sum += value;
   }
  }
  catch(...){
   if (!strm.eof()) {
    throw;
   }
  }

  return 0;
 }
}

int main(int argc, char* argv[])
{
 using namespace std;
 double sum;

 // cout:对应的是标准输出文件
 cout<<"欢迎进入苏显华翻译文章解说代码"<<endl;

 try {
  // cin:对应标准输入文件
  sum = MyLib::ReadAndProcessSum(cin);
 }
 catch(const ios::failure& error){

  file://cerr就是对应标准错误文件
  cerr<< "standard exception:" <<error.what() <<endl;
  return EXIT_FAILURE;
 }

 cout << "sum:" << sum <<endl;
 return 0;
}

--by littleroy

2004-7-5

 

抱歉!评论已关闭.