jagomart
digital resources
picture1_Tradsfuncs


 108x       Filetype PDF       File size 0.07 MB       Source: twiki.di.uniroma1.it


File: Tradsfuncs
posix thread programming 1 topics to be covered objective posix threads what are threads creating threads using threads summary 2 creating threads always include pthread library include int pthread create ...

icon picture PDF Filetype PDF | Posted on 03 Feb 2023 | 2 years ago
Partial capture of text on file.
 
      POSIX Thread Programming
                                                 1
            Topics to be Covered
    • Objective
    • POSIX threads
    • What are Threads?
    • Creating threads
    • Using threads
    • Summary
                                                  2
                        Creating threads
      •  Always include pthread library: 
         #include 
         int pthread_create (pthread_t *threadp, const 
         pthread_attr_t * attr, void *(* start routine)(void *), void 
         *arg);
      •  This creates a new thread of control that calls the function 
         start_routine.
      •  It return a zero if the creation is successful, and thread id 
         in threadp (first parameter).
      •  attr is to modify the attributes of the new thread. If it is 
         NULL, default attributes are used.
      •  arg is to pass arguments to the thread function.
                                                                                3
                   Using threads
    1. Declare a variable of type pthread_t
    2. Define a function to be executed by the thread.
    3. Create the thread using pthread_create
      Make sure creation is successful by checking 
      the return value.
    4. Pass any arguments need through’ arg (packing 
      and unpacking arg list if needed)
    6. Compile: cc –o xyz xyz.c 
    {+ options such as -lpthread}
                                                        4
The words contained in this file might help you see if this file matches what you are looking for:

...Posix thread programming topics to be covered objective threads what are creating using summary always include pthread library int create t threadp const attr void start routine arg this creates a new of control that calls the function it return zero if creation is successful and id in first parameter modify attributes null default used pass arguments declare variable type define executed by make sure checking value any need through packing unpacking list needed compile cc o xyz c options such as lpthread...

no reviews yet
Please Login to review.