Skip to content

latest /include/queue.hpp#6

Open
Ko496-glitch wants to merge 2 commits intomasterfrom
dev
Open

latest /include/queue.hpp#6
Ko496-glitch wants to merge 2 commits intomasterfrom
dev

Conversation

@Ko496-glitch
Copy link
Copy Markdown
Owner

Added queueu.hpp, skeleton for base class of queue that will be derived for ready-list, sleep-list, semaphore-list etc.

Signed off: Kartik Ohlanko496@drexel.edu

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new header file include/queue.hpp that defines a base queue data structure and API for managing various queue types (ready-list, sleep-list, semaphore-list) in what appears to be an operating system kernel project. The implementation provides queue entry structures, manipulation functions, and utilities for managing doubly-linked queue structures.

Changes:

  • Added queue.hpp with queue data structure definitions and function declarations
  • Defined quentry struct for queue entries with key, next, and prev fields
  • Declared queue manipulation functions (enqueue, dequeue, insert, etc.) and inline helper functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/* 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 +46 to +47
inline bool firstkey(qid_typ q){return quetab[gethead(q)].next.key;}
inline bool lastkey(qid_typ q){return quetab[gettail(q)].prev.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 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 +6 to +10
#ifndef NQENT;

/* Constant for total quetab entry */

#define NQENT = NTHREAD + 4 + NSEM + NSEM;
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.
#ifndef QUEUE_H
#define QUEUE_H

#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.
Comment on lines +13 to +14
#define MAXKEY 0X7FFFFFFF
#define MINKEY 0X80000000
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.



/* 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.
Comment on lines +1 to +2
#ifndef QUEUE_H
#define QUEUE_H
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.
Comment on lines +21 to +22
tid_typ next;
tid_typ prev;
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.
Comment on lines +44 to +45
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.

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.
Comment on lines +46 to +47
inline bool firstkey(qid_typ q){return quetab[gethead(q)].next.key;}
inline bool lastkey(qid_typ q){return quetab[gettail(q)].prev.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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants