How does one create a Kernel Thread using Posix library?
POSIX doesn't specify whether threads are implemented in userspace or the kernel - that's up to the implementation.
So the answer is: pthread_create
, as long as your implementation does use kernel threads. If you're using glibc on Linux, you'll be fine.
You can't.
pthreads are for use in userland processes not the kernel. kernel threads are far more "lightweight" than pthreads (e.g. have very small fixed length stacks). kthread_create is used to create kernel threads in linux.
Just to give you little background, Other OS'es had processes and threads in kernel like solaris,windows etc. But linux didn't implement threads in linux kernel, instead they provided option to pass flags which allow processes to share the VM, Open files etc..
Hope this helps.