SlideShare a Scribd company logo
POSIX vs. Win32 Threads In depth threading techniques 1 Robert.Sayegh@gmail.com   (2008)
This presentation provides a summary based on few articles regarding threads in Win32 and POSIX systems. All these articles are mentioned in the References slide. Disclaimer 2 Robert.Sayegh@gmail.com   (2008)
What is Thread1. Processes What is a Process A process is created by OS to run your Main program. Contains all information to be handled by the OS. Process ID, process group ID, user ID, and group ID  Environment Scheduling Properties (priority, etc.) Working directory.  Program instructions  Registers,    Stack,    Heap  File descriptors  Signal actions  Shared libraries  Inter-process communication tools    shared memory ,      message queues,    semaphores ,            pipes,  3 Robert.Sayegh@gmail.com   (2008)
What is Thread2. Threads ,[object Object]
A thread is created by OS to run a stream of instructions.
Threads contain smaller set of information
Scheduling Properties
Registers
Stack
Signal actions
Light-Weight	Most overhead accomplished through maintaining its process.  ,[object Object]
Has its own independent flow of control (as long as its parent process exists and the OS supports it)
Duplicates only essential resources for independent schedulingComparing timing results in POSIX for the fork() and pthreads_create()(reflecting 50,000 creations) shows 30-60 times overhead! 4 Robert.Sayegh@gmail.com   (2008)
[object Object]
File open or close at the process level.
Memory Sharing (Same address, same data).Two pointers having the same value, exist in the same virtual memory and point to the same data.
No copy is needed!
Synchronization required.As resources and memory sharing is possible, explicit synchronization is required by the programmerThreads Sharing 5 Robert.Sayegh@gmail.com   (2008)
Win32 vs. POSIX Interface1. Function calls 6 Robert.Sayegh@gmail.com   (2008)

More Related Content

What's hot

Parallel computing
Parallel computingParallel computing
Parallel computingVinay Gupta
 
Internet control message protocol
Internet control message protocolInternet control message protocol
Internet control message protocolasimnawaz54
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memoryMazin Alwaaly
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
Internetworking.49
Internetworking.49Internetworking.49
Internetworking.49myrajendra
 
Protocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol SuiteProtocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol SuiteAtharaw Deshmukh
 
Internet protocols Report Slides
Internet protocols Report SlidesInternet protocols Report Slides
Internet protocols Report SlidesBassam Kanber
 
Design Principles for Connected Devices
Design Principles for Connected DevicesDesign Principles for Connected Devices
Design Principles for Connected DevicesVikram Nandini
 
Io t system management with
Io t system management withIo t system management with
Io t system management withxyxz
 
File Protection in Operating System
File Protection in Operating SystemFile Protection in Operating System
File Protection in Operating SystemMeghaj Mallick
 
Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcpMohd Arif
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)Vaibhav Bajaj
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layerNaiyan Noor
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets myrajendra
 

What's hot (20)

TCP and UDP
TCP and UDP TCP and UDP
TCP and UDP
 
Ppt 11 - netopeer
Ppt   11 - netopeerPpt   11 - netopeer
Ppt 11 - netopeer
 
Parallel computing
Parallel computingParallel computing
Parallel computing
 
Internet control message protocol
Internet control message protocolInternet control message protocol
Internet control message protocol
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Wot
WotWot
Wot
 
Windows 2000
Windows 2000Windows 2000
Windows 2000
 
Internetworking.49
Internetworking.49Internetworking.49
Internetworking.49
 
Raspberry Pi
Raspberry Pi Raspberry Pi
Raspberry Pi
 
Protocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol SuiteProtocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol Suite
 
Internet protocols Report Slides
Internet protocols Report SlidesInternet protocols Report Slides
Internet protocols Report Slides
 
Design Principles for Connected Devices
Design Principles for Connected DevicesDesign Principles for Connected Devices
Design Principles for Connected Devices
 
Io t system management with
Io t system management withIo t system management with
Io t system management with
 
File Protection in Operating System
File Protection in Operating SystemFile Protection in Operating System
File Protection in Operating System
 
Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets
 

