A partial presentation on Threads
Presented by: Engr. Lawrence O. Galvez
As Partial Fulfillment for the Subject:
Software Development Tools and
Methodologies
Date: April 25, 2016
Place: PLM Graduate School of Engineering
Professor: Jesusa Padilla, Ph.D.
Outline of Discussion
1. Threads
2. Single-Threaded Approach
3. Multi-Threaded Approach
4. Characteristics of Threads
5. Processes and Threads and their differences
6. Thread Execution State
7. Thread Synchronization
8. Types of Threads (User Level Thread & Kernel Level Thread)
9. Advantages & Disadvantages of ULT & KLT
10. Difference of ULT
11. Multi-Threading model
12. Types of Threads in an OS
? ?
? ? ?
?
?
(For normal home use)
Computers w/
Single core
processor
(For normal Officeworks use)
(For Heavy computing or
multitasking use)
Computers w/
Single core
processor but with
Hyper-Threading
(HT) technology
Computers w/
Multi-core
processor & with
Hyper-Threading
(HT) technology
Kernel (inner core)
Shell (outer core)
threads
Throwback..throwback..throwback.. 1980s,1990s..
Computer  consists mainly of processor, memory and I/O components that are
interconnected and its main function is to execute programs
Processor  controls the operation of the computer and performs its data processing functions. When there is only one
processor, it is referred to as the central processing unit (CPU). The execution of program is done in central processing unit
(CPU) of the computer.
Computer Software  Computer software or simply called software or application, is a part of a computer system that
consists of encoded information or collection of computer instructions (or computer programs) used to operate the
computers and related devices, the tangible part of computer system is called hardware.
Software Engineering  Involves anything related to the design, development, maintenance, testing and evaluations of
software performed by software engineers/developers to make computer works.
Computer Program  one job of Software engineer is to create computer program, this program is a collection of
instructions that performs a specific task or job when executed by a computer.
Programming Languages (or Paradigms) Languages used in programming that the machine or computer can
understand. The most basic and oldest language is Machine Code (contains sequence of numbers which are already the
instructions to the machine), Assembly Language (developed in 1960s which has conditional and pre-processing
capabilities), Procedural or “Step-by-Step” Language (uses vocabulary related to problem being solved e.g. COBOL,
FORTRAN, BASIC, C-LANGUAGE), Object-oriented programming (OOP - data and/or instructions are kept in a single unit
called “object” e.g. C++ & Java. OOP is considered more of a paradigm (style of programming) rather than a language.
Operating System  a program that controls the execution of application programs and acts as interface between
applications and the computer hardware. Windows OS and Macintosh OS are samples of OS programs/software.
Processes  ???
Threads  ???????
Video 1 (inside your computer)
Video 2 (how CPU works)
CPU RAM
(System Memory)
BUS
Basic Operation of Single-core processor CPU
Simple Program
Get #3
Get #4
Add together
Store result in memory
0110 1010
0010 1011
1010 1001
0111 1001
Binary Nos. Hexadecimal No.
6A
2B
8F
3C
Computer codes
Computer
instructions
6A
2B
8F
3C
3C
8F
2B
6A
queue
PIPELINE
Math
Processor
Execution
Engine
CLOCK
2 GHz
Thread  a unit of execution or collection of instructions which together form a specific task
MSWorda unit of execution
6A, 2B, 8F, 3C
Did you know
Threads made an early appearance in OS/360
multiprogramming in 1967 in which they are called
“tasks”. The term “thread” was attributed to Victor A.
Vyssotsky
?
4F, 5D, 2G, 1E
MSExcel
Scheduler
CPU
Multi-tasking OS
(e.g. Windows,
Mac, etc.)
Time-slice
(e.g. 1 millisecond
switching)
Simultaneously
(to humans, it
appears
happening at the
same time)
Pre-emptive
Multi-tasking (it
does not relies on
applications)
2
PRIORITY
10
PRIORITY
MSWord  Process is basically the program that is running (i.e. program w/c consists
of set of instructions also similar to thread), but compared to thread, process is
typically independent, it has self-contained execution environment while
threads exist as subsets of a process.
1. Keyboard Input
2. Print
3. Save
Old MS-DOS based applications – can handle
only single threaded applications
 Thread 1
 Thread 2
Note: In Linux, there is no distinction between processes and threads. However, multiple
threads in Linux can be grouped together in such a way that, effectively you can have a
single process comprising of multiple threads.
Modern CPUs today
Multi-tasking Operating Systems
Multi-threaded Applications
1. Single Core CPUs with Hyper-Threading Technology
CPU
Thread 1
Thread 2
Thread 3
Thread 4
Thread 5
Thread 6
2. Multi-Core CPUs
Two real
pipelines
each have
their own
execution
engines
CPU
Virtual pipelines
3. Multi CPUs
CPU CPU
CPUCPU
S.M.P.
Symmetric
Multi
Processing
Note: The execution engines are not duplicated.
Computer
Servers
8 Logical Cores when hyper-threading is enabled
Single-Threaded Approach
 A single execution
path per process, in
which the concept
of a thread is not
recognized, is
referred to as a
single-threaded
approach
 MS-DOS, some
versions of UNIX
supported only this
type of process.
Single core
CPU
Multi-core
CPU
Multi-Threaded Approach
 The figure depicts
multithreaded
approaches
 A Java run-time
environment is a
system of one
process with
multiple threads;
Windows, some
UNIXes, support
multiple
multithreaded
processes.
Single core CPU
with hyper-
threading
Multi-core CPU
with hyper-
threading
End of my topics:
1. Threads
2. Single-Threaded Approach
3. Multi-Threaded Approach

LG’s Thread 3
Thank You!

Threads presentation

  • 1.
    A partial presentationon Threads Presented by: Engr. Lawrence O. Galvez As Partial Fulfillment for the Subject: Software Development Tools and Methodologies Date: April 25, 2016 Place: PLM Graduate School of Engineering Professor: Jesusa Padilla, Ph.D.
  • 2.
    Outline of Discussion 1.Threads 2. Single-Threaded Approach 3. Multi-Threaded Approach 4. Characteristics of Threads 5. Processes and Threads and their differences 6. Thread Execution State 7. Thread Synchronization 8. Types of Threads (User Level Thread & Kernel Level Thread) 9. Advantages & Disadvantages of ULT & KLT 10. Difference of ULT 11. Multi-Threading model 12. Types of Threads in an OS ? ? ? ? ? ? ?
  • 3.
    (For normal homeuse) Computers w/ Single core processor (For normal Officeworks use) (For Heavy computing or multitasking use) Computers w/ Single core processor but with Hyper-Threading (HT) technology Computers w/ Multi-core processor & with Hyper-Threading (HT) technology
  • 4.
    Kernel (inner core) Shell(outer core) threads
  • 5.
    Throwback..throwback..throwback.. 1980s,1990s.. Computer consists mainly of processor, memory and I/O components that are interconnected and its main function is to execute programs Processor  controls the operation of the computer and performs its data processing functions. When there is only one processor, it is referred to as the central processing unit (CPU). The execution of program is done in central processing unit (CPU) of the computer. Computer Software  Computer software or simply called software or application, is a part of a computer system that consists of encoded information or collection of computer instructions (or computer programs) used to operate the computers and related devices, the tangible part of computer system is called hardware. Software Engineering  Involves anything related to the design, development, maintenance, testing and evaluations of software performed by software engineers/developers to make computer works. Computer Program  one job of Software engineer is to create computer program, this program is a collection of instructions that performs a specific task or job when executed by a computer. Programming Languages (or Paradigms) Languages used in programming that the machine or computer can understand. The most basic and oldest language is Machine Code (contains sequence of numbers which are already the instructions to the machine), Assembly Language (developed in 1960s which has conditional and pre-processing capabilities), Procedural or “Step-by-Step” Language (uses vocabulary related to problem being solved e.g. COBOL, FORTRAN, BASIC, C-LANGUAGE), Object-oriented programming (OOP - data and/or instructions are kept in a single unit called “object” e.g. C++ & Java. OOP is considered more of a paradigm (style of programming) rather than a language. Operating System  a program that controls the execution of application programs and acts as interface between applications and the computer hardware. Windows OS and Macintosh OS are samples of OS programs/software. Processes  ??? Threads  ???????
  • 6.
    Video 1 (insideyour computer)
  • 7.
    Video 2 (howCPU works)
  • 8.
    CPU RAM (System Memory) BUS BasicOperation of Single-core processor CPU Simple Program Get #3 Get #4 Add together Store result in memory 0110 1010 0010 1011 1010 1001 0111 1001 Binary Nos. Hexadecimal No. 6A 2B 8F 3C Computer codes Computer instructions 6A 2B 8F 3C 3C 8F 2B 6A queue PIPELINE Math Processor Execution Engine CLOCK 2 GHz
  • 9.
    Thread  aunit of execution or collection of instructions which together form a specific task MSWorda unit of execution 6A, 2B, 8F, 3C Did you know Threads made an early appearance in OS/360 multiprogramming in 1967 in which they are called “tasks”. The term “thread” was attributed to Victor A. Vyssotsky ? 4F, 5D, 2G, 1E MSExcel Scheduler CPU Multi-tasking OS (e.g. Windows, Mac, etc.) Time-slice (e.g. 1 millisecond switching) Simultaneously (to humans, it appears happening at the same time) Pre-emptive Multi-tasking (it does not relies on applications) 2 PRIORITY 10 PRIORITY MSWord  Process is basically the program that is running (i.e. program w/c consists of set of instructions also similar to thread), but compared to thread, process is typically independent, it has self-contained execution environment while threads exist as subsets of a process. 1. Keyboard Input 2. Print 3. Save Old MS-DOS based applications – can handle only single threaded applications  Thread 1  Thread 2 Note: In Linux, there is no distinction between processes and threads. However, multiple threads in Linux can be grouped together in such a way that, effectively you can have a single process comprising of multiple threads.
  • 10.
    Modern CPUs today Multi-taskingOperating Systems Multi-threaded Applications 1. Single Core CPUs with Hyper-Threading Technology CPU Thread 1 Thread 2 Thread 3 Thread 4 Thread 5 Thread 6 2. Multi-Core CPUs Two real pipelines each have their own execution engines CPU Virtual pipelines 3. Multi CPUs CPU CPU CPUCPU S.M.P. Symmetric Multi Processing Note: The execution engines are not duplicated. Computer Servers
  • 11.
    8 Logical Coreswhen hyper-threading is enabled
  • 12.
    Single-Threaded Approach  Asingle execution path per process, in which the concept of a thread is not recognized, is referred to as a single-threaded approach  MS-DOS, some versions of UNIX supported only this type of process. Single core CPU Multi-core CPU
  • 13.
    Multi-Threaded Approach  Thefigure depicts multithreaded approaches  A Java run-time environment is a system of one process with multiple threads; Windows, some UNIXes, support multiple multithreaded processes. Single core CPU with hyper- threading Multi-core CPU with hyper- threading
  • 14.
    End of mytopics: 1. Threads 2. Single-Threaded Approach 3. Multi-Threaded Approach  LG’s Thread 3 Thank You!