Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between kernel threads and user threads?

What is the difference between kernel threads and user threads? Is it that kernel thread are scheduled and executed in kernel mode? What are techniques used for creating kernel threads?

Is it that user thread is scheduled, executed in user mode? Is it that Kernel does not participate in executing/scheduling user threads? When interrupts occur in executing user thread then who handles it?

Whenever, thread is created a TCB is created for each. now in case of user level threads Is it that this TCB is created in user's address space ?

In case of switching between two user level threads who handles the context switching ?

There is a concept of multithreading models :

  1. Many to one
  2. One to one
  3. Many to Many.

What are these models? How are these models practically used?

Have read few articles on this topic but still confused
Wants to clear the concept ..

Thanks in advance, Tazim

like image 890
tazim Avatar asked Feb 02 '23 21:02

tazim


2 Answers

Wikipedia has answers to most if not all of these questions.

http://en.wikipedia.org/wiki/Thread_(computer_science)

http://en.wikipedia.org/wiki/Thread_(computer_science)#Processes.2C_kernel_threads.2C_user_threads.2C_and_fibers

like image 136
EmeryBerger Avatar answered Feb 05 '23 17:02

EmeryBerger


What is the difference between kernel threads and user threads?

Kernel threads are privileged and can access things off-limits to user mode threads. Take a look at "Ring (Computer Security)" on Wikipedia. On Windows, user mode corresponds to Ring 3, while kernel mode corresponds to Ring 0.

What are techniques used for creating kernel threads?

This is extremely dependent upon the operating system.

now in case of user level threads Is it that this TCB is created in user's address space ?

The TCB records information about a thread that the kernel uses in running that thread, right? So if it were allocated in user space, the user mode thread could modify or corrupt it, which doesn't seem like a very good idea. So, don't you suppose it's created in kernel space?

What are these models? How are these models practically used?

Wikipedia seems really clear about that.

like image 29
Jeff Avatar answered Feb 05 '23 15:02

Jeff