Viewers also liked

Diagrama de bloque procesador intel
Diagrama de bloque procesador intelDiagrama de bloque procesador intel
Diagrama de bloque procesador intelCristian Paredes
 
Graphical user interface of web form
Graphical user interface of web formGraphical user interface of web form
Graphical user interface of web formmentorrbuddy
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface Bivek Pakuwal
 
User interfaces presentation
User interfaces presentationUser interfaces presentation
User interfaces presentationsomipam1
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)Bilal Amjad
 
human computer interface
human computer interfacehuman computer interface
human computer interfaceSantosh Kumar
 

Viewers also liked (11)

Diagrama de bloque procesador intel
Diagrama de bloque procesador intelDiagrama de bloque procesador intel
Diagrama de bloque procesador intel
 
User Interface
User InterfaceUser Interface
User Interface
 
Gui
GuiGui
Gui
 
Matlab GUI
Matlab GUIMatlab GUI
Matlab GUI
 
Graphical user interface of web form
Graphical user interface of web formGraphical user interface of web form
Graphical user interface of web form
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface
 
Matlab GUI
Matlab GUIMatlab GUI
Matlab GUI
 
User interfaces presentation
User interfaces presentationUser interfaces presentation
User interfaces presentation
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
human computer interface
human computer interfacehuman computer interface
human computer interface
 

Similar to PThreads Vs Win32 Threads

Processes and Threads in Windows Vista
Processes and Threads in Windows VistaProcesses and Threads in Windows Vista
Processes and Threads in Windows VistaTrinh Phuc Tho
 
Operating system Definition Structures
Operating  system Definition  StructuresOperating  system Definition  Structures
Operating system Definition Structuresanair23
 
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxbabayaga920391
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2mona_hakmy
 
Operating System 4
Operating System 4Operating System 4
Operating System 4tech2click
 
[iOS] Multiple Background Threads
[iOS] Multiple Background Threads[iOS] Multiple Background Threads
[iOS] Multiple Background ThreadsNikmesoft Ltd
 
Driver Programming Report
Driver Programming ReportDriver Programming Report
Driver Programming ReportShivek Khurana
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)Nagarajan
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptxbleh23
 
Interview Question of Aspdotnet
Interview Question of AspdotnetInterview Question of Aspdotnet
Interview Question of AspdotnetMohitKumar1985
 
Operating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptxOperating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptxPrudhvi668506
 
An isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra dasAn isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra dasVikash Chandra Das
 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qaabcxyzqaz
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net frameworkFaisal Aziz
 

Similar to PThreads Vs Win32 Threads (20)

Case Study 2: WINDOWS VISTA
Case Study 2: WINDOWS VISTACase Study 2: WINDOWS VISTA
Case Study 2: WINDOWS VISTA
 
Processes and Threads in Windows Vista
Processes and Threads in Windows VistaProcesses and Threads in Windows Vista
Processes and Threads in Windows Vista
 
Operating system Definition Structures
Operating  system Definition  StructuresOperating  system Definition  Structures
Operating system Definition Structures
 
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
Windows 2000
Windows 2000Windows 2000
Windows 2000
 
Concept of thread
Concept of threadConcept of thread
Concept of thread
 
Os
OsOs
Os
 
[iOS] Multiple Background Threads
[iOS] Multiple Background Threads[iOS] Multiple Background Threads
[iOS] Multiple Background Threads
 
Driver Programming Report
Driver Programming ReportDriver Programming Report
Driver Programming Report
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Linux vs windows
Linux vs windowsLinux vs windows
Linux vs windows
 
Interview Question of Aspdotnet
Interview Question of AspdotnetInterview Question of Aspdotnet
Interview Question of Aspdotnet
 
Operating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptxOperating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptx
 
An isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra dasAn isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra das
 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qa
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net framework
 

More from Robert Sayegh

Aligning the cogs - strategy for winning products.pdf
Aligning the cogs - strategy for winning products.pdfAligning the cogs - strategy for winning products.pdf
Aligning the cogs - strategy for winning products.pdfRobert Sayegh
 
