Message passing / mail system
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m20s

This commit is contained in:
2026-02-18 17:18:03 +01:00
parent 35454a087e
commit ae0a6024da
19 changed files with 340 additions and 66 deletions

View File

@@ -6,58 +6,20 @@
#include <string.h>
#include <terminal.h>
#define MUTEX 2000
__thread volatile char letter = 'c';
void app_proc (void) {
char arg_letter = (char)(uintptr_t)process_argument ();
letter = arg_letter;
for (;;) {
mutex_lock (MUTEX);
for (int i = 0; i < 3; i++)
test (letter);
/* terminal_print (&letter, 1); */
for (volatile int i = 0; i < 1000 * 1000; i++)
;
mutex_unlock (MUTEX);
}
process_quit ();
}
void app_main (void) {
mutex_create (MUTEX);
letter = 'a';
/* process_exec ("ramdisk:/ce"); */
/* process_spawn (&app_proc, (void*)'b'); */
/* process_spawn (&app_proc, (void*)'c'); */
/* process_spawn (&app_proc, (void*)'d'); */
const char* path = "ramdisk:/init.cmd";
char buffer[1024];
memset (buffer, 0, sizeof (buffer));
open (path);
read (path, 0, (uint8_t*)buffer, sizeof (buffer));
close (path);
terminal_print (buffer, strlen (buffer));
int ce_pid = exec ("ramdisk:/ce");
int ce_pgid = get_procgroup (ce_pid);
for (;;) {
int ch = kb_read_key ();
if (ch < 0)
if (ch <= 0)
continue;
terminal_print ((char*)&ch, 1);
mail_send (ce_pgid, (uint8_t*)&ch, 1);
char rcv;
mail_receive (&rcv, 1);
terminal_print (&rcv, 1);
}
}