+void read_message(int fd_in, int fd_out)
+{
+ //Find next task
+ uint8_t c;
+ uint16_t tasklen;
+ uint8_t ct;
+
+ for(ct = 0; ct<MAXTASKS; ct++)
+ if(!tasks_used[ct])
+ break;
+ if(ct == MAXTASKS)
+ die("Trying to add too much tasks...\n");
+
+ debug("Receiving input for task %d\n", ct);
+ read(fd_in, &c, 1);
+ if((char) c == 's') {
+ debug("Receiving an sds\n");
+ } else if((char) c == 't'){
+ read(fd_in, &c, 1);
+ tasklen = 256*c;
+ read(fd_in, &c, 1);
+ tasklen += c;
+ if(tasklen > MAXTASKSIZE)
+ die("Task is too long: %d\n", tasklen);
+ for(int i = 0; i<tasklen; i++){
+ debug("Read %d\n", i);
+ read(fd_in, tasks[ct]+i, 1);
+ debug("t[][%i]: %d\n", i,
+ tasks[ct][i]);
+ }
+ //Return the task number for later removal
+ write(fd_out, (void *)&ct, 1);
+ debug("Received a task of length %d\n", tasklen);
+ tasks_used[ct] = true;
+ } else {
+ die("Unknown message: %c?\n", c);
+ }
+}
+
+void run_task(char *program)
+{
+ int pc = 0;
+ int sp = 0;
+ int plen = strlen(program);
+ char stack[1024] = {0};
+ while(pc != plen){