SlideShare a Scribd company logo
1 of 26
Download to read offline
What is Thread
Thread vs Process
• A Process is inert. A process never
executes anything it is simply a
container for threads.
• Threads run in the context of a
process. Each process has at least
one thread.
• A thread represents a path of
execution that has its own call stack
and CPU state.
• Threads are confined to context of
the process that created them.
• A thread executes code and
manipulates data within its process
address space.
• If two or more threads run in the
context of a single process they
share a common address space.
• They can execute the same code
and manipulate the same data.
• Threads sharing a common process
can share kernel object handles
because the handles belong to the
process, not individual threads.
Starting a Process
• Every time a process starts, the system creates a primary thread.
• The thread begins execution with the C/C run-time library startup
code.
• The startup code calls your main or WinMain and execution continues
until the main function returns and the C/C library code calls
ExitProcess.
Scheduling Threads
• Windows 2000, NT and Win98 are preemptive multi-tasking systems. Each
task is scheduled to run for some brief time period before another task is given
control of CPU.
• Threads are the basic unit of scheduling on current Win32 platforms. A thread
may be in one of three possible states
o running
o blocked or suspended, using virtually no CPU cycles
o ready to run, using virtually no CPU cycles
• A running task is stopped by the scheduler if
• it is blocked waiting for some system event or resource
Con’t
• its time slice expires and is placed back on the queue of ready to run threads
• it is suspended by putting itself to sleep for some time
• it is suspended by some other thread
• it is suspended by the operating system while the OS takes care of some other
critical activity.
• Blocked threads become ready to run when an event or resource they wait on
becomes available.
• Suspended threads become ready to run when their sleep interval has expired or
suspend count is zero.
Benefits of using Threads
• Keeping user interfaces responsive even if required processing takes a long
time to complete.
• handle background tasks with one or more threads
• service the user interface with a dedicated thread
• Your program may need to respond to high priority events. In this case, the
design is easier to implement if you assign that event handler to a high
priority thread.
• Take advantage of multiple processors available for a computation.
• Avoid low CPU activity when a thread is blocked waiting for response from
a slow device or human by allowing other threads to continue.
Potential Problems with Threads
• Conflicting access to shared memory
• one thread begins an operation on shared memory, is suspended, and leaves
that memory region incompletely transformed
• a second thread is activated and accesses the shared memory in the
corrupted state, causing errors in its operation and potentially errors in the
operation of the suspended thread when it resumes
• Race Conditions occur when correct operation depends on the order of
completion of two or more independent activities
• the order of completion is not deterministic Starvation
• a high priority thread dominates CPU resources, preventing lower priority
threads from running often enough or at all.
Synchronization
• A program may need multiple threads to share some data.
• If access is not controlled to be sequential, then shared data may become
corrupted.
• One thread accesses the data, begins to modify the data, and then is put to sleep
because its time slice has expired. The problem arises when the data is in an
incomplete state of modification.
• Another thread awakes and accesses the data, that is only partially modified. The
result is very likely to be corrupt data.
• The process of making access serial is called serialization or synchronization.
Thread Synchronization
• Synchronizing threads means that every access to data shared between threads is protected so that when any
thread starts an operation on the shared data no other thread is allowed access until the first thread is done.
• The principle means of synchronizing access to shared data are
• Interlocked increments
• only for incrementing or decrementing integers
• Critical Sections
• Good only inside one process
• Mutexes
• Named mutexes can be shared by threads in different processes.
• Events
• Useful for synchronization as well as other event notifications.
Private Assembly Deployment
Shared Assembly Deployment
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf
vp.pdf

More Related Content

Similar to vp.pdf

Multithreading
MultithreadingMultithreading
MultithreadingF K
 
Java Thread & Multithreading
Java Thread & MultithreadingJava Thread & Multithreading
Java Thread & Multithreadingjehan1987
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.pptshreesha16
 
Java Multithreading
Java MultithreadingJava Multithreading
Java MultithreadingRajkattamuri
 
Java multithreading
Java multithreadingJava multithreading
Java multithreadingMohammed625
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentationchnrketan
 
Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfHarika Pudugosula
 
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...Sachintha Gunasena
 
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdfMultithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdfHarika Pudugosula
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptxYojanaFegade
 

Similar to vp.pdf (20)

Multithreading
MultithreadingMultithreading
Multithreading
 
multithreading
multithreadingmultithreading
multithreading
 