Quick intro to scrum agile
Quick intro to scrum agileQuick intro to scrum agile
Quick intro to scrum agileRobert Sayegh
 
Get it Right the First Time
Get it Right the First TimeGet it Right the First Time
Get it Right the First TimeRobert Sayegh
 
SW Engineering Management
SW Engineering ManagementSW Engineering Management
SW Engineering ManagementRobert Sayegh
 
Assemblies versioning and signing
Assemblies versioning and signingAssemblies versioning and signing
Assemblies versioning and signingRobert Sayegh
 
Globalization Of Software
Globalization Of SoftwareGlobalization Of Software
Globalization Of SoftwareRobert Sayegh
 

More from Robert Sayegh (6)

Aligning the cogs - strategy for winning products.pdf
Aligning the cogs - strategy for winning products.pdfAligning the cogs - strategy for winning products.pdf
Aligning the cogs - strategy for winning products.pdf
 
Quick intro to scrum agile
Quick intro to scrum agileQuick intro to scrum agile
Quick intro to scrum agile
 
Get it Right the First Time
Get it Right the First TimeGet it Right the First Time
Get it Right the First Time
 
SW Engineering Management
SW Engineering ManagementSW Engineering Management
SW Engineering Management
 
Assemblies versioning and signing
Assemblies versioning and signingAssemblies versioning and signing
Assemblies versioning and signing
 
Globalization Of Software
Globalization Of SoftwareGlobalization Of Software
Globalization Of Software
 

Recently uploaded

Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfmbmh111980
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Soroosh Khodami
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)Max Lee
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems ApproachNeo4j
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdfkalichargn70th171
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Andrea Goulet
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationHelp Desk Migration
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 

Recently uploaded (20)

Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 

