CH 04 -OS8e
CH 04 -OS8e
Systems:
Internals
and
Design
Principles Chapter 4
Threads
Eighth Edition
By William Stallings
Processes and
Threads
Resource Scheduling/
Ownership Execution
Process includes Follows an execution
a virtual address path that may be
space to hold the interleaved with other
process image processes
the OS performs a a process has an
protection function to execution state (Running,
prevent unwanted Ready, etc.) and a
interference between dispatching priority and is
processes with scheduled and dispatched
respect to resources by the OS
Processes and
Threads
Theunit of dispatching is referred to as a
thread or lightweight process
Theunit of resource ownership is referred to
as a process or task
Multithreading - The ability of an OS to
support multiple, concurrent paths of
execution within a single process
Single Threaded
Approaches
A single thread of
execution per
process, in which
the concept of a
thread is not
recognized, is
referred to as a
single-threaded
approach
MS-DOS is an
Multithreaded
Approaches
The right half of
Figure 4.1 depicts
multithreaded
approaches
A Java run-time
environment is an
example of a
system of one
process with
multiple threads
Processes
The unit or resource allocation and a unit of
protection
A virtual address space that holds the
process image
Protected access to:
processors
other processes
files
I/O resources
One or More
Threads
in a Process
Benefits of Threads
Thread Use in a
Single-User System
Foreground and background
work
Asynchronous processing
Speed of execution
Modular program structure
Threads
In an OS that supports threads,
scheduling and dispatching is done on a
thread basis
Table 4.1
Thread and Process Operation Latencies (s)
Combined Approaches
Thread creation is done
in the user space
Bulk of scheduling and
synchronization of
threads is by the
application
Solaris is an example
Table 4.2
Relationship between Threads and Processes
Applications That
Benefit
Multithreaded native applications
characterized by having a small number of
highly threaded processes
Multiprocess applications
characterized by the presence of many single-
threaded processes
Java applications
Multiinstance applications
multiple instances of the application in parallel
Valve Game
Software
and
Thread
Management
An application consists of A thread pool is a
one or more processes collection of worker threads
that efficiently execute
Each process provides the asynchronous callbacks on
resources needed to behalf of the application
execute a program
A fiber is a unit of
A thread is the entity execution that must be
within a process that can manually scheduled by the
be scheduled for execution application
A job object allows groups User-mode scheduling
of process to be managed (UMS) is a lightweight
as a unit mechanism that
applications can use to
schedule their own threads
Changes in Windows 8
Changes the traditional Windows approach to managing
background tasks and application lifecycles
Developers are now responsible for managing the state of their
individual applications
In the new Metro interface Windows 8 takes over the process
lifecycle of an application
a limited number of applications can run alongside the
main app in the Metro UI using the SnapView functionality
only one Store application can run at one time
Windows
Process
Object
Attribute
s
(Table is
on page
175 in
textbook)
4.4
Window
Thread
Object
Attribut
es
(Table is on
page 175 in
textbook)
Multithreaded
Process
Solaris Process
makes use of four thread-related
concepts:
A Lightweight Process
(LWP) Data Structure
Includes:
An LWP identifier
The priority of this LWP
A signal mask
Saved values of user-level registers
The kernel stack for this LWP
Resource usage and profiling data
Pointer to the corresponding kernel thread
Pointer to the process structure
Interrupts as Threads
Most operating systems contain two
fundamental forms of concurrent activity:
Solaris Solution