0

I have read this Linux - Threads and Process

I understood that every kernel threads have unique task_struct

But Right now my question is that how kernel manage user application's thread, suppose any user application have 12 thread then how kernel manage them and every thread have unique task_struct like kernel threads

Community
  • 1
  • 1

1 Answers1

0

The kernel manages them when it can, ie. whenever it is entered from an 'interrupt' that changes the state of the threads.

There are two flavours of interrupt: either a syscall from a running thread, or a call from a driver that has been entered from a 'real' hardware interrupt from KB, NIC, disk, timer etc, can change the state of threads and initiate a sceduling algorithm run that may change the set of threads to run on the available cores.

In between interrupts, the kernel manages nothing because it is not entered.

The task_struct is raised when a running thread makes a syscall to create a new thread. The new thread is created ready, and will run whenever the scheduling algorithm dispatches it onto a core.

Martin James
  • 24,453
  • 3
  • 36
  • 60