POSIX threads: Function calls in Pthreads package

POSIX standard has defined a thread package known as Pthreads. Each thread in a Pthreads package has an identifier, registers, program counter and attributes. The attributes include stack size, scheduling parameters, etc. Here are the function calls in Pthreads:

  • Pthread_ create: It is used for creating a new thread.
  • Pthread_ exit: It is used for terminating the calling thread.
  • Pthread_ attLinit: It is used for creating and initializing attribute structure of a thread.
  • Pthread_attr_destroy: It is is used for removing the attribute structure of a thread and freeing its memory.
  • Pthread_ join: This call is used by a thread which is waiting for a particular thread to exit.
  • Pthread_ yield: It is used by a thread to release the CPU for another thread to run.

Here is a program which uses Pthreads:

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void *print_more_process(void *tid)
printf(“More Process %d\n, tid);
int main(int argc, char *argv[ ])
pthread_t threads[NUMBER_THREADS];
int status, i;
for(i=0; i < NUMBER_THREADS; i++) {
printf(“Creating thread %d/n, i);
status = pthread_create(&threads[i], NULL, print_more_process, (void *)i);
if (status != 0) {
printf(“Error! %d\n, status);
exit( -1 );

Leave a Reply