Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions include/bufpools.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once
#include<cstdint>
#include<array>


namespace yards{

inline constexpr uint32_t MAXPOOLS = 20;
inline constexpr uint32_t MAX_BUFFER_SIZE = 8192;
inline constexpr uint32_t MAX_BUFFER_IN_POOL = 2048;
inline constexpr uint16_t MIN_BUFFER_SIZE = 8;

using SemaphoreId = uint32_t;
using BufferPoolId = uint32_t;



struct BufferPool{

BufferPool* next{nullptr};

SemaphoreId count{};
uint32_t bpsize



};

extern struct BufferPool;


}
61 changes: 61 additions & 0 deletions include/queue.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef QUEUE_H
#define QUEUE_H
Comment on lines +1 to +2
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header guard uses QUEUE_H but should follow the codebase convention of using QUEUE_HPP to match the .hpp file extension. This is consistent with other headers in the codebase (e.g., stddef.hpp uses STDDEF_HPP).

Suggested change
#ifndef QUEUE_H
#define QUEUE_H
#ifndef QUEUE_HPP
#define QUEUE_HPP

Copilot uses AI. Check for mistakes.

#include<kernel.hpp>
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space between #include and <kernel.hpp>. While some compilers may accept this, the standard practice is to have a space between the directive and the angle bracket for consistency and readability.

Suggested change
#include<kernel.hpp>
#include <kernel.hpp>

Copilot uses AI. Check for mistakes.

#ifndef NQENT;

/* Constant for total quetab entry */
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment: "quetab" should likely be "queue table" or "queue tab" for clarity. This appears in the comment describing what NQENT represents.

Suggested change
/* Constant for total quetab entry */
/* Constant for total queue table entry */

Copilot uses AI. Check for mistakes.

#define NQENT = NTHREAD + 4 + NSEM + NSEM;
Comment on lines +6 to +10
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro definition syntax is incorrect. Macros should not use an equals sign for assignment. It should be #define NQENT (NTHREAD + 4 + NSEM + NSEM) without the equals sign. Additionally, the semicolon at the end should be removed. The current syntax will cause the preprocessor to literally replace NQENT with = NTHREAD + 4 + NSEM + NSEM; which will lead to compilation errors.

Suggested change
#ifndef NQENT;
/* Constant for total quetab entry */
#define NQENT = NTHREAD + 4 + NSEM + NSEM;
#ifndef NQENT
/* Constant for total quetab entry */
#define NQENT (NTHREAD + 4 + NSEM + NSEM)

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +10
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semicolon after #ifndef NQENT is incorrect syntax. Preprocessor directives should not end with semicolons. This will cause a compilation error.

Suggested change
#ifndef NQENT;
/* Constant for total quetab entry */
#define NQENT = NTHREAD + 4 + NSEM + NSEM;
#ifndef NQENT
/* Constant for total quetab entry */
#define NQENT (NTHREAD + 4 + NSEM + NSEM)

Copilot uses AI. Check for mistakes.
#endif

#define MAXKEY 0X7FFFFFFF
#define MINKEY 0X80000000
Comment on lines +13 to +14
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hex literal prefix should use lowercase 'x' (0x7FFFFFFF and 0x80000000) for consistency with standard C++ conventions, rather than uppercase 'X'. While both are technically valid, lowercase is the more common convention.

Suggested change
#define MAXKEY 0X7FFFFFFF
#define MINKEY 0X80000000
#define MAXKEY 0x7FFFFFFF
#define MINKEY 0x80000000

Copilot uses AI. Check for mistakes.

using qid_typ = int;


struct quentry{
int key;
tid_typ next;
tid_typ prev;
Comment on lines +21 to +22
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type tid_typ is undefined. Based on the codebase convention in stddef.hpp line 23, the correct type name is tid_type (with an 'e' at the end). This will cause a compilation error.

Suggested change
tid_typ next;
tid_typ prev;
tid_type next;
tid_type prev;

Copilot uses AI. Check for mistakes.
};

extern struct queent quetab[];
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Struct name mismatch: the struct is defined as quentry on line 19, but declared as queent here. This will cause a compilation error as the types don't match.

