Practice Problems + Their answers
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
Both stack and heap will be copied into a child process. However, copying will be delayed until child process makes a change(write) in those memories. This is called copy on write
When is it appropriate for the operating system to forsake this principle and to "waste" resources? Why is such a system not really wasteful?
To improve the ease of use because it provides a better user interaction/experience. Especially on single-user systems which require less resources
Consider a computing cluster consisting of two nodes running a database. Describe two ways in which the cluster software can manage access to the data on the disk. Discuss the benefits and disadvantages of each.
We can use two types of clustering: Asymmetric clustering --> here one node will do all work, while the other will be in standby in the case that the active node fails. The benefit is that the system will not halt if the active system fails. Disadvantage is inefficiency since we have two nodes but only use one. Symmetric clustering --> Parallel clustering, multiple nodes (here, 2) can read the data from the disk. Benefit is efficiency. Disadvantage is the need for special software to implement this form of clustering.
Sine CPUs provide for more than two modes of operation. What are two possible uses of these multiple modes?
1. CPUs that support virtualization have an additional mode which indicates when the VMM is in control. It has more privileges than user mode but less than kernel 2. We can also use privileged levels -- when the system has a higher privileged level, it can execute more instructions
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?
1. Cache is fast memory, so it is faster to get data from the cache than main or secondary memory 2. Caches are helpful when two or more components need to exchange data -- transfer speeds are much faster and can be down without using main memory Caches solve the transfer problem -- the component receiving data from another component does not have to wait as long as it would have to if we didn't use caches. Main problems caused by caches would be related to consistency and misses. Consistency --> when data is changed in main memory, the cache's data also needs to be updated. Misses --> If the data is not in the cache, we lose time checking if the data is in the cache and even more transferring it Faster memories are more expensive, so it would not be affordable.
Original versions of Apple's mobile iOS operating system provided no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system.
1. Difficulty in sharing global resources 2. Difficulty in resource allocation 3. Issues with debugging and programming errors Concurrency is when two processes are being performed at the same time. While only one processes is executed at a time by the CPU, these processes can be switched in and out as required.
Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the user job or the operating system itself. Describe two difficulties that you think could arise with such a scheme
1. The operating system cannot be modified or updated. This can be especially fatal if there is a critical bug 2. All passwords and other credentials of users must be kept in an unprotected memory since it cannot be stored in protected memory
Including the initial parent process, how many processes are created by the program shown in Figure 3.32? #include <stdio.h> #include <unistd.h> int main() { int i; for (i = 0; i < 4; i++) fork(); return 0; }
4 iterations 2^4 processes --> 16
Some computer systems provide multiple register sets. Describe what happens when a context switch occurs if the new context is already loaded into one of the register sets. What happens if the new context is in memory rather than in a register set and all the register sets are in use?
A context switch is a process that occurs when the CPU switches from one process to another. It is the process of storing the state of a process or thread so that it can be restored and resumed later. It is also called a task switch or a process switch. The operating system performs a context switch, and it is usually done when a process is waiting for I/O or when a time slice has expired. When a context switch occurs, and the new context is pre-loaded into one of the register sets, then we get the following: Fast context switching: No memory access: State preservation: When a context switch occurs, and all the register sets are occupied, then we get the following: Slow context switching: Selecting a victim process: State preservation:
Timers could be used to compute the current time. Provide a short description of how this could be accomplished.
A process can save a local state and set a time for some time then be suspended by the OS. After the timer has passed, an interrupt will wake the program. Based on the current time which was saved by the process before being suspended and the time it was awakened, it can measure the time. This also assumes that the current time can be obtained with a system call. If it cannot be, it can count the amount of times it was suspended and measure it like that. Second option isn't ideal
Explain the circumstances under which the line of code marked printf("LINE J") in Figure 3.33 will be reached. #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ execlp("/bin/ls","ls",NULL); printf("LINE J"); } else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; }
The printf("LINE J") statement will be reached if the execlp() system call fails to replace the child process with the ls command. This can happen if the ls command does not exist in the /bin directory. In this case, the execlp() system call will fail, and the printf("LINE J") statement will be reached.
Why do some systems store the operating system in firmware, while others store it on disk?
The reason to use a firmware as storage for the operating system would be if the device cannot contain a disk or a disk is not compatible with the specific hardware.
Some computer systems do not provide a privileged mode of operation in hardware. Is it possible to construct a secure operating system for these computer systems? Give arguments both that it is and that it is not possible.
Theoretically, this can be done by running only one process at a time and carefully monitoring it and inspecting its output. However, this surely affects the efficiency of the system (it will run much more slowly), and we must make sure to know the priority of each process somehow (which is rather hard if we do not have modes).
The services and functions provided by an operating system can be divided into two main categories. Briefly describe the two categories, and discuss how they differ.
There are different ways to define different categories of operating system's services and functions. In our case the difference is made based on the efficiency and usefulness of the operating system. One category of services makes the operating system helpful to the user, the other helpful to the system. The first class services contain the user interface, program execution services , I/0 operations services ,file-system manipulation, communications and error detection. The second category contains resource allocation, accounting and protection. The difference between the two categories is made based on the use and efficiency of each category.
How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system?
This distinction serves as a form of security because there exist instructions that can cause harm to the system, privileged instructions, which can only be executed in kernel mode. The hardware will not execute said instructions in user mode -- they are considered illegal and the hardware will trap them.
Describe how you could obtain a statistical profile of the amount of time a program spends executing different sections of its code. Discuss the importance of obtaining such a statistical profile.
What we should do in order to make a statistical profile of the amount of time spent by a programmer executing different sections of code is to issue timer interrupts. This can later be used by the engineer to optimize the code blocks which are consuming a lot of CPU resources.
Describe the actions taken by a kernel to context-switch between processes.
When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run.
Give an example of a situation in which ordinary pipes are more suitable than named pipes and an example of a situation in which named pipes are more suitable than ordinary pipes.
An example could be when several processes need to write messages to a log. Ordinary pipes work better with simple communication. Named pipes work better when several processes need to write messages. Ordinary pipes allow communication between parent and child processes, while named pipes permit unrelated processes to communicate. Context: A pipe is a technique for passing information from one process to another. Ordinary pipes allow two processes to communicate in standard producer-consumer fashion where the producer writes to one end of the pipe and the consumer reads from the other end. Thus they allow only one-way communication meaning they are unidirectional. An ordinary pipe cannot be accessed from outside the process that created it. Generally we use ordinary pipes when a parent process wants to communicate with its children. Once the processes have finished communicating and have terminated the ordinary pipes ceases to exist. On the other hand named pipes provide a much more bidirectional communication tool and don't require a parent-child relationship.
Why is the separation of mechanism and policy desirable?
By separating the mechanisms and policies we can make a more flexible system where modifications are easier to implement. This allows any system designer to develop mechanisms which will stay unchanged while the policies change to suit specific needs.
Distinguish between the client-server and peer-to-peer models of distributed systems.
Client-server model is more secure and scalable while peer-to-peer is faster and less expensive. Client-server model --> clients send requests to servers to execute some action. Some info is then sent by the server to the client which requested it. This can be the result of the action or some file. All authentication is done on the server. Peer-to-peer --> All connected systems are called peers and they act either as a client or as a server, depending on whether they are providing or requesting some service. Since there are no servers, which are so-called bottlenecks in the client-server model, this model is generally faster. Also, it is more simple and expensive to implement for fixed number of peers. It is not scalable, so it is more difficult to maintain.
Should OS' include web browsers and mail programs?
For: Yes because there are uses which would like their OS to come with programs such as web browsers and email so they do not have to install these programs themselves. Simply convenience. Against: Tight coupling of applications to OS is not something every user wants. Some users just want functionality with the ability to choose their own applications that are not a part of the OS.
Consider the RPC mechanism. Describe the undesirable consequences that could arise from not enforcing either the "at most once" or "exactly once" semantic. Describe possible uses for a mechanism that has neither of these guarantees.
If an RPC mechanism cannot support either at most once or at least once semantics then the RPC can fail or be duplicated and executed more than once as a result of common network errors. So the RPC server cannot guarantee that a remote procedure will be invoked correctly and executed only once.
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?
Microkernels have several advantages, such as making it easier to extend the operating system, making it easier to port it from one hardware design to another, needing less changes when modifying the kernel, being more reliable and secure. Its disadvantages are related to the overheads coming with the communication system and the frequent usage of messages. The microkernel must provide communication between the client program and the various services that are also running in user space. In this case communication is provided through message passing. The client program and service never interact directly only by exchanging messages with the microkernel.
It is sometimes difficult to achieve a layered approach if two components of the operating system are dependent on each other. Identify a scenario in which it is unclear how to layer two system components that require tight coupling of their functionalities.
One example where different components of an OS are related to each other would be the virtual memory and the storage system. Having strong dependencies between components makes it difficult to divide the layers
Describe a mechanism for enforcing memory protection in order to prevent a program from modifying the memory associated with other programs.
One such mechanism is called virtual memory. Every process which is running on computer will think it has access to all of the RAM and only it has access to the RAM. In reality, it has access to a small portion and when it addresses some location in RAM, OS will use a table to calculate a physical address in RAM from address requested by that process. Another way can be bound checking. If a process tries to access some addresses in RAM which are needed by OS, request can be ignored and interrupt can be raised
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?
Operating Systems are installed in different drives and/or partitions which are also known as boot disks or system disks. The bootstrap program needs to search the file system to find the operating system kernel, load it into memory, and start its execution.
explain what the output will be at LINE A. #include <sys/types.h> #include <stdio.h> #include <unistd.h> int value = 5; int main() { pid t pid; pid = fork(); if (pid == 0) { /* child process */ value += 15; return 0; } else if (pid > 0) { /* parent process */ wait(NULL); printf("PARENT: value = %d",value); /* LINE A */ return 0; } }
PARENT: value=5 However since the child is a duplicate both the parent and the child will have their ownown variables in this case the valuevalue variable. This means the child process will inherit the variable int value = 5int value = 5 however any changes done to this value on the child process after its creation will not affect the parent's value of the variable and the other way round.
What is the purpose of system calls?
System calls provide the interface between the operating system and a program in execution. Using system calls the operating system provides resources or actions for a running application. For example the system call open() provides access to a file in a file system while exit() terminates a program's execution. If a program in execution running in user mode requires some service from the kernel it will send a particular system call. After receiving the system call the kernel will provide the needed service on behalf of the program. As a result system calls are the only entry points in the kernel system. Some examples where a program in execution needs to send a system call would be : - to receive and send packages in network connections - to require access to hardware such as camera, printer or scanner - to manipulate devices ( reading from device buffers) - to manipulate files (create, delete, read, write)
What is the purpose of system programs?
System programs, also known as system utilities, are one of the main categories of programs the other being application programs. They are a collection of many system calls. Their main purpose is to provide an environment for program development and execution as well as providing basic functionality to users so that they can operate the system easily. There are seven types of system programs which serve different purposes.
What system calls have to be executed by a command interpreter or shell in order to start a new process on a UNIX system?
The following system calls need to be executed by a command/shell interpreter to start a new process on a UNIX system: fork(): This system call is used to create a new process by duplicating the calling process. The new process is called the child process, and the calling process is called the parent process. The child and parent processes run in separate memory spaces and have separate address spaces. exec(): This system call executes a new program in the calling process. It replaces the current process with a new one based on the program to be executed and the arguments passed to it. wait(): This system call waits for the child process to terminate. It suspends the execution of the calling process until the child process completes.
What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps be generated intentionally by a user program? If so, for what purpose?
The interrupt is used to inform the computer about terminating the current process and initiating a new one for a circuit. For this process, it sends a computer signal. When we compare an interrupt with a trap, we can see that an interrupt is created by hardware. But a trap is created by the software. The main reason to generate a trap is to let a program or task be executed continuously. That's why program continuity will never be lost. Yes, traps can also be generated intentionally by a user program. Because sometimes arithmetic failures occur in the system. If these errors are not gone, solving these problems will be more complicated in the future. That's why the user intervenes with traps. Also, OS procedures are called by the trap.
What are the two models of interprocess communication? What are the strengths and weaknesses of the two approaches?
The message - passing model and the shared memory model. The message passing model is useful for exchanging smaller amounts of data, is easier to implement and had no conflicts to avoid. However because of the implementation of the connection process it is slower than shared memory. Shared memory allows two or more processes to exchange information by reading and writing data in shared memory areas. It allows maximum speed and offers better convenience of communication. However it has security and synchronization issues as well as the processes that use the shared memory model need to make sure that they are not writing to the same memory location.
What are the advantages of using loadable kernel modules?
With loadable kernel modules we don't need to implement all the functionalities on the core system. The additional services are implemented only when they are needed either during boot up or when the OS is running.
Using the program shown in Figure 3.35, explain what the output will be at lines X and Y. #include <sys/types.h> #include <stdio.h> #include <unistd.h> #define SIZE 5 int nums[SIZE] = {0,1,2,3,4}; int main() { int i; pid t pid; pid = fork(); if (pid == 0) { for (i = 0; i < SIZE; i++) { nums[i] *= -i; printf("CHILD: %d ",nums[i]); /* LINE X */ } } else if (pid > 0) { wait(NULL); for (i = 0; i < SIZE; i++) printf("PARENT: %d ",nums[i]); /* LINE Y */ } return 0; }
X: CHILD: 0 CHILD: -1 CHILD: -4 CHILD: -9 CHILD: -16 Y: PARENT: 0 PARENT: 1 PARENT: 2 PARENT: 4
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.
a) Set value of timer: This instruction is used to set the value of the timer which is a critical system resource. c) Clear memory: This instruction is used to clear the memory of the system which is also a critical system resource. e) Turn off interrupts: This instruction is used to turn off interrupts which are alerts that are sent to the processor indicating that an event requiring immediate attention has occurred in the system. f) Modify entries in device-status table: This is an instruction that is used to indicate which devices are allocated to which processes and which ones are available for allocation. h) Access I/O device: This instruction is used to send data to an I/O device or to retrieve data from an I/O device which is a critical system resource. Thus, theses instructions should be privileged while the rest of the instructions can be executed in user mode. Set value of timer Clear memory Turn off interrupts Modify entries in device status table Access I/O device Se Cl Tu Mo Ac
Including the initial parent process, how many processes are created by the program shown in Figure 3.31? #include <stdio.h> #include <unistd.h> int main() { /* fork a child process */ fork(); /* fork another child process */ fork(); /* and fork another */ fork(); return 0; }
fork(); --> 2 processes fork() 2; --> 4 processes fork() 3; --> 8 processes 2^n processes
Assume that a distributed system is susceptible to server failure. What mechanisms would be required to guarantee the "exactly once" semantic for execution of RPCs?
to ensure that RPC is executed exactly once either distributed system should have shared memory with controlled access in which components check whether specific RPC was executed (this shared memory can be disk based i.e.) or components should talk to other components before executing a call to ensure that nobody else will execute it. This can be achieved by attaching some "clock value" to messages passed between components. "Clock value" indicates which component was first one "wanting to execute" this call. If the component which was first fails and it doesn't send a confirmation that it executed a call, component which was "second" should try and execute it.
What are the three main purposes of an operating system?
Provide an interface for users to communicate with hardware Resource allocator for efficiency Control program to manage user program execution, preventing errors and improper use
What are the benefits and the disadvantages of each of the following? Consider both the system level and the programmer level. a. Synchronous and asynchronous communication b. Automatic and explicit buffering c. Send by copy and send by reference d. Fixed-sized and variable-sized messages
A. In this case, when we use blocking send() and receive() statements, it can help solve the producer-consumer problem since the producer can invoke the blocking send() call and wait until the message is delivered to either the receiver or the mailbox, and the consumer blocks until a message is available by invoking receive(). However, sometimes the wait which comes with blocking can be quite long, which in cases such as network programming, we may wish to perform other activities. In these cases, by using non-blocking, we send off multiple requests, but the completion of the operations will be processed by the kernel at some later point. H B. The messages exchanged by communicating processes reside in a temporary queue. Automatic buffering provides a queue with indefinite length. Since the queue's length is potentially infinite, any number of messages can wait in it, so there is no need to block the sender while copying the message. However, it may reserve a sufficiently large memory and lead to memory wastage. In the case of explicit buffering, the length of the queue is provided, while in automatic buffering, the queue size needs to be indefinite. In explicit buffering, there is a bounded capacity since the queue has finite length. Thus, at most a maximum number equal to the length of the queue can reside in it. If the queue is full, the sender must block until space is available in the queue. However, unlike in automatic buffering, no memory is being wasted in explicit buffering. C. In send by copy, the sender and the receiver have two independent variables with the same value. If one modifies the parameter variable, the effect is not visible to the other. So the receiver can't change the state of the parameter of the sender. One advantage would be offering more safety since the value, rather than a reference to the location of the value, is passed. Thus, the original value cannot be corrupted. In send by reference, when we pass a parameter, the caller and the receiver use the same variable for the parameter. If one modifies the parameter, the effect is visible to both. So this method allows the receiver to alter the state of the parameter. It is beneficial to pass a reference than to copy the whole in
Using the program in Figure 3.34, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively.) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid t pid, pid1; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ pid1 = getpid(); printf("child: pid = %d",pid); /* A */ printf("child: pid1 = %d",pid1); /* B */ } else { /* parent process */ pid1 = getpid(); printf("parent: pid = %d",pid); /* C */ printf("parent: pid1 = %d",pid1); /* D */ wait(NULL); } return 0; }
A: 0 B: 2603 C: 2603 D: 2600 In summary, after the fork() system call, the child process has a pid value equal to 0, and the parent process has a pid value equal to the process ID of the child process. Additionally, the getpid() system call returns the process ID of the calling process. Thus, the pid variable equals the process ID of the calling process.
What is the main advantage of the layered approach to system design? What are the disadvantages of the layered approach?
Advantages: Simplicity of construction and easier debugging and system verification Disadvantages: Defining the layers and inefficiency Context: The layered approach is one of the operating-system structures. Since a modern operating system is a large and complex structure a common approach is to build it creating smaller modules instead of one large structure. The layered approach is one of these modular methods where the engineers partition the operating system in a number of levels and each level has different functionalities. In the layered approach the hardware is the lowest level (layer 0) and the user interface is the highest (layer N).
Contrast and compare an application programming interface (API) and an application binary interface (ABI).
An API is a high-level interface between two software components, while an ABI is a low-level interface between two binary program modules. An API is a set of functions and protocols for building and interacting with software applications. At the same time, an ABI is a set of rules that defines how the data structures or computational routines are accessed in machine code. Regarding the stability of the interface, an API can be modified more freely than an ABI, as long as developers using the API adhere to the new API version. On the other hand, an ABI cannot be modified as freely as an API since it is a low-level interface between two binary program modules and must remain stable, especially for binary compatibility.
Consider an SMP system similar to the one shown in Figure 1.8. Illustrate with an example how data residing in memory could in fact have a different value in each of the local caches.
An SMP system is a symmetric multiprocessing system that consists of multiple processors that share the same main memory and I/O devices. Each processor has its own set of registers and program counters in an SMP system. Thus, in an SMP system, each processor has its own local cache, and the main memory is shared among all the processors in the system. Let's consider that a process X receives data from the main memory and is running on processor CPU_0 of an SMP system. --> Then, the process X modifies the data, and before it is written back to the main memory, another process Y running on the processor CPU_1 of the SMP system reads the data from the main memory. --> Since the data has not been written back to the main memory, the process Y reads the old value of the data from the main memory. --> Thus, the data in memory could have different values in each of the local caches of an SMP system.
Explain the role of the init (or systemd) process on UNIX and Linux systems in regard to process termination.
Init is the ancestor of all other processes (it can be a direct or indirect ancestor) and it adopts all orphaned processes. Init then periodically invokes wait() in order release the orphan's PID and process-table entry.
Many SMP systems have different levels of caches; one level is local to each processing core, and another level is shared among all processing cores. Why are caching systems designed this way?
Local caches are much faster than shared caches. The data which is expected to be used by some processor is put into its local cache, but it is also put into the shared cache (if it is not already there --- notice that it is plausible that it was in the shared cache before it was transferred to the local cache). We put the data into the shared cache so that it can be quickly transferred to a local cache of another processor if it starts some process which needs this data.
Rank the following storage systems from slowest to fastest: a. Hard-disk drives b. Registers c. Optical disk d. Main memory e. Nonvolatile memory f. Magnetic tapes g. Cache
Magnetic tapes; Optical disk; Hard-disk drives; Nonvolatile memory; Main memory; Cache; Registers. Magnetic tapes < Optical disk < Hard-disk drives < Nonvolatile memory < Main memory < Cache < Registers. Mag Opt Har Non Mai Cac Reg MOHNMCR
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.
Program execution I/O Operations File-system manipulation Communications Error detection a. 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. b. 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. c. 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. d. 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. e. 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 progr
What is the main difficulty that a programmer must overcome in writing an operating system for a real-time environment?
Real-time operating systems have fixed time constraints on operations of a processor and data flow. A system will fail if a process takes too long to complete, so programmers must pay attention to optimization and resource allocation.
Describe three general methods for passing parameters to the operating system.
Registers, blocks, and stacks
Would it be possible for the user to develop a new command interpreter using the system-call interface provided by the operating system?
Since the command interpreter (or the shell) allows users functionalities such as creating and managing processes, accessing scripts to shut down the computer or copy files, which can be accessed and implemented through system-calls by a user-level program we can conclude it is possible to develop a new command interpreter.
Consider the "exactly once" semantic with respect to the RPC mechanism. Does the algorithm for implementing this semantic execute correctly even if the ACK message sent back to the client is lost due to a network problem? Describe the sequence of messages, and discuss whether "exactly once" is still preserved.
The "exactly once" semantics ensure that a remote procedure will be executed exactly once and only once. The general algorithm for ensuring this combines an acknowledgment (ACK) scheme combined with timestamps (or some other incremental counter that allows the server to distinguish between duplicate messages). The general strategy is for the client to send the RPC to the server along with a timestamp. The client will also start a timeout clock. The client will then wait for one of two occurrences: (1) it will receive an ACK from the server indicating that the remote procedure was performed, or (2) it will time out. If the client times out, it assumes the server was unable to perform the remote procedure so the client invokes the RPC a second time, sending a later timestamp. The client may not receive the ACK for one of two reasons: (1) the original RPC was never received by the server, or (2) the RPC was correctly received—and performed—by the server but the ACK was lost. In situation (1), the use of ACKs allows the server ultimately to receive and perform the RPC. In situation (2), the server will receive a duplicate RPC and it will use the timestamp to identify it as a duplicate so as not to perform the RPC a second time. It is important to note that the server must send a second ACK back to the client to inform the client the RPC has been performed.
What are the advantages and disadvantages of using the same system call interface for manipulating both files and devices?
The advantages would be that the user program code would be the same used to access both files and devices only the parameters would change. Also the driver code could be rewritten to support API's (which are libraries of system calls). On the other hand it would be difficult to capture the full functionalities of some devices meaning it could result in a loss of functionality and performance.
What is the purpose of the command interpreter? Why is it usually separate from the kernel?
The command interpreter or the command-line interface is one of the ways a user can interface with the operating system, the other way being the GUI or the graphical user interface. It is a simpler interface, lighter and easier to implement. The command interpreter's main task is to understands and executes commands which it turns into system calls. Normally either the command interpreter itself contains the code to execute a command or it uses the command to identify and read an external file which holds some code. What is special about this interface is that it allows the users to directly enter the commands in the form of text-lines to be performed by the operating system.
How do clustered systems differ from multiprocessor systems? What is required for two machines belonging to a cluster to cooperate to provide a highly available service?
The difference is that clustered systems contain two or more independent systems (in multiprocessor systems, processors are not so independent of each other). For clustered systems to be efficient, we need to be sure that the system will not halt if one or more systems in the cluster fail. This is done by adding a level of redundancy in the system. For example, if some system fails, some other system can take control of its storage and rerun the required applications.
Discuss, with examples, how the problem of maintaining coherence of cached data manifests itself in the following processing environments: a. Single-processor systems b. Multiprocessor systems c. Distributed systems
a. Single — In a single-processor system, there is only one cache and only one process being executed sequentially by the CPU. Since there are no other users to simultaneously modify or access data, the cache is reliably up-to-date. b. Multi — In a multiprocessor system, each CPU has its own cache and/or a shared cache and the main memory. Without cache coherence, each CPU might store a local copy of some data, say an integer I that was stored to the cache from main memory, and changes to I will not persist between CPUs. Thus, accessed data may be out of date or inconsistent between processors. c. Distributed — In a distributed system, data is often shared between computers by keeping separate copies of files on each computer. However, changes to one file will not be visible to the rest of the system unless each copy is constantly kept up-to-date.
Direct memory access is used for high-speed I/O devices in order to avoid increasing the CPU's execution load. a. How does the CPU interface with the device to coordinate the transfer? b. How does the CPU know when the memory operations are complete? c. The CPU is allowed to execute other programs while the DMA controller is transferring data. Does this process interfere with the execution of the user programs? If so, describe what forms of interference are caused.
a. The device controller transfers an entire block of data directly to or from its own buffer storage to memory, with no intervention by the CPU. b. One interrupt is generated per block, to tell the device driver that the operation has completed. c. Yes. Once DMA processes are done, an interrupt is generated which add so the main processors load. Thus, affecting the sequence of queueing process