Message passing / mail system
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m20s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m20s
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <libk/string.h>
|
||||
#include <mm/liballoc.h>
|
||||
#include <mm/pmm.h>
|
||||
#include <proc/mail.h>
|
||||
#include <proc/mutex.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/procgroup.h>
|
||||
@@ -49,6 +50,32 @@ struct proc_resource* proc_create_resource_mutex (struct procgroup* procgroup, i
|
||||
return resource;
|
||||
}
|
||||
|
||||
struct proc_resource* proc_create_resource_mail (struct procgroup* procgroup, int rid) {
|
||||
struct proc_resource* resource;
|
||||
|
||||
resource = proc_find_resource (procgroup, rid);
|
||||
if (resource != NULL)
|
||||
return resource;
|
||||
|
||||
resource = malloc (sizeof (*resource));
|
||||
if (resource == NULL)
|
||||
return NULL;
|
||||
|
||||
memset (resource, 0, sizeof (*resource));
|
||||
resource->lock = SPIN_LOCK_INIT;
|
||||
resource->ops.cleanup = &proc_cleanup_resource_mail;
|
||||
resource->u.mail.resource = resource;
|
||||
resource->rid = rid;
|
||||
resource->type = PR_MAIL;
|
||||
|
||||
spin_lock (&procgroup->lock);
|
||||
rbtree_insert (struct proc_resource, &procgroup->resource_tree, &resource->resource_tree_link,
|
||||
resource_tree_link, rid);
|
||||
spin_unlock (&procgroup->lock);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
bool proc_delete_resource (struct proc_resource* resource, struct cpu** reschedule_cpu) {
|
||||
bool reschedule = resource->ops.cleanup (resource, reschedule_cpu);
|
||||
free (resource);
|
||||
|
||||
Reference in New Issue
Block a user