Operating Systems Midterm Review: Inclass Activities 1-12

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Why do some systems store the operating system in firmware, while others store it on disk?

For certain devices, such as handheld PDAs and cellular telephones, a disk with a file system may be not be available for the device. In this situation, the operating system must be stored in firmware.

What is a disadvantage with the one to one multithreading model?

For each user thread created a kernel thread must be created as well. Because the overhead of kernel threads can burden the performance of an application, many systems limit the number of user threads which can be created.

In context switching when the CPU receives and interrupt, the state of the current process must be saved. How does the operating system handle this?

In context switching, the state of the current process being switched from is saved to its PCB by the operating system. This allows the processor to correctly resume execution when the process has been re-dispatched to the CPU.

What is the major advantage of the many to many multithreading model over the many to one and the one to one models?

It does not suffer from the shortcomings of either model. Unlike the many to one model it supports concurrency and is not affected by blocking calls. Unlike the one to one model, due to the multiplexing of user threads to an equal number or lesser amount of kernel threads, it does not suffer from the same system overhead issues.

Why is it a good idea to restrict a child process to a subset of the resources of the parent process?

It is a good idea to restrict a child process to a subset of the resources of a parent process in order to prevent a process from generating too many child processes and consuming too much system resources.

Explain why Java programs running on Android systems do not use the standard Java API and virtual machine.

It is because the standard API and virtual machine are designed for desktop and server systems, not mobile devices. Google developed a separate API and virtual machine for mobile devices.

What is the difference between how named pipes are implemented on Unix vs Windows systems?

On Unix named pipes are half-duplex and can only support communication on the same machine. On Windows named pipes support full-duplex communication and allow communication between processes across machines.

Name one advantage and disadvantage each of blocking vs non-blocking message passing.

One advantage of blocking message passing is that it guarantees message delivery. A disadvantage is that it is slower as the process will be blocked until a message is delivered. An advantage of non-blocking message passing is speed as the process will continue executing after sending a message. A disadvantage is that it does not guarantee message delivery.

What is the purpose of system calls?

System calls allow user-level processes to request services of the operating system.

In Unix if the fork() system call is made to create a child process without calling exec() what will occur?

The child process and the parent process will be duplicates of each other.

How can the producer-consumer problem be solved using synchronization?

The producer-consumer problem can be solved by using blocking send and blocking receive.

What is the purpose of marshalling in RPC?

The purpose of marshalling is: 1) it is used by the client machine to package parameters to be transported across a network for a procedure call on a remote server machine. 2) On the server machine it is used to package the results of the procedure call to be transported back to the client machine.

Why must the short-term scheduler be very fast?

The short-term scheduler needs to be very fast because it is accessed very frequently and is responsible for dispatching processes to the CPU. The longer it takes the short-term scheduler to decide which process to dispatch the more time the CPU will be idle.

When a parent process creates a child process using the fork() system call what "state" is shared between the processes?

The state that is shared between the processes is memory address space.

What are the three major activities of an operating system with regards to memory management?

The three major activities are: a. Keep track of which parts of memory are currently being used and by whom. b. Decide which processes are to be loaded into memory when memory space becomes available. c. Allocate and deallocate memory space as needed.

What are the types of parallelism and what is the difference between them?

The two types of parallelism are data parallelism and task parallelism. Data parallelism involves distributing a subset of the data used by multiple tasks to the processor/core executing that task. Task parallelism involves distributing tasks to multiple processors/cores for simultaneous execution.

File-system manipulation

There are many details in file creation, deletion, allocation, and naming that users should not have to perform. Blocks of disk space are used by files and must be tracked. Deleting a file requires removing the name file information and freeing the allocated blocks. Protections must also be checked to assure proper file access. User programs could neither ensure adherence to protection methods nor be trusted to allocate only free blocks and deallocate blocks on file deletion.

With indirect communication when a process creates a mailbox it is the default owner and is the only process that can receive messages through it. However, ownership and receiving privileges may be passed to other processes. How is this done?

This is done by making the necessary system calls.

The producer-consumer problem in shared memory using buffers requires that the producer and consumer processes are synchronized. Why is this necessary?

This is necessary in order to prevent the consumer from consuming something that is still be produced.

What is meant by the long-term scheduler controlling the degree of multiprogramming?

This means that the long-term scheduler determines how many processes will be in main memory at any given time.

What is a loopback address and what is its purpose?

A loopback address is the IP address for a local machine and is used for client/server communication on the same machine using TCP/IP.

What is the difference between a process and a program?

A process is active while a program is a passive entity.

In synchronization within message passing systems what is meant by a rendezvous?

