SlideShare a Scribd company logo
1 of 15
Download to read offline
An Introduction to
threads
Presented by:
Zahra sadeghi
zahra sadeghi 2
history
 First: in late 60’s
 early 80’s : Unix community
 Windows 95 and OS/2
 Today: all operating systems have
multithreaded capability
zahra sadeghi 3
Terminology
 Thread:
 single sequence of execution
 independent path of execution
 Multiprogramming: Running multiple processes
concurrently
 Multithreading: Running multiple threads within one
process concurrently
 i.e: having several code executions within a
single process
zahra sadeghi 4
Process and thread
 A process is the "heaviest" unit of kernel
scheduling.
 process has its own memory area and data.
 A thread is the "lightest" unit of kernel
scheduling.
 the thread shares memory and data with the other
threads.
 A process/program,consists of many threads. (At
least one thread exists within each process.)
zahra sadeghi 5
Are threads actually needed!!!
 We are able to do the normal work with the
computer (like editing/saving a file) or drawing a
graphic and listening to music etc without getting
bothered with the print job.
 separate threads are executing all these tasks.
 the database or a web server interacts with a
number of users simultaneously.
 they maintain a separate thread for each user and
hence can maintain the state of all the users.
 If the program is run as one sequence then it is
possible that failure in some part of the program
will disrupt the functioning of the entire program.
 threads can execute independent of others
zahra sadeghi 6
drawbacks
 Is a Costly concept
 Many threads : less processor time
 memory : storing the context information of
each thread.
 Good designed program
zahra sadeghi 7
Multi_threading
 Each thread has its own run-time stack and
CPU state
 Two different threads can act on the same
object and same static fields concurrently
zahra sadeghi 8
example
zahra sadeghi 9
A thread control problem
multi-processor system:
 the operating system can allocate individual threads to the separate
processors, which thus fastens the execution of the program.
 the distribution of the threads on several processors is faster than
sharing time-slices on a single processor.
zahra sadeghi 10
Race Condition
 if shared data is accessed in an
unsynchronized manner
 Two threads are simultaneously reading or
modifying some shared data
 outcome :the order in which the
program's threads are allocated CPU time
zahra sadeghi 11
 On a single processor system,
threads can be run either in a preemptive
mode or in a cooperative mode.
threads
preemptive cooperative
zahra sadeghi 12
preemptive mode
 the operating system distributes the
processor time between the threads
 interrupts the threads at regular intervals
 The processor time given to each thread is
so small
 The switching between threads is so fast
that it appears as if all the threads are
running simultaneously.
zahra sadeghi 13
Cooperative mode
 each thread can control the CPU for as
long as it needs it.
 one thread can starve all the others
 Windows 3.x uses this kind of
implementation.
 A, B and C can be
considered as three
threads and are context
switched at the points
indicated by the small
circles.
zahra sadeghi 14
Implemntation of cooperative mode
 jmp_buf is defined in the ANSI C header file
setjmp.h.
 setjmp() : to save the execution environment
before switching out
 longjmp() : to switch to a place recorded in a
particular jump buffer.
 With this technique, we can implement a
non-preemptive threaded system with
minimal capability in about 100 lines!
 Note that a separate stack is required for each
executing function.
zahra sadeghi 15
Links & White Papers on Threads
 http://jamesthornton.com/linux/FAQ/Thre
ads-
 FAQ/ThreadLibs.html
 http://linuxdevices.com/articles/AT675369
9732.html
 http://www.gridbus.org/~raj/asc98.html

More Related Content

What's hot

Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)sonuu__
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-GalvinSonali Chauhan
 
Multithreading models
Multithreading modelsMultithreading models
Multithreading modelsanoopkrishna2
 
Multithreading
Multithreading Multithreading
Multithreading WafaQKhan
 
Operating System 4
Operating System 4Operating System 4
Operating System 4tech2click
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingguesta40f80
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
Hardware Multi-Threading
Hardware Multi-ThreadingHardware Multi-Threading
Hardware Multi-Threadingbabuece
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating SystemsNitish Gulati
 
Lecture24 Multiprocessor
Lecture24 MultiprocessorLecture24 Multiprocessor
Lecture24 Multiprocessorallankliu
 
Multiple processor (ppt 2010)
Multiple processor (ppt 2010)Multiple processor (ppt 2010)
Multiple processor (ppt 2010)Arth Ramada
 
Cache coherence
Cache coherenceCache coherence
Cache coherenceEmployee
 
Cache coherence problem and its solutions
Cache coherence problem and its solutionsCache coherence problem and its solutions
Cache coherence problem and its solutionsMajid Saleem
 

