【正文】
pooling, andmultiprogramming. Batch is good for executing large jobs that need little interaction。 } int src, dst。 dst=open(argv[2], O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IXUSR)。 close(dst)。 CHAR Buffer [BUF_SIZE]。 if (hIn == INVALID_HANDLE_VALUE) { printf (Cannot open input file. Error: %x\n, GetLastError ())。 return 3。 nIn 0) { WriteFile (hOut, Buffer, nIn。nIn, NULL) amp。 } hOut = CreateFile (argv [2], GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)。 return 1。}//solution 2: using Windows CopyFileinclude include define BUF_SIZE 256int main (int argc, LPTSTR argv []){ HANDLE hIn, hOut。 } if (n0) printf(read error !)。 int n。 for instance, do the number of allocated and unallocated blocks of storage match the total number on the device. There, errors are frequently processindependent (for instance, the corruption of data on a disk), so there must be a global program (the operating system) that handles all types of errors. Also, by having errors processed by the operating system, processes need not contain code to catch and correct all the errors possible on a system. Describe three general methods for passing parameters to the operating system.Answer:a. Pass parameters in registersb. Registers pass starting addresses of blocks of parametersc. Parameters can be placed, or pushed, onto the stack by the program, and popped off the stack by the operating system. Describe how you could obtain a statistical profile of the amount of time spent by a program executing different sections of its the importance of obtaining such a statistical profile.Answer: One could issue periodic timer interrupts and monitor what instructions or what sections of code are currently executing when the interrupts are delivered. A statistical profile of which pieces of code were active should be consistent with the time spent by the program in different sections of its code. Once such a statistical profile has been obtained, the programmer could optimize those sections of code that are consuming more of the CPU resources. What are the five major activities of an operating system in regard to file management?Answer:? The creation and deletion of files? The creation and deletion of directories? The support of primitives for manipulating files and directories? The mapping of files onto secondary storage? The backup of files on stable (nonvolatile) storage media What are the advantages and disadvantages of using the same systemcall interface for manipulating both files and devices?Answer: Each device can be accessed as though it was a file in the file system. Since most of the kernel deals with devices through this file interface,it is relatively easy to add a new device driver by implementing the hardwarespecific code to support this abstract file interface. Therefore,this benefits the development of both user program code, which can bewritten to access devices and files in the samemanner, and device driver code, which can be written to support a welldefined API. The disadvantage with using the same interface is that it might be difficult to capture the functionality of certain devices within the context of the file access API, thereby either resulting in a loss of functionality or a loss of performance. Some of this could be overe by the use of ioctl operation that provides a general purpose interface for processes to invoke operations on devices. What is the purpose of the mand interpreter? Why is it usually separate from the kernel? Would it be possible for the user to develop a new mand interpreter using the systemcall interface provided by the operating system?Answer: It reads mands from the user or from a file of mands and executes them, usually by turning them into one or more system calls. It is usually not part of the kernel since the mand interpreter is subject to changes. An user should be able to develop a new mand interpreter using the systemcall interface provided by the operating system. The mand interpreter allows an user to create and manage processes and also determine ways by which they municate (such as through pipes and files). As all of this functionality could be accessed by an userlevel program using the system calls, it should be possible for the user to develop a new mandline interpreter. What are the two models of interprocess munication? What are the strengths and weaknesses of the two approaches?Answer: The two models of interprocess munication are messagepassing model and the sharedmemory model. Why is the separation of mechanism and policy desirable?Answer: Mechanism and policymust be separate to ensure that systems are easy to modify. No two system installations are the same, so each installation may want to tune the operating system to suit its mechanism and policy separate, the policy may be changed at will while the mechanism stays unchanged. This arrangement provides a more flexible system. Why does Java provide the ability to call from a Java program native methods that are written in, say, C or C++? Provide an example of a situation in which a native method is useful.Answer: Java programs are intended to be platform I/O independent. Therefore, the language does not provide access to most specific system resources such as reading fromI/O devices or ports. To perform a system I/O specific operation, you must write it in a language that supports such features (such as C or C++.) Keep in mind that a Java program that calls a native method written in another language will no longer be architectureneutral. It is sometimes difficult to achieve a layered approach if two ponents of the operating system are dependent on each other. Identify a scenario in which it is unclear how to layer two system ponents that require tight coupling of their functionalities.Answer: The virtual m