A rendezvous is when blocking send and blocking receive communication is used.

What is another name for both the long-term scheduler and the short-term scheduler?

Another name for the long-term scheduler is the job scheduler and another name for the short-term scheduler is the CPU scheduler.

What is the main advantage of the layered approach to system design? What are the disadvantages of using the layered approach?

As in all cases of modular design, designing an operating system in a modular way has several advantages. The system is easier to debug and modify because changes affect only limited sections of the system rather than touching all sections of the operating system. Information is kept only where it is needed and is accessible only within a defined and restricted area, so any bugs affecting that data must be limited to a specific module or layer.

What is the difference between automatic and explicit buffering?

With automatic buffering the size of the buffer is not limited or is unbounded. With explicit buffering the size of the buffer is fixed or is bounded.

Describe three general methods for passing parameters to the operating system.

a. Pass parameters in registers b. Registers pass starting addresses of blocks of parameters c. Parameters can be placed, or pushed, onto the stack by the program, and popped off the stack by the operating system

What is the difference between concurrent execution and parallel execution?

Concurrent execution means that multiple tasks all make progress in their execution but not simultaneously. Parallel execution is where multiple tasks can be executed simultaneously across multiple processors/cores.

Provide three programming examples in which multithreading provides better performance than a single-threaded solution.

• A Web server that services each request in a separate thread. • A parallelized application such as matrix multiplication where different parts of the matrix may be worked on in parallel. • An interactive GUI program such as a debugger where a thread is used to monitor user input, another thread represents the running application, and a third thread monitors performance.

What are the three major activities of an operating system with regards to secondary-storage management?

• Free-space management. • Storage allocation. • Disk scheduling.

What are two major disadvantages with the many to one multithreading model?

1) It does not support true concurrency due to a single kernel thread being used. 2) If a user threads makes a blocking call the entire process is blocked.

Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?

Caches are useful when two or more components need to exchange data, and the components perform transfers at differing speeds. Caches solve the transfer problem by providing a buffer of intermediate speed between the components. If the fast device finds the data it needs in the cache, it need not wait for the slower device. The data in the cache must be kept consistent with the data in the components. If a component has a data value change, and the datum is also in the cache, the cache must also be updated. This is especially a problem on multiprocessor systems where more than one process may be accessing a datum. A component may be eliminated by an equal-sized cache, but only if: (a) the cache and the component have equivalent state-saving capacity (that is, if the component retains its data when electricity is removed, the cache must retain data as well), and (b) the cache is affordable, because faster storage tends to be more expensive.

Error detection

