Threads Two - Operating Systems - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Operating Systems which includes File-System Structure, Defining, Logical File, Physical Device, Secondary, System Organized, File Control Block, Structure Consisting, Typical File Control Block etc.Key important points are: Threads Two, Scheduling, Execution, Resource Ownership, Multithreading, Process Stays, Lightweight Process, Ability, Support Multiple, Concurrent

Typology: Slides

2012/2013

Uploaded on 03/28/2013

ekana
ekana 🇮🇳

4

(44)

370 documents

1 / 41

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating Systems
Lecture 08:
Threads
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29

Partial preview of the text

Download Threads Two - Operating Systems - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Operating Systems

Lecture 08:

Threads

Processes vs. Threads

  • A process viewed so far as units of:
    • Resource ownership
    • Scheduling/execution
  • In multithreading OS:
    • Process stays the unit of resource ownership
    • Thread (or lightweight process ) is the unit of scheduling
  • Multithreading: the ability of an OS to

support multiple, concurrent paths of

execution within a single process Docsity.com^2

One or More Threads

in a Process

Each thread in a process has:

  • A thread execution state (Running, Ready, etc.)
  • A saved thread context when not running; one way to view a thread is as an independent program counter operating within a process
  • An execution stack
  • Some per-thread static storage for local variables
  • Access to the memory and resources of its process, shared with all other threads in that process

Threads vs. 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

2 RPCs with

single thread

and multi- threading

Multithreading on a Uniprocessor

User-Level Threads (ULTs)

  • All thread management is done by the application
  • The kernel is not aware of the existence of threads

Relationships Between ULT

States and Process States

Figure 4.6 Examples of the Relationships between User-Level Thread States and Process States

Disadvantages of ULTs

  • 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 all of the threads within the process are blocked

  • In a pure ULT strategy, a multithreaded

application cannot take advantage of multiprocessing

Kernel-Level Threads (KLTs)

  • Thread management is done by the kernel - no thread management is done by the application - Windows is an example of this approach

Disadvantage of KLTs

The transfer of control from one thread to

another within the same process

requires a mode switch to the kernel

This image cannot currently be displayed.

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