PThreads Vs Win32 Threads

  • 1. POSIX vs. Win32 Threads In depth threading techniques 1 Robert.Sayegh@gmail.com (2008)
  • 2. This presentation provides a summary based on few articles regarding threads in Win32 and POSIX systems. All these articles are mentioned in the References slide. Disclaimer 2 Robert.Sayegh@gmail.com (2008)
  • 3. What is Thread1. Processes What is a Process A process is created by OS to run your Main program. Contains all information to be handled by the OS. Process ID, process group ID, user ID, and group ID Environment Scheduling Properties (priority, etc.) Working directory. Program instructions Registers, Stack, Heap File descriptors Signal actions Shared libraries Inter-process communication tools shared memory , message queues, semaphores , pipes, 3 Robert.Sayegh@gmail.com (2008)
  • 4.
  • 5. A thread is created by OS to run a stream of instructions.
  • 6. Threads contain smaller set of information
  • 11.
  • 12. Has its own independent flow of control (as long as its parent process exists and the OS supports it)
  • 13. Duplicates only essential resources for independent schedulingComparing timing results in POSIX for the fork() and pthreads_create()(reflecting 50,000 creations) shows 30-60 times overhead! 4 Robert.Sayegh@gmail.com (2008)
  • 14.
  • 15. File open or close at the process level.
  • 16. Memory Sharing (Same address, same data).Two pointers having the same value, exist in the same virtual memory and point to the same data.
  • 17. No copy is needed!
  • 18. Synchronization required.As resources and memory sharing is possible, explicit synchronization is required by the programmerThreads Sharing 5 Robert.Sayegh@gmail.com (2008)
  • 19. Win32 vs. POSIX Interface1. Function calls 6 Robert.Sayegh@gmail.com (2008)
  • 20. Win32 vs. POSIX Interface2. Synchronization overhead 7 Robert.Sayegh@gmail.com (2008)
  • 21. Historically, hardware vendors have implemented their own proprietary versions of threads. In Windows, the thread is the basic execution unit, and the process is a container that holds this thread. In Linux, the basic execution unit is the process Some may claim POSIX threads are a low-level API and Windows threads are a high-level API In Windows the thread scheduling code is implemented in the kernel. In Linux realm, there are several drafts of the POSIX threads standard. Differences between drafts exist! Especially many scheduling mechanisms exist (user and kernel-level threads). The current POSIX standard is defined only for the C language. More issues to consider 8 Robert.Sayegh@gmail.com (2008)
  • 22. Mapping Win32 to Pthreads1. Process Mapping Mappable: Both the Windows and Linux constructs provide similar functionality. Context: The decision to use a specific Linux construct(s) depends on the application context !! More on WaitForMultipleObjects may be found under the following reference: http://www.ibm.com/developerworks/linux/library/l-ipc2lin3.html 9 Robert.Sayegh@gmail.com (2008)
  • 23. Mapping Win32 to Pthreads2. Thread Mapping 10 Robert.Sayegh@gmail.com (2008) Mappable: Both the Windows and Linux constructs provide similar functionality. Context: The decision to use a specific Linux construct(s) depends on the application context
  • 24. Mapping Win32 to Pthreads3. Synchronization !! Conditional Variables: While mutexes implement synchronization by controlling thread access to data, condition variables allow threads to synchronize based upon the actual value of data. See more under: https://computing.llnl.gov/tutorials/pthreads 11 Robert.Sayegh@gmail.com (2008)
  • 25. Mapping Win32 to PthreadsSynchronization (semaphores) Notice: Win32 semaphores are created within a thread, and propagated all over the system. POSIX semaphores are wither for inter-thread within a process, or inter-process entities. !! opensemaphore function enables multiple processes to open handles of the same semaphore object. The function succeeds only if some process has already created the semaphore by using the CreateSemaphore function. 12 Robert.Sayegh@gmail.com (2008)
  • 26. Mapping Win32toPthreadsSynchronization (events) Notice (See conclusion in the next slide). - Events are Windows specific objects. - POSIX semaphores with count set to 1 provide similar functionality to the Windows events. However, they don't provide timeout in the wait functions. - Conditional variables & Mutexin pthreads provide event-based synchronization between threads, but they are synchronous. 13 Robert.Sayegh@gmail.com (2008)
  • 27. Mapping Win32toPthreadsSynchronization (events) - conclusion 14 Robert.Sayegh@gmail.com (2008)
  • 28. Mapping Win32toPthreadsSynchronization (mutex) Notice (See conclusion in the next slide).Some major differences reside, including: - Named and un-named mutexes. - Ownershiop at creation. - Timeout during wait. - Recursive mutexes. 15 Robert.Sayegh@gmail.com (2008)
  • 29. Mapping Win32toLinuxSynchronization (mutex) - conclusion 16 Robert.Sayegh@gmail.com (2008)
  • 30. Mapping Win32 to LinuxSynchronization (Critical Sections) Notice: Since the critical sections are used only between the threads of the same process, Pthreadsmutex can be used to achieve the same functionality on Linux systems. 1 - In general, mutex objects are more CPU intensive and slower to use than critical sections due to a larger amount of bookkeeping, and the deep execution path into the kernel taken to acquire a mutex. The equivalent functions for accessing a critical section remain in thread context, and consist of merely checking and incrementing/decrementing lock-count related data. This makes critical sections light weight, fast, and easy to use for thread synchronization within a process. 2- In Win32 The primary benefit of using a mutex object is that a mutex can be named and shared across process boundaries. 17 Robert.Sayegh@gmail.com (2008)
  • 31. References POSIX Threads Programminghttps://computing.llnl.gov/tutorials/pthreads/ Why pthreads are better than Win32http://softwarecommunity.intel.com/ISN/Community/en-US/forums/post/840096.aspx Why Windows threads are better than pthreads: http://softwareblogs.intel.com/2006/10/19/why-windows-threads-are-better-than-posix-threads/ Port Windows IPC apps to Linux (including code examples) http://www.ibm.com/developerworks/linux/library/l-ipc2lin1.html http://www.ibm.com/developerworks/linux/library/l-ipc2lin2.html http://www.ibm.com/developerworks/linux/library/l-ipc2lin3.html 18 Robert.Sayegh@gmail.com (2008)
  • 32. Thank you 19 Robert.Sayegh@gmail.com (2008)