Kernel Ring Buffer Project

by: burt rosenberg
at: university of miami
date: oct 2018
  

NAME
    rb_ioctl, rb_enqueue, rb_dequeue -- ring buffer syscalls
    ringbuf -- command line interface to the rb_* system calls
    
SYNOPSIS
    rb_enqueue enqueues characters to a single, in-kernel ring buffer; re_dequeue 
    dequeues an enqueued character. rb_ioctl implements the control functions return
    if the queue is empty or full, depending on the control argument.

DESCRIPTION
    The rb_enqueue syscall takes a single character argument and returns the argument
    if the character can be enqueued, -1 else. For instance, it will return -1 if the
    ring buffer is full. 
    
    The rb_dequeue syscall takes no arguments are returns a single integer value, which
    is the dequeued character, -1 else. For instance, if will return -1 if the ring 
    buffer is empty.
    
    The rb_ioctl takes an integer argument giving the operation, as follows:
    
    Argument value:
        0 - return the size of the ring buffer.
    	1 - return 1 if ring buffer is empty, 0 else.
    	2 - return 1 if ring buffer is full, 0 else.
    	3 - return the current number of characters in the ring buffer
	
    On error, or an invalid argument value, return -1.
	
    The ring buffer is of fixed size. The kernel needs to be rebuilt if the ring buffer 
    is to be of a different size. For this project, the size is 16.
    

HISTORY
    Introduced as Project 2 in CSC 421 session 151.
    Made independent Project 4 in csc 421 session 191.

BUGS
    The code might not be thread safe.

Goals

The goals of this project are:

Specific steps

  1. Build the linux kernel. Here are hints.
  2. Modify the kernel files to introduce the system calls. Here are hints.
  3. Rebuild and reboot on the new kernel.
  4. Using the given template files from the class/proj4 folder.
  5. Implement the ringbuffer system call by modifying the mysyscalls.c file in the kernel. Your work in project 2 is relevant.
  6. Rebuild and reboot on the new kernel.
  7. Implement the user interface in ringbuf-sub.c. Build ringbuf and test.

Testing and submission

Test-ringbuf runs the ringbuffer test and saves the output to ringbuf.out. The test is the same as project 1, and the provided ringbuf.ref is identical to the one used in project 1. Note however that the implement should be by syscalls to code in the kernel. Because the ring buffer is persistent between runs of ringbuf, it must be emptied for the test. The Empty-ringbuf makefile target empties the ringbuffer by performing 16 dequeue operations.

You will submit "evidence" that your project ran, as well as the sources so that we can reproduce your project.

The makefile target evidence collects the evidence into an evidence.tar file, which you will add and commit to the repository. The evidence includes of the 5 kernel files and the output file:

You must add and commit the complete set of sources that built and tested your project: Commit all, even though you might have only modified ringbuf-sub.c.

Discussion

Please refer to the in-class discussion concerning this project.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 27 sep 2015
update: 1 oct 2018