0% found this document useful (0 votes)
8 views

Week 04

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Week 04

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Operating

Systems:
Internals Week-4
and Design
Principles Operating System
Overview
Operating
Systems:
Internals
and
Design
Principles Threads
Processes and Threads
Resource Ownership Scheduling/Execution
Process includes a Follows an execution path
virtual address space to that may be interleaved with
hold the process image other processes
 the OS performs a  a process has an execution state
protection function to (Running, Ready, etc.) and a
prevent unwanted dispatching priority and is
interference between scheduled and dispatched by the
processes with respect to OS
resources
Processes and Threads
 The unit of dispatching is referred to as a thread or
lightweight process
 The unit 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
example
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

Each thread has:

• an execution state (Running, Ready, etc.)


• saved thread context when not running
• an execution stack
• some per-thread static storage for local
variables
• access to the memory and resources of its
process (all threads of a process share this)
Benefits of Threads

Less time to Threads enhance


terminate a efficiency in
thread than a Switching between communication
Takes less process between programs
time to create two threads takes
a new thread less time than
than a switching between
process processes
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
Most of the state information dealing with
execution is maintained in thread-level data
structures
 suspending a process involves suspending all
threads of the process
 termination of a process terminates all
threads within the process
Thread Execution States

The key states for a Thread operations


thread are: associated with a
change in thread
state are:
 Running
 Ready  Spawn
 Blocked
 Block
 Unblock
 Finish
Thread Synchronization
 Itis necessary to synchronize the activities of the
various threads
 all threads of a process share the same address
space and other resources
 any alteration of a resource by one thread
affects the other threads in the same process
Types of Threads

User Level
Thread (ULT)
Kernel level
Thread (KLT)
User-Level Threads (ULTs)
 All thread
management is done
by the application
 The kernel is not
aware of the
existence of threads
Process and Thread
Objects
Windows makes use of two types of process-
related objects:

Processes Threads
• an entity • a dispatchable
corresponding to unit of work that
a user job or executes
application that sequentially and
owns resources is interruptible
Table 4.3

Windows

Process

Object

Attributes

(Table is on
page 175 in
textbook)
Table 4.4

Windows

Thread

Object

Attributes

(Table is on page
175 in textbook)
Multithreaded Process

Achieves concurrency
without the overhead of
using multiple processes

Threads within the same


Threads in different
process can exchange
processes can exchange
information through their
information through shared
common address space and
memory that has been set up
have access to the shared
between the two processes
resources of the process
Interrupts as Threads
 Most operating systems contain two fundamental
forms of concurrent activity:
Processes cooperate with each other and manage the use of shared data
structures by primitives that enforce mutual exclusion and
(threads) synchronize their execution

Interrupts synchronized by preventing their handling for a period of


time
Processes and Threads
 A precedence hierarchy
is used to determine
which process or Foreground process
processes to kill in order
to reclaim needed Visible process
resources
Service process
 Processes are killed
beginning with the Background process
lowest precedence first
 The levels of the Empty process
hierarchy, in descending
order of precedence are:
End

You might also like