A POSIX thread or p-thread is a light-weight process which is tied directly to another parent process.

As a result these p-threads all share the same region of memory.


API

Creation

A p-thread can be created with the following C API function definition:

#include <pthread.h>
 
// Start a new pthread
int pthread_create(
  pthread_t *thread, // the returned thread index
  const pthread_attr_t *attr, // thread settings
  void *(*start_routine)(void*), // the function to run in the thread
  void *arg // arguments to pass to the thread
);

Wait on a thread

A p-thread can be blocked on with the following C API function definition:

#include <pthread.h>
 
// Start a new pthread
int pthread_join(
  pthread_t thread, // the thread to wait on
  void **value_ptr // pointer to the outputs returned by the thread
);

Exit a thread

A p-thread can be exited with the following C API function definition:

#include <pthread.h>
 
// Start a new pthread
int pthread_exit(
  void *value // the data to return to the awaiter
);