βͺοΈFunctions used
Remember printf
? Yeah right you recoded it yourself, that's good, but for this project, you can use the stdlib
one, the real one.
And you also have access to a lot of other functions, but you can't use your libft
for this project.
Some of these functions are only used for the bonus part, I didn't used them so I'll let you search how to use them. For this project you'll have to compile your programm with the -pthread
flag.
usleep()
int usleep(useconds_t usec);
usleep()
is a function in the C standard library that causes the calling process to sleep for a specified number of microseconds.
gettimeofday()
int gettimeofday(struct timeval *restrict tv, struct timezone *restrict tz);
The gettimeofday() function gets the systemβs clock time. The current time is expressed in elapsed seconds and microseconds since 00:00:00, January 1, 1970 (Unix Epoch).
You can find more information about gettimeofday() here.
pthread_create()
int pthread_create(pthread_t *restrict thread,
const pthread_attr_t *restrict attr,
void *(*start_routine)(void *),
void *restrict arg);
The pthread_create()
function starts a new thread in the calling process. The new thread starts execution by invoking start_routine()
; arg
is passed as the sole argument of start_routine()
.
You can find more information about pthread_create()
here.
pthread_join()
int pthread_join(pthread_t thread, void **retval);
The pthread_join() function waits for the thread specified by
thread to terminate. If that thread has already terminated, then
pthread_join() returns immediately. The thread specified by
thread must be joinable.
The pthread_join()
function waits for the thread specified by thread
to terminate. If that thread has already terminated, then pthread_join()
returns immediately.
You can find more information about pthread_join()
here.
pthread_mutex_init()
int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);
The pthread_mutex_init()
function initializes the mutex referenced by mutex
with the attributes specified by attr
. If attr
is NULL
, the default mutex attributes are used. When the mutex
is successfully initialized, the mutex state becomes initialized
and unlocked
.
You can find more information about pthread_mutex_init()
here.
pthread_mutex_destroy()
int pthread_mutex_destroy(pthread_mutex_t *mutex);
The pthread_mutex_destroy()
function destroys the mutex object referenced by mutex
. The mutex
object becomes uninitialized and can be reinitialized with pthread_mutex_init()
if needed.
You can find more information about pthread_mutex_destroy()
here.
pthread_mutex_lock()
int pthread_mutex_lock(pthread_mutex_t *mutex);
The pthread_mutex_lock()
function locks the mutex referenced by mutex
.
You can find more information about pthread_mutext_lock()
here.
pthread_mutex_unlock()
int pthread_mutex_unlock(pthread_mutex_t *mutex);
The pthread_mutex_unlock()
function unlocks the mutex referenced by mutex
.
You can find more information about pthread_mutex_unlock()
here.
Last updated
Was this helpful?