Started code to manage kernel resource table
This commit is contained in:
27
include/resource.h
Normal file
27
include/resource.h
Normal 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
13
src/resource.c
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user