Skip to content

jiasheng-li089/COSC440_assignment02

Repository files navigation

# About the project

The project implements a device driver, which reads data from the dummy device through the GPIO pins. It assembles the data read from the device, and then stores it in a circular buffer. After the length of the data in the circular buffer is larger than half of the buffer's capacity, or a delimiter is appended to the buffer. A tasklet will be triggered to migrate the data in the circular buffer to an endless buffer.

User applications can open the device file and read the data in the buffer. If there is no data in the buffer, the user process will be paused until new data arrives or a singel is sent to it. Once user application finishes reading the data before an delimiter, it cannot read data any more. The data left only can be read until the device file is closed and reopened again.


# Build, Run, and Test

Instructions to build the project:
`make clean && make all`

Instructions to run the module:
`sudo insmod asgn.ko`

Instructions to test:
`sudo ./data_generator <file1> <file2> ... <filen>`
`cat /dev/asgn2`    // execute this command multiple times to read all the data generated by the dummy device

# Comments on the source code
include/mem_cache.h src/mem_cache.c:    The memory management module, which applies the whole page of memory for memory reusing.
include/circular_buffer.h src/circular_buffer.c:    The implementation of the circular buffer, which uses a fixed size of memory to store data.
include/page_buffer.h src/page_buffer.c:    The implementation of the endless buffer, which applies a new page of memory to store data if there is no enough space, and releases the page of memory after the data in it is read.
include/delimiter_buffer.h src/delimiter_buffer.c:  The wrapper of the endless buffer. Only the data before an delimiter can be read until the function `dbuffer_end_phase_reading` is called.
include/gpio_reader.h src/gpio_reader.c:    The management of the GPIO device.
src/asgn2.c:    The main file of this Linux module.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages