There is no implied hierarchy or dependency between threads. Once created, threads are peers, and may create other threads.The maximum number of threads that may be created by a process is implementation dependent.NULL may be used if no argument is to be passed. While using fork() causes execution to continue in the same location with a different return code, using a new thread explicitly provides a pointer to a function where the new thread should start executing.Ī single argument that may be passed to start_routine. So, we can pass any type of single argument and return a pointer to any type. We should pass the address of a function taking a pointer to void as a parameter and the function will return a pointer to void. The routine that the thread will execute once it is created. We can specify a thread attributes object, or NULL for the default values. This identifier enables us to refer to the thread.Īn attribute object that may be used to set thread attributes. When a thread is created, an identifier is written to the memory location to which this variable points. This is a pointer to pthread_t structure. pthread_create (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) arguments:Īn identifier for the new thread returned by the subroutine.This routine can be called any number of times from anywhere within our code.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |