Docsity

CSCI 3453: Operating System Concepts, Lecture notes of Operating Systems

Partial preview of the text

Download CSCI 3453: Operating System Concepts and more Lecture notes Operating Systems in PDF only on Docsity!

CSCI 3453: Operating

System Concepts

Chapter 4 - Objectives

●

To introduce the notion of a thread—a fundamental unit

of CPU utilization that forms the basis of multithreaded

computer systems

●

To discuss the APIs for the Pthreads and Java thread

libraries

●

To explore several strategies that provide implicit

threading

●

To examine issues related to multithreaded programming

Motivation

●

Multiple tasks within the application can be implemented

by separate threads

●

Example

  • (^) Microsoft Words can have multiple threads to perform

different task.

  • (^) Update display and user interface
  • (^) Auto save a file
  • (^) Spell checking

Motivation

●

Weather app on smart device

  • (^) Thread for updating display
  • (^) Thread for downloading data

Benefits

●

Responsiveness – may allow continued execution if part

of process is blocked, especially important for user

interfaces

●

Resource Sharing – threads share resources of process,

easier than shared memory or message passing

●

Economy – cheaper than process creation, thread

switching lower overhead than context switching

●

Scalability – process can take advantage of

multiprocessor architectures

Multicore Programming

●

Multicore or multiprocessor systems putting pressure on

programmers, challenges include:

  • (^) Dividing activities
  • (^) Balance
  • (^) Data splitting
  • (^) Data dependency
  • (^) Testing and debugging

Concurrency vs. Parallelism

●

Concurrent execution on single-core system:

●

Parallelism on a multi-core system:

Multicore Programming

●

Types of parallelism

  • (^) Data parallelism – distributes subsets of the same data

across multiple cores, same operation on each

  • (^) Task parallelism – distributing threads across cores,

each thread performing unique operation

●

As # of threads grows, so does architectural support for

threading

  • (^) CPUs have cores as well as hardware threads
  • (^) Consider Oracle SPARC T4 with 8 cores, and 8

hardware threads per core

Amdahl’s Law

●

That is, if application is 75% parallel / 25% serial,

moving from 1 to 2 cores results in speedup of 1.6 times

●

As N approaches infinity, speedup approaches 1 / S

Single and Multithreaded

Processes

User-Level Threads

●

Disadvantages

  • (^) Need to avoid blocking system calls [all threads

block]

  • (^) Does not take advantage of multiprocessors [no real

parallelism]

User-Level Threads

Implementing Kernel-level

threads

Kernel Threads

●

Pro:

  • (^) System calls will not block the entire process ●

Con

  • (^) Context switching becomes very expensive, almost as

expensive as context switching between processes