SlideShare a Scribd company logo
1 of 19
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

RPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksRPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksPradeep Kumar TS
 
LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...
LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...
LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...ClearView Imaging
 
Software Defined Network - SDN
Software Defined Network - SDNSoftware Defined Network - SDN
Software Defined Network - SDNVenkata Naga Ravi
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V IntroductionYi-Hsiu Hsu
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOSICS
 
Arista Networks - Building the Next Generation Workplace and Data Center Usin...
Arista Networks - Building the Next Generation Workplace and Data Center Usin...Arista Networks - Building the Next Generation Workplace and Data Center Usin...
Arista Networks - Building the Next Generation Workplace and Data Center Usin...Aruba, a Hewlett Packard Enterprise company
 
ARM Cortex-M3 Training
ARM Cortex-M3 TrainingARM Cortex-M3 Training
ARM Cortex-M3 TrainingRaghav Nayak
 
Msp 430 module 3
Msp 430 module 3Msp 430 module 3
Msp 430 module 3SARALA T
 
Wireless sensor network
Wireless sensor networkWireless sensor network
Wireless sensor networkNeha Kulkarni
 

What's hot (20)

IoT Control Units and Communication Models
IoT Control Units and Communication ModelsIoT Control Units and Communication Models
IoT Control Units and Communication Models
 
PROFIBUS frame analysis - Peter Thomas of Control Specialists
PROFIBUS frame analysis - Peter Thomas of Control SpecialistsPROFIBUS frame analysis - Peter Thomas of Control Specialists
PROFIBUS frame analysis - Peter Thomas of Control Specialists
 
Smart NIC
Smart NICSmart NIC
Smart NIC
 
ARM Processor
ARM ProcessorARM Processor
ARM Processor
 
RPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksRPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy Networks
 
LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...
LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...
LUCID Vision Labs -All-in-One Industrial Edge Computing with the Triton Edge ...
 
Uart
UartUart
Uart
 
Software Defined Network - SDN
Software Defined Network - SDNSoftware Defined Network - SDN
Software Defined Network - SDN
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
 
QoS in WSN thesis
QoS in WSN thesisQoS in WSN thesis
QoS in WSN thesis
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
 
SOC design
SOC design SOC design
SOC design
 
Arista Networks - Building the Next Generation Workplace and Data Center Usin...
Arista Networks - Building the Next Generation Workplace and Data Center Usin...Arista Networks - Building the Next Generation Workplace and Data Center Usin...
Arista Networks - Building the Next Generation Workplace and Data Center Usin...
 
Module 3 INTERNET OF THINGS
Module 3 INTERNET OF THINGSModule 3 INTERNET OF THINGS
Module 3 INTERNET OF THINGS
 
Fuzzing.pptx
Fuzzing.pptxFuzzing.pptx
Fuzzing.pptx
 
ARM Cortex-M3 Training
ARM Cortex-M3 TrainingARM Cortex-M3 Training
ARM Cortex-M3 Training
 
Alt Ağlar
Alt AğlarAlt Ağlar
Alt Ağlar
 
Msp 430 module 3
Msp 430 module 3Msp 430 module 3
Msp 430 module 3
 
Embedded Systems and IoT
Embedded Systems and IoTEmbedded Systems and IoT
Embedded Systems and IoT
 
Wireless sensor network
Wireless sensor networkWireless sensor network
Wireless sensor network
 

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

20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

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)