2.4 What are the three major activities of an operating system with regard to secondary-storage management?
- Free-space management;
- storage allocation;
- disk scheduling
2.6 What system calls have to be executed by a command interpreter or shell in order to start a new process?
- Unix:fork()
- Windows:CreateProcess()
In Unix systems, a fork system call followed by an exec system call need to be performed to start a new process. The fork call clones the currently executing process, while the exec call overlays a new process based on a different executable over the calling process
2.9 List five services provided by an operating system, and explain how each creates convenience for users. In which cases would it be impossible for user-level programs to provide these services? Explain your answer.
- User interface. Almost all operating systems have a user interface
- Program execution. The system must be able to load a program into memory and to run that program, end its execution, either normally or abnormally (indicating error).
- I/O operations. A running program may require I/O, which may involve a file or an I/O device.
- File-system manipulation. programs need to read and write files and directories, create and delete them, search them, list file information, permission management.
- Communications. Process may exchange information, on the same computer or between computers over a network.
(6.Error detection. Os needs to be constantly aware of possible errors.)
Another set of operating system functions (such as resource allocation, accounting and protection and security) exists not for helping the user but rather for ensuring the efficient operation of the system itself. Systems with multiple users can gain efficiency by sharing the computer resources among the users.
2.10 Why do some systems store the operating system in firmware, while others store it on disk?
For large operating systems (including most general-purpose operating systems like Windows, Mac OS X, and UNIX) or for systems that change frequently, the bootstrap loader is stored in firmware, and the operating system is on disk.
Some systems — such as cellular phones, tablets, and game consoles — store the entire operating system in firmware. Storing the operating system in ROM is suitable for small operating systems, simple supporting hardware, and rugged operation.
For certain devices, such as handheld PDAs and cellular telephones, a disk with a file system may be not be available for the device. ?
2.13 Describe three general methods for passing parameters to the operating system.
- pass the parameters in registers
- the parameters are generally stored in a block, or table, in memory, and the address of the block is passed as a parameter in a register
- Parameters also can be placed, or pushed, onto the stack by the program and popped off the stack by the operating system.
2.16 What are the advantages and disadvantages of using the same system- call interface for manipulating both files and devices?
Advantages
Each device can be accessed as though it was a file in the file system. Therefore, this benefits the development of both user program code, which can be written to access devices and files in the same manner, and device driver code, which can be written to support a well-defined API.
Disadvantage
it might be difficult to capture the functionality of certain devices within the context of the file access API, thereby resulting in either a loss of functionality or a loss of performance.
2.23 How are iOS and Android similar? How are they different?
Similarities
- Both are based on existing kernels (Linux and Mac OS X).
- Both have architecture that uses software stacks that provides a rich set of frameworks for developing mobile applications.
- Both provide frameworks for developers.
Difference
- iOS is designed to run on Apple mobile devices, and Android was developed for Android smartphones and tablet computers.
- iOS is closed-source, and Android is open-source.
- iOS applications are developed in Objective-C, Android in Java.
- Android uses a virtual machine, and iOS executes code natively.
2.24 Explain why Java programs running on Android systems do not use the standard Java API and virtual machine.
Rather than using the standard Java API, Google has designed a separate Android API for Java development. The Java class files are first compiled to Java byte code and then translated into an executable file that runs on the Dalvik virtual machine. The Dalvik virtual machine was designed for Android and is optimized for mobile devices with limited memory and CPU processing capabilities.
3.1 Using the program shown in Figure 3.30, explain what the output will
be at LINE A.
The output will be 5. When a process creates a new process, the child process is a duplicate of the parent process and the child process has a new program loaded into it.So the result is still 5 because the child process has a copy of its value.
3.2 Including the initial parent process, how many processes are created by
the program shown in Figure 3.31?
8. When the fock() function is called, each process will have a new child process.
3.5 When a process creates a new process using the fork() operation, which of the following states is shared between the parent process and the child process?
a. Stack b. Heap
c. Shared memory segments
Shared memory segments will be shared between the parent process and the child process.Heap and stack will not be shared, the child process will have its own copy.