Ring Buffer Project

by: burt rosenberg
at: university of miami
date: sep 2015
NAME
    ringbuffer -- implement the ring buffer "interface" and test
    
SYNOPSIS
    ringbuffer [-v] [-s _size_] _commands_
		
DESCRIPTION

    Creates a ring buffer of characters of size _size_ and applies the 
    enqueue/dequeue commands from string _commands_. The _commands_ string 
    is understood as follows: 
	
    For each character c in _commands_, in order, either:
        * enqueue the character c or
        * if c is the hyphen character, dequeue a character
          from the ring buffer

	After each command the program writes either "deq: _X_" or "enq: _X_" to 
	standard out, where _X_ is either the character enqueued or dequeued, or the
	words "empty" or "full", according to the result of dequeue or enqueue.
	
    The following options are available:
    
    -v verbose output
    -s ring buffer size. Default is 8.

HISTORY
    Introduced in csc421.161 to prepare for the in-kernel ring buffer 
    introduced in csc421.151.
    
BUGS
    
    

Goals

The goals of this project are:

Specific steps

  1. Check-out class/csc421.161 from svn.cs.miami.edu.
  2. Copy class/proj2 to [yourdirectory]/proj2; add and commit as "initial commit".
  3. Implement the body of all functions in the ringbuffer.c file.
  4. Test against the ringbuffer.ref until you get correct behavoir.
  5. Consider additional tests that may be run, making further improvements to ringbuffer.c if necessary.
  6. Commit for a grade by the due date.

Discussion

You have been provided with the structure "struct RingBuffer". This fields in this structure will be used to implement a ring buffer according the algorithm given here.

Implement by adding code to the bodies of the functions. The main program should be ok for the initial test of your program. I would suggest implementing the test functions rb_is_full and rb_is_empty early on — working on them will help you understand the data structure and its invariants.
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 08 sep 2015
update: 08 sep 2015