Reputation: 1235
I am looking at this example code in http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html
In this example, why pthread_self could be used without pthread_create? I thought a program needs to call pthread_create to create a pthread then calls pthread_self to return the pthread id.
Upvotes: 0
Views: 199
Reputation: 6875
pthread_create
is used to create a new (usually worker) thread. pthread_self
is used to return thread identifier of the thread which calls it. It can also be the main thread.
Upvotes: 2