This commit is contained in:
2026-02-25 03:44:39 +01:00
parent 252a36ae4e
commit 76f782c5ae

View File

@@ -46,33 +46,41 @@ extern "C" void main() {
//sys_test(1,2,3,4,5); //sys_test(1,2,3,4,5);
unsigned id = sys_getpid(); unsigned id = sys_getpid();
char text[] = "appX "; char text[] = "appX";
text[3] = 0x30+id; text[3] = 0x30+id;
write(1, text, sizeof(text), 0, (int)id); write(1, text, sizeof(text), 0, (int)id);
uint8_t cnt = 0; uint8_t cnt = 0;
for (unsigned i = 1;; ++i) { for (uint8_t i = 1;; ++i) {
if(i%10 == 0){
if(id == 2){
send(4, text, strlen(text), text, 15);
write(1, text, strlen(text), 25, (int)id);
}
if(id == 4){
char blubb[10];
if(receive(blubb, 20)){
write(1, blubb, strlen(blubb), 25, (int)id);
}
reply("toast ", 11);
}
}
//counter to see app running //counter to see app running
cnt=(cnt+1)%100; cnt=(cnt+1)%100;
char buf[12]; char buf[32];
char* msg = itoa(cnt,buf); char* msg = itoa(cnt,buf);
write(1, msg, strlen(msg), 6, (int)id); write(1, msg, strlen(msg), 6, (int)id);
//test ipc
if((i+50)%100 == 0){
if(id == 2){
char txt[] = "toastbrot ";
itoa(cnt, &txt[1]);
write(2, "send\n", 5);
send(4, txt, strlen(txt), txt, 15);
write(1, txt, strlen(txt), 25, (int)id);
}
}
if(i%100 == 0){
if(id == 4){
char blubb[20];
if(receive(blubb, sizeof(blubb))){
write(1, blubb, strlen(blubb), 25, (int)id);
write(2, "reply\n", 6);
itoa(cnt, &blubb[1]);
reply(blubb, sizeof(blubb));
}
}
}
// test map/unmap and print ptr // test map/unmap and print ptr
void* ptr= map(4096); void* ptr= map(4096);
uint16_t* val = ((uint16_t*)ptr); uint16_t* val = ((uint16_t*)ptr);