Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a user level thread or kernel level thread using `pthread_create`?

Question: How can one create a user level thread or kernel level thread using pthread_create?

Note: I checked the documentation of pthread_create in this link and I didn't find any parameter that can be specified to tell OS to create either user level thread or the kernel level thread. So if there is no parameter then when thread created using pthread_create by default is user level or kernel level?

Any information or hint would be great.

Thanks.

like image 514
Node.JS Avatar asked Oct 15 '25 16:10

Node.JS


1 Answers

pthread_create simply creates a thread. Not "a kernel-level thread" or "a user-level thread". The latter are descriptions you could use talking about implementation of threads, but as far as POSIX threads are concerned, there is no practical way to implement threads without each thread having some corresponding scheduling/state object belonging to the kernel. This is because each thread has independent signal mask, pending signals, etc. and can be independently blocked in various operations that allow other threads to make forward progress while they are blocked. So in some sense, you could say pthread_create creates "kernel level threads". That's certainly the mechanism in all major real-world implementations.

like image 179
R.. GitHub STOP HELPING ICE Avatar answered Oct 18 '25 06:10

R.. GitHub STOP HELPING ICE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!