Suggested change
extern struct queent quetab[];
extern struct quentry quetab[];

Copilot uses AI. Check for mistakes.
extern qid_typ readylist;


/* Queue functions to get index of head and tail */

inline qid_typ gethead(qid_typ q){return q;}
inline qid_typ gettail(qid_typ q){return q+1;}

/* Function to check for bad pid */

inline isbadid(qid_typ x){
return(x < 0 || x >= NQENT || x != (gettail(x) - 1));
Comment on lines +36 to +37
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return type for inline function isbadid. The function should declare a return type, likely bool based on its usage pattern. This will cause a compilation error in modern C++.

Suggested change
inline isbadid(qid_typ x){
return(x < 0 || x >= NQENT || x != (gettail(x) - 1));
inline bool isbadid(qid_typ x){
return (x < 0 || x >= NQENT || x != (gettail(x) - 1));

Copilot uses AI. Check for mistakes.
}



/* Queue Manipulations functions */

inline bool isempty(qid_typ q){return quetab[gethead(q)].next >= NPROC;}
inline bool isnonemty(qid_typ q){return quetab[gethead(q)].next < NPROC;}
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in function name: "isnonemty" should be "isnonempty".

Suggested change
inline bool isnonemty(qid_typ q){return quetab[gethead(q)].next < NPROC;}
inline bool isnonempty(qid_typ q){return quetab[gethead(q)].next < NPROC;}

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +45
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type error: quetab[gethead(q)].next is of type tid_type (which is int32_t), not an index. Comparing it with NPROC doesn't make semantic sense for checking if a queue is empty. The logic should likely check if next equals a sentinel value or compare indices differently.

Suggested change
inline bool isempty(qid_typ q){return quetab[gethead(q)].next >= NPROC;}
inline bool isnonemty(qid_typ q){return quetab[gethead(q)].next < NPROC;}
/* Forward declaration to allow use in inline helpers below. */
qid_typ get_first(qid_typ id);
inline bool isempty(qid_typ q){
/* A negative result from get_first(q) indicates that the queue is empty. */
return (get_first(q) < 0);
}
inline bool isnonemty(qid_typ q){
return !isempty(q);
}

Copilot uses AI. Check for mistakes.
inline bool firstkey(qid_typ q){return quetab[gethead(q)].next.key;}
inline bool lastkey(qid_typ q){return quetab[gettail(q)].prev.key;}
Comment on lines +46 to +47
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type for these functions should be int or qid_typ, not bool. The functions appear to return key values (integers), but are declared to return boolean values. This is a type mismatch that will cause incorrect behavior or compilation warnings.

Suggested change
inline bool firstkey(qid_typ q){return quetab[gethead(q)].next.key;}
inline bool lastkey(qid_typ q){return quetab[gettail(q)].prev.key;}
inline int firstkey(qid_typ q){return quetab[gethead(q)].next.key;}
inline int lastkey(qid_typ q){return quetab[gettail(q)].prev.key;}

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +47
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type error: attempting to access .key member on quetab[gethead(q)].next, but next is of type tid_type (int32_t), not a struct with a key field. This will cause a compilation error. The function likely needs to access the key of the next entry in the queue table.

Copilot uses AI. Check for mistakes.




/* Queue funtioncs */
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in comment: "funtioncs" should be "functions".

Suggested change
/* Queue funtioncs */
/* Queue functions */

Copilot uses AI. Check for mistakes.

qid_typ get_first(qid_typ id);
qid_typ get_last(qid_typ id);
qid_typ getitem(qid_typ process);
qid_typ enqueue(qid_typ id);
qid_typ dequeue(qid_typ id);
qid_typ insert(qid_typ id, qid_typ q, qid_typ key);
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The insert function signature appears to have incorrect parameter types. The third parameter is declared as qid_typ key, but based on the struct definition where key is of type int, and considering the inline functions firstkey and lastkey that return keys, this parameter should likely be of type int rather than qid_typ.

Suggested change
qid_typ insert(qid_typ id, qid_typ q, qid_typ key);
qid_typ insert(qid_typ id, qid_typ q, int key);

Copilot uses AI. Check for mistakes.
qid_typ queinit();