Java Thread & Multithreading
Java Thread & MultithreadingJava Thread & Multithreading
Java Thread & Multithreading
 
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
 
Java
JavaJava
Java
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.ppt
 
Thread
ThreadThread
Thread
 
Thread
ThreadThread
Thread
 
Java Multithreading
Java MultithreadingJava Multithreading
Java Multithreading
 
Java multithreading
Java multithreadingJava multithreading
Java multithreading
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
 
Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdf
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Threads
ThreadsThreads
Threads
 
Pthread
PthreadPthread
Pthread
 
MULTI THREADING.pptx
MULTI THREADING.pptxMULTI THREADING.pptx
MULTI THREADING.pptx
 
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
Concurrency Programming in Java - 05 - Processes and Threads, Thread Objects,...
 
Lecture 5 inter process communication
Lecture 5 inter process communicationLecture 5 inter process communication
Lecture 5 inter process communication
 
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdfMultithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdf
 
1 Multithreading basics.pptx
1 Multithreading basics.pptx1 Multithreading basics.pptx
1 Multithreading basics.pptx
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 

vp.pdf

  • 1.
  • 3. Thread vs Process • A Process is inert. A process never executes anything it is simply a container for threads. • Threads run in the context of a process. Each process has at least one thread. • A thread represents a path of execution that has its own call stack and CPU state. • Threads are confined to context of the process that created them. • A thread executes code and manipulates data within its process address space. • If two or more threads run in the context of a single process they share a common address space. • They can execute the same code and manipulate the same data. • Threads sharing a common process can share kernel object handles because the handles belong to the process, not individual threads.
  • 4. Starting a Process • Every time a process starts, the system creates a primary thread. • The thread begins execution with the C/C run-time library startup code. • The startup code calls your main or WinMain and execution continues until the main function returns and the C/C library code calls ExitProcess.
  • 5. Scheduling Threads • Windows 2000, NT and Win98 are preemptive multi-tasking systems. Each task is scheduled to run for some brief time period before another task is given control of CPU. • Threads are the basic unit of scheduling on current Win32 platforms. A thread may be in one of three possible states o running o blocked or suspended, using virtually no CPU cycles o ready to run, using virtually no CPU cycles • A running task is stopped by the scheduler if • it is blocked waiting for some system event or resource
  • 6. Con’t • its time slice expires and is placed back on the queue of ready to run threads • it is suspended by putting itself to sleep for some time • it is suspended by some other thread • it is suspended by the operating system while the OS takes care of some other critical activity. • Blocked threads become ready to run when an event or resource they wait on becomes available. • Suspended threads become ready to run when their sleep interval has expired or suspend count is zero.
  • 7. Benefits of using Threads • Keeping user interfaces responsive even if required processing takes a long time to complete. • handle background tasks with one or more threads • service the user interface with a dedicated thread • Your program may need to respond to high priority events. In this case, the design is easier to implement if you assign that event handler to a high priority thread. • Take advantage of multiple processors available for a computation. • Avoid low CPU activity when a thread is blocked waiting for response from a slow device or human by allowing other threads to continue.
  • 8. Potential Problems with Threads • Conflicting access to shared memory • one thread begins an operation on shared memory, is suspended, and leaves that memory region incompletely transformed • a second thread is activated and accesses the shared memory in the corrupted state, causing errors in its operation and potentially errors in the operation of the suspended thread when it resumes • Race Conditions occur when correct operation depends on the order of completion of two or more independent activities • the order of completion is not deterministic Starvation • a high priority thread dominates CPU resources, preventing lower priority threads from running often enough or at all.
  • 9. Synchronization • A program may need multiple threads to share some data. • If access is not controlled to be sequential, then shared data may become corrupted. • One thread accesses the data, begins to modify the data, and then is put to sleep because its time slice has expired. The problem arises when the data is in an incomplete state of modification. • Another thread awakes and accesses the data, that is only partially modified. The result is very likely to be corrupt data. • The process of making access serial is called serialization or synchronization.
  • 10. Thread Synchronization • Synchronizing threads means that every access to data shared between threads is protected so that when any thread starts an operation on the shared data no other thread is allowed access until the first thread is done. • The principle means of synchronizing access to shared data are • Interlocked increments • only for incrementing or decrementing integers • Critical Sections • Good only inside one process • Mutexes • Named mutexes can be shared by threads in different processes. • Events • Useful for synchronization as well as other event notifications.
  • 11. Private Assembly Deployment Shared Assembly Deployment