CSCI361 Operating Systems Chapter 4

Ace your homework & exams now with Quizwiz!

Multithreaded Approaches

A Java run-time environment is an example of a system of one process with multiple threads. Of interest in this section is the use of multiple processes, each of which supports multiple threads. This approach is taken in Windows, Solaris, and many modern versions of UNIX, among others. This is known as _____________ __________

Scheduling/Execution

A chacteristic of a process, the execution of which , follows an execution path (trace) through one or more programs. 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 This is known as __________/_________

Resource ownership

A chacteristic of a process, this includes a virtual address space to hold the process image which 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. This is known as ________ __________

Thread Synchronization

All of the threads of a process share the same address space and other resources, such as open files. Any alteration of a resource by one thread affects the environment of the other threads in the same process. It is therefore necessary to use ______ _______________ so that they do not interfere with each other or corrupt data structures. For example, if two threads each try to add an element to a doubly linked list at the same time, one element may be lost or the list may end up malformed. The issues raised and the techniques used in ______ _______________ are, in general, the same as for the synchronization of process

Uniprocessor Multithreading

In ____________ _______________ execution passes from one thread to another either when the currently running thread is blocked or when its time slice is exhausted.

Processes

In a multithreaded environment, a process is defined as the unit of resource allocation and a unit of protection. The following are associated with _________: • A virtual address space that holds the process image • Protected access to processors, other _________ (for interprocess communication), files, and I/O resources (devices and channels)

Thread Considerations

In an OS that supports threads, scheduling and dispatching is done on a thread basis Most of the state information dealing with execution is maintained in thread-level data structures 1) suspending a process involves suspending all threads of the process 2) termination of a process terminates all threads within the process

Combined Approach

In these, thread creation is done completely in user space, as is the bulk of the scheduling and synchronization of threads within an application. The multiple ULTs from a single application are mapped onto some (smaller or equal) number of KLTs. The programmer may adjust the number of KLTs for a particular application and processor to achieve the best overall results. In a ________ ________, multiple threads within the same application can run in parallel on multiple processors, and a blocking system call need not block the entire process. If properly designed, this approach should combine the advantages of the pure ULT and KLT approaches while minimizing the disadvantages.

Thread Execution States

Key States: 1) Running 2) Ready 3) Blocked These are all ______ _________ ______ and are the same as the ones for processes.

Benefits of Threads

Key points to this include: 1. It takes far less time to create a new thread in an existing process than to create a brand-new process. Studies done by the Mach developers show that thread creation is ten times faster than process creation in UNIX [TEVA87]. 2. It takes less time to terminate a thread than a process. 3. It takes less time to switch between two threads within the same process than to switch between processes. 4. Threads enhance efficiency in communication between different executing programs. In most operating systems, communication between independent processes requires the intervention of the kernel to provide protection and the mechanisms needed for communication. However, because threads within the same process share memory and files, they can communicate with each other without invoking the kernel. These are all ________ __ _______

Spawn

One of the thread operations, this creates a new thread and it is provided with its own register context and stack space and placed on the ready queue.

Finish

One of the thread operations, when a thread completes, its register context and stacks are deallocated.

Block

One of the thread operations, when a thread needs to wait for an event, it will _____ (saving its user registers, program counter, and stack pointers). The processor may now turn to the execution of another ready thread in the same or a different process

Unblock

One of the thread operations, when the event for which a thread is blocked occurs, the thread is moved to the Ready queue

User Level Thread(ULT)

One of the thread types, in this all thread management is done by the application and the kernel is not aware of the existence of threads.

Kernel-level Thread(KLT)

One of the thread types, in this, thread management is done by the kernel. No thread management is done by the application. Windows is an example of this approach

M:N

One of the thread:process relationships, this combines the attributes of a 1:M and M:1 relationship. TRIX is an example of this.

1:M

One of the thread:process relationships, this means a thread may migrate from one process environment to another. This allows a thread to be easily moved among distinct systems. Ra(Clouds) and Emerald are examples of this relationship

1:1

One of the thread:process relationships, this means each thread is a unique process. Traditional UNIX is an example of this relationship

M:1

One of the thread:process relationships, this means the process defines an address space and dynamic resouce ownership. Multiple threads may be created and executed within that process. Windows NT, Solaris, Linux, OS/2, OS/390 and MACH are examples of this relationship

Amdahl's Law

