5

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.

Node.JS
  • 1,042
  • 6
  • 44
  • 114
  • 4
    POSIX doesn't recognize a difference — [`pthread_create()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html) creates a new thread, that's all. So, the question will become: what do you mean by kernel vs user thread? What are you hoping to achieve, and why? – Jonathan Leffler Oct 04 '14 at 00:43

1 Answers1

6

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.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711