Multithreading - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Multithreading

Description:

A thread is a way for the program to fork or split itself ... It is more efficient to use one process with multiple threads. Multithreaded web server process. ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 10
Provided by: serg8
Category:

less

Transcript and Presenter's Notes

Title: Multithreading


1
Multithreading
By Sergio Romanello
2
Multithreading
  • Outline
  • What is Multithreading?
  • Single vs Multithreaded
  • Processes
  • Example of Multithreading
  • Benefits

3
Multithreading
  • A thread is a way for the program to fork or
    split itself into two or more simultaneously
    running tasks.
  • E.g. alot of software that run on modern desktop
    PCs are
  • multithreaded.
  • Web browser
  • One thread to display images or text.
  • Another thread retrieves data from the network.
  • Word processor
  • One thread is for displaying graphics.
  • Another thread is for responding to keystrokes
    from the user.
  • Thread for performing spelling and grammar
    checking.

4
Single vs Multithreaded Processes
  • A traditional process has a single thread of
    control.
  • If a process has a multiple thread of control, it
    can perform many tasks at a time.
  • A thread shares with other threads belonging to
    the same process its code section, data section,
    and other operating system resources.

5
Single vs Multithreaded Processes
6
Web Browser Example
  • Problem/Example
  • Web browser accepts client request for webpage,
    image, sounds, and so on.
  • A web browser server may have several clients
    concurrently accessing it.
  • If the web browser ran as a traditional single
    threaded process, it would be able to service
    only one client at a time. The amount of
  • time the client may have to wait is enormous.

7
Web Browser Example
  • Solution 1
  • When a server receives a request, it creates a
    separate process to service that request.
  • Old solution before threads become popular.
  • Disadvantage
  • Time consuming and resource intensive, new
    process will perform the same task as the
    existing process.

8
Web Browser Example
  • Solution 2
  • It is more efficient to use one process with
    multiple threads.
  • Multithreaded web server process.
  • Create a separate thread that would listen for
    client requests.
  • When a request is made, rather than creating
    another process, the server would create another
    thread to serve that request.
  • Many operating systems are multithreaded.
  • Linux is multithreaded.

9
Benefits of Multithreading
  • Responsiveness multithreading an interactive
    application may allow a program to continue
    running even if part of it is blocked or
    performing a length operation.
  • Resource Sharing the thread share the memory and
    the resources of the process to which they
    belong.
  • Economy allocating memory and resources for
    process creation is costly.
  • Utilization of Multi Processor Architecture the
    benefits of multithreading can be greatly
    increased in a multiprocessor architecture where
    threads running on parallel on different
    processors.
Write a Comment
User Comments (0)
About PowerShow.com