Error detection occurs at both the hardware and software levels. At the hardware level, all data transfers must be inspected to ensure that data have not been corrupted in transit. All data on media must be checked to be sure they have not changed since they were written to the media. At the software level, media must be checked for data consistency; for instance, whether the number of allocated and unallocated blocks of storage match the total number on the device. There, errors are frequently process independent (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.

What is the difference between user threads and kernel threads and how they're supported?

User threads are created and managed in the user space and does not involve the kernel. Kernel threads are created and managed within the kernel.

What are the three main purposes of an operating system?

1. To provide an environment for a computer user to execute programs on computer hardware in a convenient and efficient manner. 2. To allocate the separate resources of the computer as needed to solve the problem given. The allocation process should be as fair and efficient as possible. 3. As a control program it serves two major functions: (1) supervision of the execution of user programs to prevent errors and improper use of the computer, and (2) management of the operation and control of I/O devices.

How is a socket identified in network communication?

A socket is identified by the concatenation of an IP address and port number.

Some CPUs provide for more than two modes of operation. What are two possible uses of these multiple modes?

Although most systems only distinguish between user and kernel modes, some CPUs have supported multiple modes. Multiple modes could be used to provide a finer-grained security policy. For example, rather than distinguishing between just user and kernel mode, you could distinguish between different types of user mode. Perhaps users belonging to the same group could execute each other's code. The machine would go into a specified mode when one of these users was running code. When the machine was in this mode, a member of the group could run code belonging to anyone else in the group. Another possibility would be to provide different distinctions within kernel code. For example, a specific mode could allow USB device drivers to run. This would mean that USB devices could be serviced without having to switch to kernel mode, thereby essentially allowing USB device drivers to run in a quasi-user/kernel mode.

What is an advantage and disadvantage each of automatic and explicit buffering?

An advantage of automatic buffering is that the sender will never have to wait on the receiver to send a message. A disadvantage is that it requires a lot of storage (memory) space. An advantage of explicit buffering is that it requires less storage space. A disadvantage is that if the buffer is full the sender will have to wait on the receiver to consume messages before it can send.

What is an advantage and disadvantage of both message passing and shared memory?

An advantage of message passing is that it can be used in a distributed environment. A disadvantage is that it is slower than shared memory due to the fact that message passing is done via the OS kernel. An advantage of shared memory is that it is faster than message passing as the kernel is only needed once to setup the shared memory location. Memory access from then on is by simple reading and writing to the shared memory space. A disadvantage of shared memory is that it is susceptible to cache coherency problems.

Keeping in mind the various definitions of operating system, consider whether the operating system should include applications such as Web browsers and mail programs. Argue both that it should and that it should not, and support your answers.

An argument in favor of including popular applications with the operating system is that if the application is embedded within the operating system, it is likely to be better able to take advantage of features in the kernel and therefore have performance advantages over an application that runs outside of the kernel. Arguments against embedding applications within the operating system typically dominate however: (1) the applications are applications - and not part of an operating system, (2) any performance benefits of running within the kernel are offset by security vulnerabilities, (3) it leads to a bloated operating system.

What is the main advantage of the microkernel approach to system design? How do user programs and system services interact in a microkernel architecture? What are the disadvantages of using the microkernel approach?

Benefits typically include the following: (a) adding a new service does not require modifying the kernel (b) it is more secure as more operations are done in user mode than in kernel mode (c) a simpler kernel design and functionality typically results in a more reliable operating system. User programs and system services interact in a microkernel architecture by using interprocess communication mechanisms such as messaging. These messages are conveyed by the operating system. The primary disadvantages of the microkernel architecture are the overheads associated with interprocess communication and the frequent use of the operating system's messaging functions to enable the user process and the system service to interact with each other.

How could a system be designed to allow a choice of operating systems from which to boot? What would the bootstrap program need to do?

Consider a system that would like to run both Windows XP and three different distributions of Linux (e.g., RedHat, Debian, and Mandrake). Each operating system will be stored on disk. During system boot-up, a special program (which we will call the boot manager) will determine which operating system to boot into. This means that rather initially booting to an operating system, the boot manager will first run during system startup. It is this boot manager that is responsible for determining which system to boot into. Typically boot managers must be stored at certain locations of the hard disk to be recognized during system startup. Boot managers often provide the user with a selection of systems to boot into; boot managers are also typically designed to boot into a default operating system if no choice is selected by the user.

I/O operations

Disks, tapes, serial lines, and other devices must be communicated with at a very low level. The user need only specify the device and the operation to perform on it, while the system converts that request into device- or controller-specific commands. User-level programs cannot be trusted to access only devices they should have access to and to access them only when they are otherwise unused.

What system calls have to be executed by a command interpreter or shell in order to start a new process?

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.

What are the advantages of using loadable kernel modules?

It is difficult to predict what features an operating system will need when it is being designed. The advantage of using loadable kernel modules is that functionality can be added to and removed from the kernel while it is running. There is no need to either recompile or reboot the kernel.

What is the purpose of the command interpreter? Why is it usually separate from the kernel?

It reads commands from the user or from a file of commands and executes them, usually by turning them into one or more system calls. It is usually not part of the kernel since the command interpreter is subject to changes.

Why is the separation of mechanism and policy desirable?

Mechanism and policy must 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 needs. With mechanism and policy separate, the policy may be changed at will while the mechanism stays unchanged. This arrangement provides a more flexible system.

Communications

Message passing between systems requires messages to be turned into packets of information, sent to the network controller, transmitted across a communications medium, and reassembled by the destination system. Packet ordering and data correction must take place. Again, user programs might not coordinate access to the network device, or they might receive packets destined for other processes.

In RPC the client needs to bind to the port on the server providing the remote request. What are the two mechanisms for accomplishing this?

One is a fixed method where the server port is compiled into the client stub. This method means that server can not change the port used for client RPC requests. The second method is using a matchmaker daemon which dynamically looks up the port number for a procedure on the server.

We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to "waste" resources? Why is such a system not really wasteful?

Single-user systems should maximize use of the system for the user. A GUI might "waste" CPU cycles, but it optimizes the user's interaction with the system.

What is the purpose of system programs? Give some examples.

System programs can be thought of as bundles of useful system calls. They provide basic functionality to users so that users do not need to write their own programs to solve common problems.

For IPC within the Mach operating system what is the purpose of the Kernel mailbox and the Notify mailbox?

The Kernel mailbox is responsible for all communication between the kernel and a process. This mailbox is how system call are made. The Notify mailbox is used by the kernel to send notifications to a process.

Distinguish between the client-server and peer-to-peer models of distributed systems.

The client-server model firmly distinguishes the roles of the client and server. Under this model, the client requests services that are provided by the server. The peer-to-peer model doesn't have such strict roles. In fact, all nodes in the system are considered peers and thus may act as either clients or servers—or both. A node may request a service from another peer, or the node may in fact provide such a service to other peers in the system. For example, let's consider a system of nodes that share cooking recipes. Under the client-server model, all recipes are stored with the server. If a client wishes to access a recipe, it must request the recipe from the specified server. Using the peer-to-peer model, a peer node could ask other peer nodes for the specified recipe. The node (or perhaps nodes) with the requested recipe could provide it to the requesting node. Notice how each peer may act as both a client (it may request recipes) and as a server (it may provide recipes).

What is the difference between a connection port and a communication port in Windows IPC?

The connection port is a public port used by processes to make a connection request to a service/subsystem. The communication ports are private ports which makes up the channel used for communication between a process and a service/subsystem. There are two communication ports, one for messages from a client to a service/subsystem and another for sending messages from the service/subsystem to a process.

What is the difference between the many to one multithreading model and two-level multithreading model?

The difference is that the two-level model allows a user thread to bind to a single kernel thread along with the many to many approach.

Does the distinction between kernel mode and usermode function as a rudimentary form of protection (security) system?

The distinction between kernel mode and user mode provides a rudimentary form of protection in the following manner. Certain instructions could be executed only when the CPU is in kernel mode. Similarly, hardware devices could be accessed only when the program is executing in kernel mode. Control over when interrupts could be enabled or disabled is also possible only when the CPU is in kernel mode. Consequently, the CPU has very limited capability when executing in user mode, thereby enforcing protection of critical resources.

What are the five major activities of an operating system with regards to process management?

The five major activities are: a. The creation and deletion of both user and system processes b. The suspension and resumption of processes c. The provision of mechanisms for process synchronization d. The provision of mechanisms for process communication e. The provision of mechanisms for deadlock handling

List five services provided by an operating system

The five services are: 1. Program execution 2. I/O operations 3. File-system manipulation 4. Communications 5. Error detection

Which of the following instructions should be privileged? a. Set value of timer. b. Read the clock. c. Clear memory. d. Issue a trap instruction. e. Turn off interrupts. f. Modify entries in device-status table. g. Switch from user to kernel mode. h. Access I/O device.

The following operations need to be privileged: Set value of timer, clear memory, turn off interrupts, modify entries in device-status table, access I/O device. The rest can be performed in user mode.

What is the main difficulty that a programmer must overcome in writing an operating system for a real time environment?

The main difficulty is keeping the operating system within the fixed time constraints of a real-time system. If the system does not complete a task in a certain time frame, it may cause a breakdown of the entire system it is running. Therefore, when writing an operating system for a real-time system, the writer must be sure that his scheduling schemes don't allow response time to exceed the time constraint.

With the direct communication form of message passing the identifiers of the processes are hard-coded. What is the major disadvantage of this mechanism?

The major disadvantage is that if a process's PID is changed then any direct communication links involving the process will have to be updated.

In multicore systems processes can have multiple threads executing in parallel. How does the operating system account for multiple threads belonging to a single process?

The operating system accounts for multiple threads executing in parallel for a single process by expanding the Process Control Block (PCB) of the process to include information on all its threads.

Program execution

The operating system loads the contents (or sections) of a file into memory and begins its execution. A user-level program could not be trusted to properly allocate CPU time.

The long-term scheduler must select a good mix of I/O processes and CPU-bound processes. Why is this the case?

This is the case because if there are too many I/O bound processes, the ready queue will be empty and the short-term scheduler will be underutilized. Also, if there are too many CPU-bound processes then the device queues will be empty and the I/O resources of the system will be underutilized.

Is it possible for a program to be associated with more than one process? Give an example of such a case.

Yes, it is possible for a program to be associated with more than one process. An example of this is having multiple windows open in your web browser.

What are the five major activities of an operating system in regard to file management?

•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


Set pelajaran terkait

Environmental Controls and Mobile Devices

View Set

Chapter 16 Short-Term Financial Planning

View Set

Ch. 3 Financial Instruments, Financial Markets, and Financial Institutions

View Set

Simplifying Expressions, Equivalent Expressions, Equivalent Expressions, Equivalent Expressions

View Set

THE WORLD TRADE ORGANIZATION World Trade Organization (WTO)

View Set

PREP U CH. 65electroencephalogram (EEG)

View Set

Chapter 3 Lesson 2 Quiz The New England Colonies

View Set