What's hot (20)

Thread
ThreadThread
Thread
 
Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
Thread
ThreadThread
Thread
 
Multithreading models
Multithreading modelsMultithreading models
Multithreading models
 
Multithreading
Multithreading Multithreading
Multithreading
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
4 threads
4 threads4 threads
4 threads
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
 
OS_Ch5
OS_Ch5OS_Ch5
OS_Ch5
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Hardware Multi-Threading
Hardware Multi-ThreadingHardware Multi-Threading
Hardware Multi-Threading
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 
Lecture24 Multiprocessor
Lecture24 MultiprocessorLecture24 Multiprocessor
Lecture24 Multiprocessor
 
Multiple processor (ppt 2010)
Multiple processor (ppt 2010)Multiple processor (ppt 2010)
Multiple processor (ppt 2010)
 
Cache coherence
Cache coherenceCache coherence
Cache coherence
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Cache coherence problem and its solutions
Cache coherence problem and its solutionsCache coherence problem and its solutions
Cache coherence problem and its solutions
 

Viewers also liked

Viewers also liked (14)

Parcticas
ParcticasParcticas
Parcticas
 
BSI 9001 Certificate
BSI 9001 CertificateBSI 9001 Certificate
BSI 9001 Certificate
 
Practicas de powerpoint
Practicas de powerpoint Practicas de powerpoint
Practicas de powerpoint
 
Design hybrid micropower system in mistah village using homer model
Design hybrid micropower system in mistah village using homer modelDesign hybrid micropower system in mistah village using homer model
Design hybrid micropower system in mistah village using homer model
 
Comunidades en medellín – barrio castilla
Comunidades en medellín – barrio castillaComunidades en medellín – barrio castilla
Comunidades en medellín – barrio castilla
 
16-bit microprocessors
16-bit microprocessors16-bit microprocessors
16-bit microprocessors
 
Holistic Counseling
Holistic CounselingHolistic Counseling
Holistic Counseling
 
Authentic Leadership
Authentic LeadershipAuthentic Leadership
Authentic Leadership
 
Sb diet-flyer
Sb diet-flyerSb diet-flyer
Sb diet-flyer
 
Easilens healthcare-computers-limited
Easilens healthcare-computers-limitedEasilens healthcare-computers-limited
Easilens healthcare-computers-limited
 
Experiential Learning Overview MTSU EMC
Experiential Learning Overview MTSU EMCExperiential Learning Overview MTSU EMC
Experiential Learning Overview MTSU EMC
 
Adonis y Venus
Adonis y VenusAdonis y Venus
Adonis y Venus
 
201607 03 - odoo 8.0
201607 03 - odoo 8.0201607 03 - odoo 8.0
201607 03 - odoo 8.0
 
Tyrosine kinase report
Tyrosine kinase reportTyrosine kinase report
Tyrosine kinase report
 

Similar to An Introduction to threads

Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaRaghu nath
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programmingAnyapuPranav
 
Operating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptxOperating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptxPrudhvi668506
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 
Concurrency in java
Concurrency in javaConcurrency in java
Concurrency in javaSaquib Sajid
 
Shared memory Parallelism (NOTES)
Shared memory Parallelism (NOTES)Shared memory Parallelism (NOTES)
Shared memory Parallelism (NOTES)Subhajit Sahu
 
dos slide share.pptx
dos slide share.pptxdos slide share.pptx
dos slide share.pptxNagaVarthini
 
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating SystemProcess, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating SystemLieYah Daliah
 
Lecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptxLecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptxAmanuelmergia
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10Minal Maniar
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptxbleh23
 

Similar to An Introduction to threads (20)

4.Process.ppt
4.Process.ppt4.Process.ppt
4.Process.ppt
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Threads
ThreadsThreads
Threads
 
Assignment-01.pptx
Assignment-01.pptxAssignment-01.pptx
Assignment-01.pptx
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
Chapter04 new
Chapter04 newChapter04 new
Chapter04 new
 
Os
OsOs
Os
 
Threads
ThreadsThreads
Threads
 
Operating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptxOperating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptx
 
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Concurrency in java
Concurrency in javaConcurrency in java
Concurrency in java
 
Shared memory Parallelism (NOTES)
Shared memory Parallelism (NOTES)Shared memory Parallelism (NOTES)
Shared memory Parallelism (NOTES)
 
dos slide share.pptx
dos slide share.pptxdos slide share.pptx
dos slide share.pptx
 
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating SystemProcess, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System
 
Lecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptxLecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptx
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 

More from Zahra Sadeghi

