Author: Arpit Savarkar
Contains Code for Assignment 2 for PES, ECEN-5813, Fall 2020
Repository for PES-Assignment 1
- llfifo.h - Header file which contains the function prototypes and enumerators needed for llfifo.c
- llfifo.c - The main script for instantiating and testing a linkedlist based Queue
- cbfifo.h - Header file which contains the function prototypes and enumerators needed for cbfifo.c
- cbfifo.c - The main script for instantiating and testing a Circular Buffer based Queue
cbfifo.h Involves Four Functions and Unit Tests and helper functions for the following
- cbfifo_enqueue(void *buf, size_t nbyte
- Returns the number of bytes requested to be enqueued on a linkedlist based implementation of a linkedlist. Enqueues data onto the FIFO, up to the limit of the available FIFO capacity The number of bytes actually enqueued, which could be 0. In case of an error, returns -1.
- cbfifo_dequeue(void *buf, size_t nbyte)
- Attempts to remove ("dequeue") up to nbyte bytes of data from the FIFO. Removed data will be copied into the buffer pointed to by buf. Returns The number of bytes actually copied, which will be between 0 and nbyte. In case of an error, returns -1.
- cbfifo_length()
- Returns the Number of bytes currently available to be dequeued from the FIFO
- cbfifo_capacity()
- Returns the capacity, in bytes, for the FIFO
==========================================================================================================
- llfifo_create(int capacity)
- Initializes the FIFO and A pointer to an llfifo_t, or NULL in case of an error.
- llfifo_enqueue(llfifo_t *fifo, void *element)
- Enqueues an element onto the FIFO, growing the FIFO by adding additional elements, if necessary. The new length of the FIFO on success, -1 on failure
- llfifo_length(llfifo_t *fifo)
- Returns the number of elements currently on the FIFO.
- llfifo_dequeue(llfifo_t *fifo)
- Removes ("dequeues") an element from the FIFO, and returns it
- llfifo_capacity(llfifo_t *fifo)
- Returns The current capacity, in number of elements, for the FIFO
- llfifo_destroy(llfifo_t *fifo)
- Teardown function. The llfifo will free all dynamically allocated memory. After calling this function, the fifo should not be used again!
This assignment demonstrates C Programming from scratch for data representation conversion and FIFO Based implementation using both LinkedList and Ciruclar Buffer, it also demonstrates a code for testing the specified data structures.
- To run the Program (Linux) :
- make
- ./main