This Linux kernel module implements a producer-consumer design pattern using kernel threads. The module reads information about processes started by a user in a producer thread and calculates the time elapsed for each process in a consumer thread
-
Cloning the Repository:git clonehttps://github.com/CSE330-FALL-2023/Project-1-Template.git
-
Writing the Code:
- Developed the kernel module
producer_consumer.c
based on the problem statement. - Used module_param() for passing arguments.
- Used Semaphore and Mutex (for critical sections).
- Properly acquire and release Mutex.
- Properly signal Semaphores uning up, down on full and empty.
- Copy task info into buffer.
- Read from buffer in consumer.
- Define start_time_ns and process_pid using the read data from buffer.
- Initialize Semaphores and Mutex.
- Create producer threads.
- Create consumer threads.
- Store the id in ctx_producer_thread and ctx_consumer_thread respectively.
- Changed incompatible up(&mutex) to up(empty) in the provided code.
- Developed the kernel module
-
Modifying the Code:
- Made adjustments to resolve errors and improve code structure based on errors during testing.
- Changed Initial Licence from GPLv3 to GPL as ktime_get_ns() is GPL only.
- Defined start_time_ns currectly to get correct times
-
Testing:
- Compiled the kernel module using the provided Makefile.
- Used the provided
test.sh
script to automate testing and verify the behavior of the module.
producer_consumer.c
: Contains the implementation of the producer consumer kernel module.
-
Compilation:
- Run
make
command in the terminal to compile the kernel module. - This generates the module file
producer_consumer.ko
.
- Run
-
Testing:
- Execute the
test.sh
script with 5 parameters to perform automated testing. These are- number of processes for the test user
- Buffer size
- Number of Producers
- Number of Consumers
- Number of lines from dmesg to display
- Do this 6 times for six test cases
- Execute the
Reviews
There are no reviews yet.