Maritime Anomaly Detection
Maritime Anomaly DetectionMaritime Anomaly Detection
Maritime Anomaly DetectionZahra Sadeghi
 
Quality Assurance in Modern Software Development
Quality Assurance in Modern Software DevelopmentQuality Assurance in Modern Software Development
Quality Assurance in Modern Software DevelopmentZahra Sadeghi
 
Attention mechanism in brain and deep neural network
Attention mechanism in brain and deep neural networkAttention mechanism in brain and deep neural network
Attention mechanism in brain and deep neural networkZahra Sadeghi
 
Perception, representation, structure, and recognition
Perception, representation, structure, and recognitionPerception, representation, structure, and recognition
Perception, representation, structure, and recognitionZahra Sadeghi
 
An introduction to Autonomous mobile robots
An introduction to Autonomous mobile robotsAn introduction to Autonomous mobile robots
An introduction to Autonomous mobile robotsZahra Sadeghi
 
Bluetooth Technoloty
Bluetooth TechnolotyBluetooth Technoloty
Bluetooth TechnolotyZahra Sadeghi
 
Self Organization Map
Self Organization MapSelf Organization Map
Self Organization MapZahra Sadeghi
 
A survey on ant colony clustering papers
A survey on ant colony clustering papersA survey on ant colony clustering papers
A survey on ant colony clustering papersZahra Sadeghi
 
Pittssburgh approach
Pittssburgh approachPittssburgh approach
Pittssburgh approachZahra Sadeghi
 
Cerebellar Model Articulation Controller
Cerebellar Model Articulation ControllerCerebellar Model Articulation Controller
Cerebellar Model Articulation ControllerZahra Sadeghi
 
Semantic Search with Semantic Web
Semantic Search with Semantic WebSemantic Search with Semantic Web
Semantic Search with Semantic WebZahra Sadeghi
 
Interval programming
Interval programming Interval programming
Interval programming Zahra Sadeghi
 
Ms dos boot process
Ms dos boot process Ms dos boot process
Ms dos boot process Zahra Sadeghi
 
An intoroduction to Multimedia
An intoroduction to MultimediaAn intoroduction to Multimedia
An intoroduction to MultimediaZahra Sadeghi
 
Parametric and non parametric classifiers
Parametric and non parametric classifiersParametric and non parametric classifiers
Parametric and non parametric classifiersZahra Sadeghi
 
Jack rental-car-problem
Jack rental-car-problemJack rental-car-problem
Jack rental-car-problemZahra Sadeghi
 

More from Zahra Sadeghi (20)

Maritime Anomaly Detection
Maritime Anomaly DetectionMaritime Anomaly Detection
Maritime Anomaly Detection
 
Quality Assurance in Modern Software Development
Quality Assurance in Modern Software DevelopmentQuality Assurance in Modern Software Development
Quality Assurance in Modern Software Development
 
Attention mechanism in brain and deep neural network
Attention mechanism in brain and deep neural networkAttention mechanism in brain and deep neural network
Attention mechanism in brain and deep neural network
 
Perception, representation, structure, and recognition
Perception, representation, structure, and recognitionPerception, representation, structure, and recognition
Perception, representation, structure, and recognition
 
An introduction to Autonomous mobile robots
An introduction to Autonomous mobile robotsAn introduction to Autonomous mobile robots
An introduction to Autonomous mobile robots
 
Bluetooth Technoloty
Bluetooth TechnolotyBluetooth Technoloty
Bluetooth Technoloty
 
Self Organization Map
Self Organization MapSelf Organization Map
Self Organization Map
 
A survey on ant colony clustering papers
A survey on ant colony clustering papersA survey on ant colony clustering papers
A survey on ant colony clustering papers
 
Pittssburgh approach
Pittssburgh approachPittssburgh approach
Pittssburgh approach
 
Cerebellar Model Articulation Controller
Cerebellar Model Articulation ControllerCerebellar Model Articulation Controller
Cerebellar Model Articulation Controller
 
Semantic Search with Semantic Web
Semantic Search with Semantic WebSemantic Search with Semantic Web
Semantic Search with Semantic Web
 
Interval programming
Interval programming Interval programming
Interval programming
 
Logic converter
Logic converterLogic converter
Logic converter
 
Ms dos boot process
Ms dos boot process Ms dos boot process
Ms dos boot process
 
An intoroduction to Multimedia
An intoroduction to MultimediaAn intoroduction to Multimedia
An intoroduction to Multimedia
 
Penalty function
Penalty function Penalty function
Penalty function
 
Neural networks
Neural networksNeural networks
Neural networks
 
Parametric and non parametric classifiers
Parametric and non parametric classifiersParametric and non parametric classifiers
Parametric and non parametric classifiers
 
