Implementation of kernel threads

Computer Science

VSU

Question Description

I need a project on the implementation of kernel threads(operating systems) and I have attached the abstract for the details. I need the project to be done in xv6 operating system without using the predefined libraries. Our project deadline is on April 26th Kindly respond us ASAP.

Unformatted Attachment Preview

Implementation of Kernel Threads Introduction: 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 blocked. The trace of the proposal document will include motivation and project details with conclusion and references. Motivation: 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. Project Summary: 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”. Project Details: Architecture and Environment​- ​Linux Operating System – Version 3.13.0 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. Implementation: • ​kernel 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. • ​Below is the API for creating kernel thread: #include kthread_create(int (*function)(void *data), void *data, const char name[], ...) • start_kthread​: creates a new kernel thread. Can be called from any process context but not from interrupt. The functions block until the thread started. • stop_kthread​: 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. • init_kthread​: sets the environment of the new threads. Is to be called out of the created thread. • exit_kthread​: needs to be called by the thread to be terminated on exit. Issues and Challenges: 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. Deliverables: The following are the deliverables in this project which will be produced over the timeline• Program code to implement the kernel threads o Importing kernel headers. o Includes various functions like kthread_Create(), join(), clone(), lock_acquire(), lock_release() etc . • Output report. • Our project main idea is to implement kernel threads by creating a kernel thread and making a system call. Conclusion: 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. References: [1] http://faculty.cs.tamu.edu/bettati/Courses/410/2014A/Slides/threads .pdf [2] https://lwn.net/Articles/65178/ [3] https://www.cs.princeton.edu/courses/archive/fall11/cos318/lectures/L5_ThreadsImplementati on.pdf [4]​https://www.researchgate.net/post/in_user_level_thread_when_one_high_level_thread_preempt_lo w_level_thr ead_then_how_CPU_context_is_switched_without_the_involvement_of_kernel [5] https://www.quora.com/What-is-a-kernel-thread-How-do-you-creat e-it [6] https://github.com/remzi-arpacidusseau/ostep-projects/tree/master/concurrency-xv6-t hreads [7] http://pages.cs.wisc.edu/~remzi/OSTEP/threads-locks. pdf ...
Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.
Tags: VSU

This question has not been answered.

Create a free account to get help with this and any other question!