Started code to manage kernel resource table

This commit is contained in:
2021-04-17 00:57:37 -05:00
parent 9630d0a396
commit cb6d2681ef
2 changed files with 40 additions and 0 deletions

27
include/resource.h Normal file
View File

@@ -0,0 +1,27 @@
#pragma once
#include "process.h"
#include <stddef.h>
enum resource_type_t
{
RESOURCE_UNAVAILABLE = 0,
RESOURCE_PROCESS
};
struct resource_t
{
size_t type;
union
{
struct process_t process;
};
};
struct resource_table_t
{
struct resource_t *array;
size_t capacity;
};
int find_resource_slot(struct resource_table_t *table);

13
src/resource.c Normal file
View File

@@ -0,0 +1,13 @@
#include "resource.h"
int find_resource_slot(struct resource_table_t *table)
{
for(int i = 0; i < table->capacity; i++)
{
if(table->array[i].type == RESOURCE_UNAVAILABLE)
{
return i;
}
}
return -1;
}