----
!! Question
'''Several popular microcomputer operating systems provide little or no means of concurrent processing. Discuss the major complications that concurrent processing adds to an operating system.'''
>>answer<<
!! Answer
* A method of time sharing must be implemented to allow each of several processes to have access to the system. This method involves the preemption of processes that do not voluntarily give up the CPU (by using a system call, for instance) and the kernel being reentrant (so more than one process may be executing kernel code concurrently).
* Processes and system resources must have protections and must be protected from each other. Any given process must be limited in the amount of memory it can use and the operations it can perform on devices like disks.
* Care must be taken in the kernel to prevent deadlocks between processes, so processes aren’t waiting for each other’s allocated resources.
>><<
----
!! Question
'''Describe the differences among short-term, medium-term, and long-term scheduling.'''
>>answer<<
!! Answer
* Short-term (CPU scheduler) -selects from jobs in memory, those jobs which are ready to execute, and allocates the CPU to them.
* Medium-term -used especially with time-sharing systems as an intermediate scheduling level. A swapping scheme is implemented to remove partially run programs from memory and reinstate them later to continue where they left off.
* Long-term (job scheduler) -determines which jobs are brought into memory for processing.
The primary difference is in the frequency of their execution. The short-term must select a new process quite often. Long-term is used much less often since it handles placing jobs in the system, and may wait a while for a job to finish before it admits another one.
>><<
----
!! Question
'''A DECSYSTEM-20 computer has multiple register sets. Describe the actions of a context switch if the new context is already loaded into one of the register sets. What else must happen if the new context is in memory rather than a register set, and all the register sets are in use?'''
>>answer<<
!! Answer
The CPU current-register-set pointer is changed to point to the set containing the new context, which takes very little time. If the context is in memory, one of the contexts in a register set must be chosen and moved to memory, and the new context must be loaded from memory into the set. This process takes a little more time than on systems with one set of registers, depending on how a replacement victim is selected.
>><<
----
!! Question
'''What two advantages do threads have over multiple processes? What major disadvantage do they have? Suggest one application that would benefit from the use of threads, and one that would not.'''
>>answer<<
!! Answer
Threads are very inexpensive to create and destroy, and they use very little resources while they exist. They do use CPU time for instance, but they don’t have totally separate memory spaces. Unfortunately, threads must “trust” each other to not damage shared data. For instance, one thread could destroy data that all the other threads rely on, while the same could not happen between processes unless they used a system feature to allow them to share data. Any program that may do more than one task at once could benefit from multitasking. For instance, a program that reads input, processes it, and outputs it could have three threads, one for each task. “Single-minded” processes would not bene?t from multiple threads; for instance, a program that displays the time of day.
>><<
----
!! Question
'''What resources are used when a thread is created? How do they differ from those used when a process is created?'''
>>answer<<
!! Answer
A context must be created, including a register set storage location for storage during context switching, and a local stack to record the procedure call arguments, return values, and return addresses, and thread-local storage. A process creation results in memory being allocated for program instructions and data, as well as thread-like storage. Code may also be loaded into the allocated memory
>><<
----
!! Question
'''Describe the actions taken by a kernel to switch context'''
# '''Among threads.'''
# '''Among processes.'''
>>answer<<
!! Answer
# The thread context must be saved (registers and accounting if appropriate), and another thread’s context must be loaded.
# The same as (a), plus the memory context must be stored and that of the next process must be loaded.
>><<
----
!! Question
'''What are the differences between user-level threads and kernel-supported threads? Under what circumstances is one type “better” than the other?'''
>>answer<<
!! Answer
User-level threads have no kernel support, so they are very inexpensive to create, destroy, and switch among. However, if one blocks, the whole process blocks. Kernel-supported threads are more expensive because system calls are needed to create and destroy them and the kernel must schedule them. They are more powerful because they are independently scheduled and block individually.
>><<
----
!! Question
'''Consider the interprocess-communication scheme where mailboxes are used. Suppose a process P wants to wait for two messages, one from mailbox A and one from mailbox B. What sequence of send and receive should it execute?'''
>>answer<<
!! Answer
>><<
----
!! Question
'''Consider an operating system that supports both the IPC and RPC schemes. Give examples of problems that could be solved with each type of scheme. Explain why each problem is best solved by the method that you specify.'''
>>answer<<
!! Answer
>><<