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:
@@ -6,6 +6,7 @@ $(eval $(call add_lib,libstring))
|
||||
$(eval $(call add_lib,libdebugconsole))
|
||||
$(eval $(call add_lib,libaux))
|
||||
$(eval $(call add_lib,libmalloc))
|
||||
$(eval $(call add_lib,libkb))
|
||||
|
||||
cflags += -DPRINTF_INCLUDE_CONFIG_H=1
|
||||
|
||||
|
||||
24
init/init.c
24
init/init.c
@@ -1,9 +1,11 @@
|
||||
#include <debugconsole.h>
|
||||
#include <kb.h>
|
||||
#include <limits.h>
|
||||
#include <malloc.h>
|
||||
#include <process.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <streams.h>
|
||||
#include <string.h>
|
||||
#include <terminal.h>
|
||||
|
||||
@@ -14,12 +16,17 @@ static int ce_pgid;
|
||||
void receiver (void* arg) {
|
||||
(void)arg;
|
||||
|
||||
char recv[RECV_MAX];
|
||||
int n;
|
||||
for (;;) {
|
||||
char recv[RECV_MAX];
|
||||
memset (recv, 0, sizeof (recv));
|
||||
mail_receive (&recv, sizeof (recv) - 1);
|
||||
|
||||
terminal_print (recv, strlen (recv));
|
||||
n = stream_read (ce_pgid, STREAM_OUT, (void*)recv, RECV_MAX - 1);
|
||||
|
||||
if (n > 0)
|
||||
terminal_print (recv, n);
|
||||
else
|
||||
sched ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +36,14 @@ void app_main (void) {
|
||||
int ce_pid = exec ("sys", "/ce");
|
||||
ce_pgid = get_procgroup (ce_pid);
|
||||
|
||||
struct process_data* pdata = process_spawn (&receiver, NULL);
|
||||
process_spawn (&receiver, NULL);
|
||||
|
||||
wait_for_pid (pdata->pid);
|
||||
for (;;) {
|
||||
int ch = kb_read_key ();
|
||||
|
||||
process_data_free (pdata);
|
||||
if (ch == 0)
|
||||
continue;
|
||||
|
||||
stream_write (ce_pgid, STREAM_IN, &ch, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user