003 Linux System ProgrammingIssues, queries and suggestions related to Linux, Linux Programming, IPC, Interprocess Communication, Synchronization, Semaphore, System Programming, Linux Software Development. » 003.11.POSIX-Threads
when pthread_create() is called the operating system allocate resource for new threads such as stack and thread control box,then kernel initializes the thread and give it to scheduler for execution .The newly creted thread executes the function provided as start routine
int pthread_create(pthread_t *thread,attributes,void* (*start_routine),(void*)arg)
first argument is pointer of type pthread_t it assign unique ID to thread and store it to memory location pointed by first argument. This thread id is used to uniquely identify the each thread within the process.
second arguments is attributes to thread which specifies the thread behavior and properties like what is the stack size for the thread ,whether thread is joinable or detached threads.
Third arguments is function pointer to thread function that contain routines or task which thread is intended to perform.
fourth arguments is function arguments that is to passed to threads function if it is required input data to perform its task.