Tuesday, May 5, 2020

Operating system free essay sample

Lightweight process; this is the unit of dispatching also known as thread. Multithreading; this refers to the ability of an os to support multiple, concurrent paths of Execution within a single process. Kernel-level thread; this is a type of threading in which all of the work of thread management is done by the kernel. Thread; this is a single execution path, with an execution stack, processor stack, and scheduling information. Review Questions 4.1 Table 3.5 lists typical elements found in a process control block for an unthreaded OS. Of these, which should belong to a thread control block and which should belong to a Process control block for a multithreaded system? Identifiers will appear in both thread and process control blocks, because both need to be identified. Processor State Information should belongs to process control block. Kernel will only interact with process not threads. Process Control Information: Thread control block should handle scheduling and State Information. We will write a custom essay sample on Operating system or any similar topic specifically for you Do Not WasteYour Time HIRE WRITER Only 13.90 / page 4Data Structuring should also be handled by thread control block (mostly). Memory Management and Resource ownership should belong to process control block. Privileges and Inter-process communications can probably be divided between the 2 process blocks depending on the system. 4.2 List reasons why a mode switch between threads may be cheaper than a mode switch between processes. Switching process requires OS to process more information. Memory is shared by threads, so theres no need to exchange memory or data during thread creation or switching. Thread switching does not require kernel to get involved, which in turn saves time on switching user to kernel mode. 4.3 What are the two separate and potentially independent characteristics embodied in the concept of process? Resource ownership: A process includes a virtual address space to hold the process image; recall from Chapter 3 that the process image is the collection of program, data, stack, and attributes defined in the process control block. From time to time, a process may be allocated control or ownership of resources, such as main memory, I/O channels, I/O devices, and files. The OS performs a protection function to prevent unwanted interference between processes with respect to resources. Scheduling/execution: The execution of a process follows an execution path (trace) through one or more programs (e.g., Figure 1.5 and Figure 1.26). This execution may be interleaved with that of other processes. Thus, a process has an execution state (Running, Ready, etc.) and a dispatching priority and is the entity that is scheduled and dispatched by the OS. 4.4 Give four general examples of the use of threads in a single-user multiprocessing system. Foreground and background work: For example, in a spreadsheet program, one thread could display menus and read user input, while another thread executes user commands and updates the spreadsheet. This arrangement often increases the perceived speed of the application by allowing the program to prompt for the next command before the previous command is complete. Asynchronous processing: Asynchronous elements in the program can be implemented as threads. For example, as a protection against power failure, one can design a word processor to write its random access memory (RAM) buffer to disk once every minute. A thread can be created whose sole job is periodic backup and that schedules itself directly with the OS; there is no need for fancy code in the main program to provide for time checks or to coordinate input and output. Speed of execution: A multithreaded process can compute one batch of data while reading the next batch from a device. On a multiprocessor system, multiple threads from the same process may be able to execute simultaneously. Thus, even though one thread may be blocked for an I/O operation to read in a batch of data, another thread may be executing. Modular program structure: Programs that involve a variety of activities or a variety of sources and destinations of input and output may be easier to design and implement using threads. 4.5 What resources are typically shared by all of the threads of a process? All of the threads of a process share the state and resources of that process. They reside in the same address space and have access to the same data. When one thread alters an item of data in memory, other threads see the results if and when they access that item. If one thread opens a file with read privileges, other threads in the same process can also read from that file. 4.6 List three advantages of ULTs over KLTs. 1. Thread switching does not require kernel mode privileges because all of the thread management data structures are within the user address space of a single process. Therefore, the process does not switch to the kernel mode to do thread management. This saves the overhead of two mode switches (user to kernel; kernel back to user). 2. Scheduling can be application specific. One application may benefit most from a simple round-robin scheduling algorithm, while another might benefit from a priority-based scheduling algorithm. The scheduling algorithm can be tailored to the application without disturbing the underlying OS scheduler. 3. ULTs can run on any OS. No changes are required to the underlying kernel to support ULTs. The threads library is a set of application-level functions shared by all applications. 4.7 List two disadvantages of ULTs compared to KLTs. 1. In a typical OS, many system calls are blocking. As a result, when a ULT executes a system call, not only is that thread blocked, but also all of the threads within the process are blocked. 2. In a pure ULT strategy, a multithreaded application cannot take advantage of multiprocessing. A kernel assigns one process to only one processor at a time. Therefore, only a single thread within a process can execute at a time. In effect, we have application-level multiprogramming within a single process. While This multiprogramming can result in a significant speedup of the application, there are applications that would benefit from the ability to execute portions of code simultaneously. Discussion 4.2 In the discussion of ULTs versus KLTs, it was pointed out that a disadvantage of ULTs is that when a ULT executes a system call, not only is that thread blocked, but also all of the threads within the process are blocked. Why is that so? User process functions separately from Kernel processes. That is, thread structure of a process is not visible to the OS/kernel, which schedules on the basis of processes. The kernel continues to schedule the process as a unit and assigns a single execution state (Ready, Running, Blocked, etc.) to that process once one thread is blocked, the whole process is blocked and consequently all threads in that process are blocked. 4.5 If a process exits and there are still threads of that process running, will they continue to run? LEWI96-42 No, threads of the process will no longer run once the process is terminated. This is because all threads in a process share the same address space, all threads are suspended at the same time. Similarly, termination of a process terminates all threads within that process

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.