Reputation: 415
While doing an assignment on Pthread Scheduling API for Operating Systems course. I came across a function which looks like this:
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg);
Can someone please explain what does the second last function parameter mean in terms of syntax? i.e.
void *(*start_routine) (void *)
Upvotes: 0
Views: 46
Reputation: 121407
void *(*start_routine) (void *)
is a pointer to a function that takes a void*
as an argument and returns a void*
.
Generally, you can use cdecl.org to read complex C declarations. For void *(*start_routine) (void *)
, it says:
declare start_routine as pointer to function (pointer to void) returning pointer to void
In Pthreads, the function pointer passed as an argument to pthread_create()
is the thread function, which is run (depending on how OS schedules) after pthread_create()
call succeeds.
See here for a simple example of how to use pthread_create()
and the thread function.
Upvotes: 1