Reputation: 1287
In user-space we can create a process by executing program or calling fork inside a program, Kernel will create process descriptor(task_struct) for each user-space process.
In kernel space is there any any concept called process, if so how they will be created?
As per my understanding kernel threads will be created in kernel space using kernel_thread()
etc, kernel_thread()
is internally calling do_fork()
, so kernel threads also represented using task_struct
?
If both user-space process and kernel space threads are represented using task_struct
, then how scheduler will schedule the user-space process and kernel space thread?
Upvotes: 0
Views: 2746
Reputation: 92
Moreover I suppose that even POSIX threads which share the memory segments (e.g. heap, global varaibales ) with another threads, are handled by task_struct as well.
Upvotes: 1
Reputation: 11504
Yes, they all handled through task_struct
.
Critical kernel threads have RT ("Real-Time") scheduler class which have priority over CFS scheduler that is usually used for user-space threads. . Just check your ps:
# ps ax --format uname,pid,ppid,tty,cmd,cls,pri,rtprio | egrep '(FF|RR)'
(kernel threads are shown in square brackets)
However, as you can see many kernel threads have TS scheduler. I do not think that there is reason make all kernel threads realtime. For example, you can defer writeback to a disk over emotional scene shown by VLC player.
Upvotes: 2