Added queue structure
This commit is contained in:
@@ -85,6 +85,14 @@ int store_active_context(struct process_context_t *context, size_t size);
|
||||
|
||||
struct process_context_t *get_active_context();
|
||||
|
||||
int open_port(int id);
|
||||
|
||||
int close_port(int id);
|
||||
|
||||
int send_message(int recipient, struct message_t *message);
|
||||
|
||||
int receive_message(struct message_t *buffer);
|
||||
|
||||
int request_message(struct message_t *buffer, void *temp);
|
||||
|
||||
void panic(const char *message) __attribute__ ((noreturn));
|
||||
|
||||
@@ -70,7 +70,7 @@ int construct_priority_queue(struct priority_queue_t *queue, int capacity);
|
||||
* @param queue
|
||||
* @return void*
|
||||
*/
|
||||
void *extract_min(struct priority_queue_t *queue);
|
||||
void *priorityqueue_extract_min(struct priority_queue_t *queue);
|
||||
|
||||
/**
|
||||
* @brief Inserts a new object onto the queue.
|
||||
@@ -80,7 +80,7 @@ void *extract_min(struct priority_queue_t *queue);
|
||||
* @param priority
|
||||
* @return int
|
||||
*/
|
||||
int queue_insert(struct priority_queue_t *queue, void *value, int priority);
|
||||
int priorityqueue_insert(struct priority_queue_t *queue, void *value, int priority);
|
||||
|
||||
/**
|
||||
* @brief Removes the object with a matching value from the queue.
|
||||
@@ -89,4 +89,4 @@ int queue_insert(struct priority_queue_t *queue, void *value, int priority);
|
||||
* @param value
|
||||
* @return int
|
||||
*/
|
||||
int queue_remove(struct priority_queue_t *queue, void *value);
|
||||
int priorityqueue_remove(struct priority_queue_t *queue, void *value);
|
||||
|
||||
53
include/queue.h
Normal file
53
include/queue.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
struct queue_node_t;
|
||||
|
||||
/**
|
||||
* @brief A last-in-first-out queue.
|
||||
*
|
||||
*/
|
||||
struct queue_t
|
||||
{
|
||||
/**
|
||||
* @brief The number of objects stored in this queue.
|
||||
*
|
||||
*/
|
||||
unsigned int count;
|
||||
|
||||
/**
|
||||
* @brief A link to the first node stored in this queue.
|
||||
*
|
||||
*/
|
||||
struct queue_node_t *first;
|
||||
|
||||
/**
|
||||
* @brief A link to the last node stored in this queue.
|
||||
*
|
||||
*/
|
||||
struct queue_node_t *last;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Inserts a new item at the end of the queue.
|
||||
*
|
||||
* @param queue
|
||||
* @param ptr
|
||||
*/
|
||||
void queue_insert(struct queue_t *queue, void *ptr);
|
||||
|
||||
/**
|
||||
* @brief Removes the next item from the queue and returns it.
|
||||
*
|
||||
* @param queue
|
||||
* @return void*
|
||||
*/
|
||||
void *queue_get_next(struct queue_t *queue);
|
||||
|
||||
/**
|
||||
* @brief Returns the next item on the queue without removing it.
|
||||
*
|
||||
* @param queue
|
||||
* @return void*
|
||||
*/
|
||||
void *queue_peek(struct queue_t *queue);
|
||||
|
||||
Reference in New Issue
Block a user