Your SlideShare is downloading. ×
Posix threads(asha)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Posix threads(asha)

1,170
views

Published on

Published in: Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,170
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. An Introduction to POSIX Threads
  • 2. Threads
  • 3. POSIX Threads (pthreads)‏
    • IEEE's POSIX Threads Model:
      • programming models for threads in a UNIX platform
      • pthreads are included in the international standards ISO/IEC9945-1
    • pthreads programming model:
      • creation of threads
      • managing thread execution
      • managing the shared resources of the process
  • 4. What are Pthreads?
    • Historically hardware vendors have implement their owm properietary versions ot threads.these implementation differed substantially from each other making it difficult for programmers to develop portable threaded applications.
    • In order to take full advantantage of the capabilities provided by threads,a standardised programming interface was required.
  • 5.
    • For unix system this interface be specified by the IEEE POSIX standard.
    • Implementation adhering to this standard are refferred to as posixthreads or pthreads.
    • Most hardware vendors how offer pthreads in addition to the proprietory API.
  • 6. Why Pthreads?
    • The primary motivation for using Pthread is to realize potential program performance gains.
    • When compared to cost of creating and managing process a thread can be created with much less operating system overhead..
    • Managing threads requires fewer system resources than managing process.
  • 7. Threads Programming Model
    • pipeline model – threads are run one after the other
    • master-slave model – master (main) thread doesn't do any work, it just waits for the slave threads to finish working
    • equal-worker model – all threads work
  • 8.
      • Supported by the Kernel
          • OS maintains data structures for thread state and does all of the work of thread implementation.
      • Examples
          • Solaris
          • Tru64 UNIX
          • Mac OS X
          • Windows 2000/XP/Vista
          • Linux version 2.6
    Kernel threads
  • 9. Solaris 2 Threads
    • Solaris 2 is a version of UNIX with support for threads at the kernel and user levels,SMP,and real-time scheduling..
    • solaris2 implements the pthread API for thread creation and management known as UI threads.
    • The differences between two libraries are insignificant, although most developers now opt for the Pthread library..
  • 10. Solaris 2 Threads
  • 11. Solaris 2 Threads
  • 12.  
  • 13.  
  • 14. Windows 2000 Threads
    • Windows 2000 implements the Win32 API.the Win32 API is the primary API for the family of Microsoft operating systems.
    • A windows application runs as separate process where each process may contain one or more threads.
    • Windows 2000 uses the one to one mapping where each user level thread maps to an associated kernel thread.
  • 15. The general components of thread include:
    • A thread ID uniquely identifying the thread.
    • A register set representing the status of the processor.
    • A user stack used when the thread is running is user mode.
    • A private storage area used by various runtime libraries and dynamic link libraries.
  • 16. The primary data structures of thread include:
    • ETHREAD(executive thread block).
    • KTHREAD(kernel thread block).
    • TEB(thread environment block)‏
  • 17.
    • The key components of the ETHREAD include a pointer to the process to which the thread belongs and the address of the routine in which the thread starts control. the ETHREAD also contains a pointer to the corresponding KTHREAD.
    • The KTHREAD includes scheduling and synchronization information for the thread. in addition, the KTHREAD includes the kernel stack and the pointer to the TEB.
  • 18.
    • The ETHREAD and the KTHREAD exist entirely in kernel space; this means only the kernel can access them. the TEB is a user-space structure that is accessed when the thread is running in usermode.among other fields, the TEB contains a user mode and an array for thread-specific data.
  • 19.  

×