Speedup = time to execute program on a single processor time to execute program on N parallel processors = 1 (1 - f ) + f N The law assumes a program in which a fraction (1 - f) of the execution time involves code that is inherently serial and a fraction f that involves code that is infinitely parallelizable with no scheduling overhead. This law appears to make the prospect of a multicore organization attractive. But even a small amount of serial code has a noticeable impact. If only 10% of the code is inherently serial ( f = 0.9) , running the program on a multicore system with eight processors yields a performance gain of only a factor of 4.7. In addition, software typically incurs overhead as a result of communication and distribution of work to multiple processors and cache coherence overhead. This results in a curve where performance peaks and then begins to degrade because of the increased burden of the overhead of using multiple processors.

Multithreading

The ability of an OS to support multiple, concurrent paths of execution within a single process

Thread Uses

The following are examples of use: • 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.

Applications with Multithreading Benefits

The following are examples of: 1) Multithreaded native applications 2) Multiprocess applications 3) Java applications 4) Multiinstance applications

KLT Disadvantages

The principal disadvantage of ___ is that the transfer of control from one thread to another within the same process requires a mode switch to the kernel. These are the ___ _____________

Single Threaded Approaches

The traditional approach of a single thread of execution per process, in which the concept of a thread is not recognized, is referred to as ______ _________ __________. MS-DOS is an example of an OS that supports a single user process and a single thread.

Thread Types

There are two broad categories of these: 1) User Level Thread(ULT) 2) Kernel Level Thread(KLT) Together these make up the ______ _____

Jacketing

There are ways to work around the ULT problems. For example, both problems can be overcome by writing an application as multiple processes rather than multiple threads. But this approach eliminates the main advantage of threads: Each switch becomes a process switch rather than a thread switch, resulting in much greater overhead. Another way to overcome the problem of blocking threads is to use a technique referred to as _________ . The purpose of _________ is to convert a blocking system call into a non-blocking system call.

Thread

There may be multiple numbers of these in a process. Each has: • An execution state (Running, Ready, etc.) • A saved context when not running; one way to view these is as an independent program counter operating within a process • An execution stack • Some individual static storage for local variables • Access to the memory and resources of its process, shared with all of these that are in that process

Thread Operations

These are associated with a change in thread state and are: 1) Spawn 2) Block 3) Unblock 4) Finish Together these are known as ______ __________

Threads:Processes

These can have the following relationships: 1) 1:1 2) M:1 3) 1:M 4) M:N These are the relationships between _______:_________

Java applications

These embrace threading in a fundamental way. Not only does the Java language greatly facilitate multithreaded applications, but the Java Virtual Machine is a multithreaded process that provides scheduling and memory management for Java applications. ____ ____________ that can benefit directly from multicore resources include application servers such as Sun's Java Application Server, BEA's Weblogic, IBM's Websphere, and the open-source Tomcat application server. All applications that use a Java 2 Platform, Enterprise Edition (J2EE platform) application server can immediately benefit from multicore technology.

Process

These have two main characteristics: 1) Resource ownership 2) Scheduling/Execution

KLT Advantages

These include the following: 1) The kernel can simultaneously schedule multiple threads from the same process on multiple processors 2) If one thread in a process is blocked, the kernel can schedule another thread of the same process 3) Kernel routines can be multithreaded Combined these make up the ___ __________

ULT Disadvantages

These include the following: 1. In a typical OS, many system calls are blocking. As a result, when these execute a system call, not only is that thread blocked, but also all of the threads within the process are blocked. 2. In a pure ___ 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. Combined these are the ___ _____________

ULT Advantages

These include the following: 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. These can run on any OS. No changes are required to the underlying kernel to support these. The threads library is a set of application-level functions shared by all application Combined these make up the ___ __________

Threads Library

This contains code for creating and destroying threads, for passing messages and data between threads, for scheduling thread execution, and for saving and restoring thread contexts.

Lightweight Process

This is a unit of dispatching and is referred to as a ___________ _______ or thread

Task

This is a unit of resource ownership also known as a process.

Multithreaded native applications

characterized by having a small number of highly threaded processes

Multiprocess applications

characterized by the presence of many single-threaded processes

Multiinstance applications

multiple instances of the application in parallel


Related study sets

To Kill a Mockingbird Vocabulary Chapters 15-17

View Set

Regla de 3 simple directa e inversa

View Set

Unit 02 - Determining Filing Status and Residency

View Set

Chapter 24: Asepsis and Infection control

View Set

Cognition Ch 7: Long Term Memory: Encoding, Retrieval, and Consolidation

View Set

Activity: Genetics of ABO Blood Types

View Set

Chapter 12 Physical Geography: River Systems

View Set