kernel: implement globally-unique object ids

This commit is contained in:
2026-02-23 18:31:28 +00:00
parent dbe117135b
commit 37ae7aeef7
3 changed files with 18 additions and 1 deletions

View File

@@ -7,6 +7,20 @@
static struct queue object_types;
static spin_lock_t object_types_lock = SPIN_LOCK_INIT;
static koid_t koid_alloc(void)
{
static koid_t counter = 0;
static spin_lock_t lock = SPIN_LOCK_INIT;
unsigned long flags;
spin_lock_irqsave(&lock, &flags);
koid_t result = counter;
counter++;
spin_unlock_irqrestore(&lock, flags);
return result;
}
kern_status_t object_bootstrap(void)
{
return KERN_OK;
@@ -53,6 +67,7 @@ struct object *object_create(struct object_type *type)
struct object *obj = (struct object *)((unsigned char *)obj_buf
+ type->ob_header_offset);
obj->ob_id = koid_alloc();
obj->ob_type = type;
obj->ob_lock = SPIN_LOCK_INIT;
obj->ob_magic = OBJECT_MAGIC;