Implement streams IPC mechanism
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m47s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m47s
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <proc/procgroup.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <proc/resource.h>
|
||||
#include <proc/stream.h>
|
||||
#include <sync/spin_lock.h>
|
||||
#include <sys/debug.h>
|
||||
|
||||
@@ -96,6 +97,46 @@ struct proc_resource* proc_create_resource_mail (struct procgroup* procgroup) {
|
||||
return resource;
|
||||
}
|
||||
|
||||
struct proc_resource* proc_create_resource_stream (struct procgroup* procgroup) {
|
||||
uint64_t fpg;
|
||||
|
||||
struct proc_resource* resource;
|
||||
|
||||
resource = malloc (sizeof (*resource));
|
||||
if (resource == NULL)
|
||||
return NULL;
|
||||
|
||||
memset (resource, 0, sizeof (*resource));
|
||||
|
||||
spin_lock (&procgroup->lock, &fpg);
|
||||
|
||||
resource->rid = id_alloc (&procgroup->rid_alloc);
|
||||
|
||||
if (resource->rid < 0) {
|
||||
free (resource);
|
||||
spin_unlock (&procgroup->lock, fpg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resource->lock = SPIN_LOCK_INIT;
|
||||
resource->ops.cleanup = &proc_cleanup_resource_stream;
|
||||
resource->u.mail.resource = resource;
|
||||
resource->type = PR_STREAM;
|
||||
|
||||
if (!ringbuffer_init (&resource->u.stream.ringbuffer, PROC_STREAM_MAX, 1)) {
|
||||
free (resource);
|
||||
spin_unlock (&procgroup->lock, fpg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rbtree_insert (struct proc_resource, &procgroup->resource_tree, &resource->resource_tree_link,
|
||||
resource_tree_link, rid);
|
||||
|
||||
spin_unlock (&procgroup->lock, fpg);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void proc_delete_resource (struct procgroup* procgroup, struct proc_resource* resource,
|
||||
struct reschedule_ctx* rctx) {
|
||||
uint64_t fr, fpg;
|
||||
|
||||
Reference in New Issue
Block a user