Question

I want to implement circular FIFO buffer in C. While I was searching for code samples on Google I found this link. I don't understand is this mean that the concept of circular FIFO buffer is patented and everyone who want to use it must have a license?

Best wishes

Was it helpful?

Solution

IANAL

No, FIFOs in software are not patented (there were no software patents when the first FIFO algorithm was invented - I'm not sure of the exact dates but software patents are a phenomenon of the 1990's and I used FIFOs on the C64 in 1983).

What is patented by the patent is a hardware chip that contains a FIFO and which has certain characteristics, especially that "multiple transfers are performed during one bus cycle".

So this is not your general 16550 UART (which can do only a single transfer per clock cycle).

Generally, a lot of code that you writer every day is patented. Usually, this is not an issue because your company isn't on the radar of the owner of the patent. But the day they decide that they don't like you anymore, you're in big trouble unless you can spend a couple of hundreds of millions of dollars for lawyer fees to defend yourself in court or you have a huge stack of silly patents yourself which you can use to fight back.

I collected some some articles that you might want to read:

OTHER TIPS

typedef struct red
{
   int niz[MAX]; 
   int f, r;
} RED;

int insert(RED buf, int info)
 {
 if (isFull(buf)) 
 buf->f = (buf->f + 1) % MAX;
 buf->r = (buf->r + 1) % MAX;
 buf->niz[buf->r] = info;
 return 1; }
// circular_queue.cpp : main project file.

#include "stdafx.h"

using namespace System;

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

#define max 3

int q[10];
int front=0;
int rear=-1;

int main()
{
    int ch;
    void insert();
    void delet();
    void display();
   // clrscr();
    printf("\n Circular Queue operations\n");
    printf("1.insert \n 2.delete \n 3.display \n 4.exit \n");
    while(1)
    {
        printf("Enter your choice:");
        scanf("%d",&ch);
        switch(ch)
        {
        case 1: insert();   break;
        case 2: delet();    break;
        case 3: display();  break;
        case 4:exit(0);
        default:printf("Invalid option\n");
        }
    }

    return 0;
}

void insert()
{
    int x;
    if((front==0&&rear==max-1)||(front>0&&rear==front-1))
        printf("Queue is overflow\n");
    else
    {
        printf("Enter element to be insert:");
        scanf("%d",&x);
        if(rear==max-1&&front>0)
        {
            rear=0;
            q[rear]=x;
        }
        else
        {
            if((front==0&&rear==-1)||(rear!=front-1))
                q[++rear]=x;
        }
    }
}
void  delet()
{
    int a;
    if((front==0)&&(rear==-1))
    {
        printf("Queue is underflow\n");
        getch();
        exit(0);
    }
    if(front==rear)
    {
        a=q[front];
        rear=-1;
        front=0;
    }
    else
        if(front==max-1)
        {
            a=q[front];
            front=0;
        }
        else a=q[front++];
        printf("Deleted element is:%d\n",a);
}

void display()
{
    int i,j;
    if(front==0&&rear==-1)
    {
        printf("Queue is underflow\n");
        getch();
        exit(0);
    }
    if(front>rear)
    {
        for(i=0;i<=rear;i++)
            printf("\t%d",q[i]);
        for(j=front;j<=max-1;j++)
            printf("\t%d",q[j]);
        printf("\n rear is at %d\n",q[rear]);
        printf("\n front is at %d\n",q[front]);
    }
    else
    {
        for(i=front;i<=rear;i++)
        {
            printf("\t%d",q[i]);
        }
        printf("\nrear is at %d\n",q[rear]);
        printf("\nfront is at %d\n",q[front]);
    }
    printf("\n");
}
//getch();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top