Question: Description In this project, you will implement a kernel module that launches multiple kernel threads and implement semaphores in these threads. To make the project

Description
In this project, you will implement a kernel module that launches multiple kernel threads and
implement semaphores in these threads. To make the project interesting and to prepare for the
next project, we will implement two types of threads: producer threads and consumer threads.
Both types of threads work in infinite loops until the module is unloaded.
1. Implement a new module
You MUST name your module producer_consumer.
It takes three arguments and you MUST name your input parameters for the kernel module
as follows such that the test script can load the kernel module successfully. Failure to do so,
your kernel module will not be loaded by the automated test script and you will receive
zero grade points.
a. prod: int, number of producer threads (a non-negative number)
b. cons: int, number of consumer threads (a non-negative number)
c. size: int, initializes the counting semaphore (a non-negative number)
Note that the number of producer/consumer threads can be zero.
2. Create and start kernel threads
Use the kthread_run() function in your module to create and start the kernel threads. You
will need to start prod number of producer threads and cons number of consumer threads.
/* threadfn is the function to run in the thread;
* data is the data pointer for threadfn; namefmt is the name for the
thread. It returns a pointer to the thread's task_struct if the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!