sampling
samplingsampling
sampling
 
Jack rental-car-problem
Jack rental-car-problemJack rental-car-problem
Jack rental-car-problem
 

Recently uploaded

BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.PraveenaKalaiselvan1
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxpriyankatabhane
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxMurugaveni B
 
GenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptxGenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptxBerniceCayabyab1
 
Sulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptx
Sulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptxSulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptx
Sulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptxnoordubaliya2003
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxmalonesandreagweneth
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxpriyankatabhane
 
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 GenuineCall Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuinethapagita
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensorsonawaneprad
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
Davis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologyDavis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologycaarthichand2003
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPirithiRaju
 
preservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxpreservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxnoordubaliya2003
 
Solution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsSolution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsHajira Mahmood
 
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRCall Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRlizamodels9
 

Recently uploaded (20)

BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
 
GenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptxGenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptx
 
Sulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptx
Sulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptxSulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptx
Sulphur & Phosphrus Cycle PowerPoint Presentation (2) [Autosaved]-3-1.pptx
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
 
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort ServiceHot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptx
 
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 GenuineCall Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensor
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
 
Davis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologyDavis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technology
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
 
preservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxpreservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptx
 
Solution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsSolution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutions
 
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRCall Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
 

An Introduction to threads

  • 2. zahra sadeghi 2 history  First: in late 60’s  early 80’s : Unix community  Windows 95 and OS/2  Today: all operating systems have multithreaded capability
  • 3. zahra sadeghi 3 Terminology  Thread:  single sequence of execution  independent path of execution  Multiprogramming: Running multiple processes concurrently  Multithreading: Running multiple threads within one process concurrently  i.e: having several code executions within a single process
  • 4. zahra sadeghi 4 Process and thread  A process is the "heaviest" unit of kernel scheduling.  process has its own memory area and data.  A thread is the "lightest" unit of kernel scheduling.  the thread shares memory and data with the other threads.  A process/program,consists of many threads. (At least one thread exists within each process.)
  • 5. zahra sadeghi 5 Are threads actually needed!!!  We are able to do the normal work with the computer (like editing/saving a file) or drawing a graphic and listening to music etc without getting bothered with the print job.  separate threads are executing all these tasks.  the database or a web server interacts with a number of users simultaneously.  they maintain a separate thread for each user and hence can maintain the state of all the users.  If the program is run as one sequence then it is possible that failure in some part of the program will disrupt the functioning of the entire program.  threads can execute independent of others
  • 6. zahra sadeghi 6 drawbacks  Is a Costly concept  Many threads : less processor time  memory : storing the context information of each thread.  Good designed program
  • 7. zahra sadeghi 7 Multi_threading  Each thread has its own run-time stack and CPU state  Two different threads can act on the same object and same static fields concurrently
  • 9. zahra sadeghi 9 A thread control problem multi-processor system:  the operating system can allocate individual threads to the separate processors, which thus fastens the execution of the program.  the distribution of the threads on several processors is faster than sharing time-slices on a single processor.
  • 10. zahra sadeghi 10 Race Condition  if shared data is accessed in an unsynchronized manner  Two threads are simultaneously reading or modifying some shared data  outcome :the order in which the program's threads are allocated CPU time
  • 11. zahra sadeghi 11  On a single processor system, threads can be run either in a preemptive mode or in a cooperative mode. threads preemptive cooperative
  • 12. zahra sadeghi 12 preemptive mode  the operating system distributes the processor time between the threads  interrupts the threads at regular intervals  The processor time given to each thread is so small  The switching between threads is so fast that it appears as if all the threads are running simultaneously.
  • 13. zahra sadeghi 13 Cooperative mode  each thread can control the CPU for as long as it needs it.  one thread can starve all the others  Windows 3.x uses this kind of implementation.  A, B and C can be considered as three threads and are context switched at the points indicated by the small circles.
  • 14. zahra sadeghi 14 Implemntation of cooperative mode  jmp_buf is defined in the ANSI C header file setjmp.h.  setjmp() : to save the execution environment before switching out  longjmp() : to switch to a place recorded in a particular jump buffer.  With this technique, we can implement a non-preemptive threaded system with minimal capability in about 100 lines!  Note that a separate stack is required for each executing function.
  • 15. zahra sadeghi 15 Links & White Papers on Threads  http://jamesthornton.com/linux/FAQ/Thre ads-  FAQ/ThreadLibs.html  http://linuxdevices.com/articles/AT675369 9732.html  http://www.gridbus.org/~raj/asc98.html