MyOS Libc
pthread.h File Reference
#include <sys/types.h>

Go to the source code of this file.

Typedefs

typedef pid_t pthread_t
 Represents a thread.
 
typedef int pthread_attr_t
 Created as dummy.
 
typedef int pthread_spinlock_t
 Represents a spinlock.
 

Functions

int pthread_create (pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg)
 
void pthread_exit (void *value_ptr)
 
int pthread_spin_init (pthread_spinlock_t *lock, int pshared)
 
int pthread_spin_lock (pthread_spinlock_t *lock)
 
int pthread_spin_unlock (pthread_spinlock_t *lock)
 
int pthread_spin_destroy (pthread_spinlock_t *lock)
 

Function Documentation

◆ pthread_create()

int pthread_create ( pthread_t *restrict  thread,
const pthread_attr_t *restrict  attr,
void *(*)(void *)  start_routine,
void *restrict  arg 
)

Create a thread in the current process

Parameters
threadA pointer to a pthread_t where the created thread will be placed
attrEither a pointer to a thread attribute structure, or NULL, in which case the default attributes will be used
start_routineThe start function of the thread
argAn arhument to the start function
Returns
0 if creation was sucsessful, 1 otherwise

◆ pthread_exit()

void pthread_exit ( void *  value_ptr)

Terminate the current thread

Parameters
value_ptrA pointer that when other threads in the process join on the current thread, they will recieve. (not implemented)

◆ pthread_spin_destroy()

int pthread_spin_destroy ( pthread_spinlock_t lock)

Destroys a spin lock

Parameters
lockThe spinlock to destroy
Returns
0 on success, 1 on failure

◆ pthread_spin_init()

int pthread_spin_init ( pthread_spinlock_t lock,
int  pshared 
)

Initializes a spin lock

Parameters
lockThe spinlock to initialize
psharedUnused
Returns
0 on success, 1 on failure

◆ pthread_spin_lock()

int pthread_spin_lock ( pthread_spinlock_t lock)

Locks a spin lock

Parameters
lockThe spinlock to lock
Returns
0 on success, 1 on failure

◆ pthread_spin_unlock()

int pthread_spin_unlock ( pthread_spinlock_t lock)

Unlocks a spin lock

Parameters
lockThe spinlock to unlock
Returns
0 on success, 1 on failure