Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Kernel Threads - scheduler

Is Linux Kernel scheduler a part of init process? My understanding is that it is part of Kernel threads managed internally not visible to user by either top or ps. Please correct my understanding.

Is it possible to view standard kernel threads through any kernel debugger to see how standard threads occupy cpu activity?

-Kartlee

like image 681
Kartlee Avatar asked Mar 12 '10 06:03

Kartlee


People also ask

How are kernel threads scheduled?

The kernel scheduler takes care of scheduling the threads, just like it schedules regular processes. The threads are created with the Linux clone() system call, which is a generalization of fork() allowing the new process to share the memory space, file descriptors, and signal handlers of the parent.

How are threads scheduled in Linux?

Scheduling of threads involves two boundary scheduling, Scheduling of user level threads (ULT) to kernel level threads (KLT) via lightweight process (LWP) by the application developer. Scheduling of kernel level threads by the system scheduler to perform different unique os functions.

What scheduler is used in Linux kernel?

O(1) Scheduler was introduced in LINUX Kernel 2.6. O(1) scheduler is also called as Big O of 1 scheduler or constant time scheduler. As the name suggests, it can schedule the processes within a constant amount of time, regardless of the number of processes running on the system. O(1) scheduler uses two queues.

Does Linux schedule threads or processes?

The Linux kernel scheduler is actually scheduling tasks, and these are either threads or (single-threaded) processes. A process is a non-empty finite set (sometimes a singleton) of threads sharing the same virtual address space (and other things like file descriptors, working directory, etc etc...).


1 Answers

Kernel threads can be seen through "top" and "ps" and can be distinguished by having zero VM size (they have no userspace, so no userspace memory map).

These are created by kernel_thread (or its friends). Some facilities create one thread per CPU and tie it to a CPU, so you see stuff like aio/0 aio/1 on the PS list.

Also some work is done through the several deferred execution mechanisms and gets attributed to other tasks, typically something called "events/0" (one per CPU). Time spent "really" in interrupts isn't counted anywhere (it just runs at the expense of whatever task happened to be on that CPU at the time).

like image 176
MarkR Avatar answered Nov 14 '22 22:11

MarkR