Simplified RR, cleanup stream function params
This commit is contained in:
@@ -49,6 +49,7 @@ struct proc* kproc_create (void) {
|
||||
|
||||
kproc->lock = SPIN_LOCK_INIT;
|
||||
kproc->flags |= PROC_KPROC;
|
||||
kproc->state = PROC_READY;
|
||||
kproc->pid = proc_alloc_pid ();
|
||||
|
||||
kproc->procgroup = procgroup_create ();
|
||||
@@ -58,7 +59,7 @@ struct proc* kproc_create (void) {
|
||||
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
proc_register (kproc, NULL, &rctx);
|
||||
proc_register (kproc, thiscpu, &rctx);
|
||||
|
||||
return kproc;
|
||||
}
|
||||
@@ -228,24 +229,19 @@ void proc_register_partial (struct proc* proc) {
|
||||
static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
uint64_t fp;
|
||||
|
||||
struct list_node_link *current, *start;
|
||||
|
||||
if (!cpu->proc_run_q)
|
||||
return NULL;
|
||||
|
||||
struct list_node_link *current, *start;
|
||||
|
||||
if (cpu->proc_current && cpu->proc_current->cpu_run_q_link.next)
|
||||
current = cpu->proc_current->cpu_run_q_link.next;
|
||||
else
|
||||
current = cpu->proc_run_q;
|
||||
|
||||
if (!current)
|
||||
current = cpu->proc_run_q;
|
||||
|
||||
start = current;
|
||||
|
||||
bool wrap = false;
|
||||
|
||||
while (current) {
|
||||
do {
|
||||
struct proc* proc = list_entry (current, struct proc, cpu_run_q_link);
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
@@ -261,14 +257,9 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
|
||||
current = current->next;
|
||||
|
||||
if (!current && !wrap) {
|
||||
if (!current)
|
||||
current = cpu->proc_run_q;
|
||||
wrap = true;
|
||||
}
|
||||
|
||||
if (wrap && current == start)
|
||||
break;
|
||||
}
|
||||
} while (current != start);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include <proc/stream.h>
|
||||
#include <proc/suspension_q.h>
|
||||
|
||||
void proc_stream_write (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* data, size_t data_size) {
|
||||
void proc_stream_write (struct proc_stream* stream, void* data, size_t data_size) {
|
||||
uint64_t fr, fsq;
|
||||
|
||||
spin_lock (&stream->resource->lock, &fr);
|
||||
@@ -19,8 +18,7 @@ void proc_stream_write (struct proc* proc, struct proc_stream* stream, struct re
|
||||
spin_unlock (&stream->resource->lock, fr);
|
||||
}
|
||||
|
||||
size_t proc_stream_read (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* out_data, size_t data_size) {
|
||||
size_t proc_stream_read (struct proc_stream* stream, void* out_data, size_t data_size) {
|
||||
uint64_t fr;
|
||||
|
||||
size_t bytes = 0;
|
||||
|
||||
@@ -20,10 +20,8 @@ struct proc_stream {
|
||||
|
||||
void proc_cleanup_resource_stream (struct proc_resource* resource, struct reschedule_ctx* rctx);
|
||||
|
||||
void proc_stream_write (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* data, size_t data_size);
|
||||
void proc_stream_write (struct proc_stream* stream, void* data, size_t data_size);
|
||||
|
||||
size_t proc_stream_read (struct proc* proc, struct proc_stream* stream, struct reschedule_ctx* rctx,
|
||||
void* out_data, size_t data_size);
|
||||
size_t proc_stream_read (struct proc_stream* stream, void* out_data, size_t data_size);
|
||||
|
||||
#endif // _KERNEL_PROC_STREAM_H
|
||||
|
||||
Reference in New Issue
Block a user