Unformatted Attachment Preview
Implementation of Kernel
Threads are lightweight processes, which are the basic unit of CPU initialization. To create and
manage threads we use thread libraries with an API. Support for threads must be provided either at
the user level or by the kernel. Kernel level threads are supported and managed directly by the
operating system. Whatever the functions carried by the User level threads are managed exclusively
in User space without Kernel support or intervention. Any function invoked in the API typically results
in a system call to the kernel. The limitations with the user threads are that the user-level thread
makes a blocking I/O request, the kernal serving as its virtual processor also blocks. This results in
the entire process being blocked. The solution for this problem is to implement more Kernel threads
than physical processors. When one kernel thread blocks because its user-level thread blocks in the
kernel, another kernel thread is available to run user-level threads on that processor. As it is
interesting to know that Kernel has full knowledge of all threads, schedulers may decide to give more
CPU time to a process having many threads. And it is good for the applications that are frequently
The trace of the proposal document will include motivation and project details with conclusion and
What is the history of the problem? The user level threads are above the user space and are
managed without the support of the kernel. As the user level threads are not managed by the
operating systems directly the user level threads cannot make the system calls to the operating
systems. ● For any function the kernel thread makes a system call to execute. When a kernel thread
is not implemented in the kernel space the user level threads cannot make a system call on their own
to the operating system and a kernel level thread is required. ● When a user level requests for the
service to the operating system as process creation, memory management, etc. the kernel thread
steps in and coordinates with the user level threads to make the system call to the operating system.
If there are no kernel threads implemented in the kernel space, then the user level threads cannot
make a system call. ● Is the problem already solved? What is done now? The problem is solved by
implementing the kernel thread using the one-one model where one user level thread is mapped to
one kernel level thread and with this the processes will be not affected when one user level thread
makes a blocking system call. ● There are similar solutions to the present proposal. In windows and
Linux operating systems the one to one model is already being used where one user level thread is
mapped to the one kernel level thread. Windows has the thread kernel object, and this is used to
manage and execute the threads across the system. The kernel object is where the system keeps all
the information regarding the thread. The operating system has two types of stack that is user mode
stack and kernel mode stack which is used for maintaining the local variables of the functions and to
pass the arguments to the functions for executing the thread.
In this project we will be adding the kernel threads in the Linux operating system to define a system
call to create a kernel thread using the clone() function. We will be using the join() function to wait
for the thread and we will be using the kthread_create() to create a kernel thread. In this project the
spin lock is used where we will initialize the lock with two routines “lock_acquire” and “lock_release”.
Architecture and Environment- Linux Operating System – Version
In Kernel Space each User thread has one kernel thread accordingly. In
this proposal we can limit how many threads can be created. Linux and
Windows implement one to one model for threads.
code does not use the libraries from the user space. So, we need to give the command
line options to gcc to not take the standard libraries. In order to build a kernel module, we need to
have the kernel source code which is usually found at /usr/src/linux.
is the API for creating kernel
kthread_create(int (*function)(void *data), void *data, const char
creates a new kernel thread. Can be called from any process context but
not from interrupt. The functions block until the thread started.
stop the thread. Can be called from any process context but the thread
to be terminated. Cannot be called from interrupt context. The function blocks until
the thread terminates.
sets the environment of the new threads. Is to be called out of the
needs to be called by the thread to be terminated on
Implementing kernel threads are quite complex in nature. The greater number of kernel threads
more load on the scheduler. In our project we are trying to showcase that the less number kernel
threads are created in order to elevate the functionality of the kernel threads for system calls.
The following are the deliverables in this project which will be produced over the
timeline• Program code to implement the kernel
o Importing kernel headers. o Includes various functions like kthread_Create(), join(),
clone(), lock_acquire(), lock_release()
• Output report.
• Our project main idea is to implement kernel threads by creating a kernel thread and making
a system call.
As the user level threads cannot make the system calls to the operating system directly in this project
we are implementing the kernel threads with the clone() to make the system calls using the one to
one model where one user thread is mapped to the one kernel thread.