jagomart
digital resources
picture1_1 Othersm


 149x       Filetype PDF       File size 0.41 MB       Source: www.csc.villanova.edu


File: 1 Othersm
posix threads pthreads for shared address space programming pthreads posix threads package available on almost all machines portable standard sort of like doing parallel not parallel for in openmp explicitly ...

icon picture PDF Filetype PDF | Posted on 04 Feb 2023 | 2 years ago
Partial capture of text on file.
    POSIX Threads (Pthreads) for 
      Shared Address Space 
        Programming
         Pthreads
         • Posix threads package
            • Available on almost all machines (portable standard)
            • Sort of like doing “parallel” (not “parallel for”) in OpenMP explicitly
         • Basic calls:
            • pthread_create: creates a thread, to execute a given function
            • Pthread_join
            • barrier, lock, mutex
            • Thread private variables
         • Many online resources:
            • E.g., https://computing.llnl.gov/tutorials/pthreads/
                                                   L.V.Kale                                      2
        Pthreads–Create and Join
        • Spawn an attached thread                           • Detached threads
        pthread_create                                           • Join is not needed
          (&thread1, NULL, foo, &arg)                            • The OS destroys thread 
                       .                                           resources when they 
                       .                                           terminate
                       .                                         • A parameter in the create 
        pthread_join(thread1, status)                              call indicates a detached 
                                                                   thread
        • Thread execution
        void foo(&arg)
        {  // Thread code
            return(*status);
        }
                                                  L.V.Kale                                     3
           Executing a Thread 
                                    Main Program 
                                           .                                                                              T
                                           .                                               Thread1                        hr
                                                                                                                          e
                                           .                                                                              a
                                           .                                       void * func (void *arg)                d1
                                                                                                                           
                                                                                                                          s
                    pthread_create(&thread1, NULL, func, &arg);                      {                                    t
                                                                                                                          a
                                           .                                                   .                          c
                                           .                                                   .                          k
                                           .                                                   .
                                           .                                                   .
                                                                                        return (status);                  M
                            pthread_join(thread1, status);                           }                                    a
                                                                                                                          i
                                           .                                                                              n 
                                                                                                                          s
                                                                                                                          t
                                           .                                                                              a
                                                                                                                          c
                                           .                                                                              k
                                           .
                                                                 L.V.Kale                                                   4
The words contained in this file might help you see if this file matches what you are looking for:

...Posix threads pthreads for shared address space programming package available on almost all machines portable standard sort of like doing parallel not in openmp explicitly basic calls pthread create creates a thread to execute given function join barrier lock mutex private variables many online resources e g https computing llnl gov tutorials l v kale and spawn an attached detached is needed null foo arg the os destroys when they terminate parameter status call indicates execution void code return executing main program t hr func d s c k m i n...

no reviews yet
Please Login to review.