diff -Naur legOS_orig/Makefile.kernel legOS/Makefile.kernel
--- legOS_orig/Makefile.kernel	Mon Aug 14 10:53:00 2000
+++ legOS/Makefile.kernel	Wed Apr 17 13:15:40 2002
@@ -7,7 +7,7 @@
 # kernel sources & objects
 KSOURCES=kmain.c mm.c systime.c tm.c semaphore.c conio.c lcd.c \
 	 lnp-logical.c lnp.c program.c vis.c battery.c\
-         timeout.c dkey.c dmotor.c dsensor.c dsound.c
+         timeout.c dkey.c dmotor.c dsensor.c dsound.c rtm.c
 KOBJECTS=$(KSOURCES:.c=.o)
 
 # Kernel libraries. Use second version to link all
diff -Naur legOS_orig/boot/config.h legOS/boot/config.h
--- legOS_orig/boot/config.h	Sat Sep 30 03:48:32 2000
+++ legOS/boot/config.h	Wed Apr 17 13:15:40 2002
@@ -49,6 +49,10 @@
 #define CONF_LNP_HOSTADDR 0x00	//!< LNP host address
 #define CONF_LNP_HOSTMASK 0xf0	//!< LNP host mask
 
+// extensions
+//
+#define CONF_RTM                //!< Remote Task Management 
+
 // drivers
 //
 #define CONF_DKEY		//!< debounced key driver
diff -Naur legOS_orig/include/rtm.h legOS/include/rtm.h
--- legOS_orig/include/rtm.h	Thu Jan  1 01:00:00 1970
+++ legOS/include/rtm.h	Wed Apr 17 13:19:59 2002
@@ -0,0 +1,9 @@
+// HEADER für rtm
+
+#ifndef __rtm_h__
+#define __rtm_h__
+
+void rtm_handler(const unsigned char* data, unsigned char length, unsigned char src);
+void rtm_start();
+
+#endif
\ No newline at end of file
diff -Naur legOS_orig/include/sys/tm.h legOS/include/sys/tm.h
--- legOS_orig/include/sys/tm.h	Wed Feb 14 04:53:00 2001
+++ legOS/include/sys/tm.h	Wed Apr 17 13:15:40 2002
@@ -46,7 +46,11 @@
 
 #define IDLE_STACK_SIZE		128	//!< should suffice for IRQ service
 
-#define NUM_SYSTEM_THREADS	3
+#ifdef CONF_RTM
+#define NUM_SYSTEM_THREADS	4
+#else
+#define NUM_SYSTEM_THREADS      3
+#endif
 
 ///////////////////////////////////////////////////////////////////////
 //
diff -Naur legOS_orig/kernel/kmain.c legOS/kernel/kmain.c
--- legOS_orig/kernel/kmain.c	Mon Aug 14 22:43:26 2000
+++ legOS/kernel/kmain.c	Wed Apr 17 13:15:40 2002
@@ -46,6 +46,9 @@
 #include <string.h>
 #include <conio.h>
 #include <unistd.h>
+
+#include <rtm.h>
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // Variables
@@ -155,6 +158,11 @@
 #ifdef CONF_TM
     tm_init();
 #endif
+
+#ifdef CONF_RTM
+    rtm_start();
+#endif
+
 #ifdef CONF_PROGRAM
     program_init();
 #endif
diff -Naur legOS_orig/kernel/program.c legOS/kernel/program.c
--- legOS_orig/kernel/program.c	Thu May 10 19:15:06 2001
+++ legOS/kernel/program.c	Wed Apr 17 13:15:40 2002
@@ -56,6 +56,8 @@
 
 #include <conio.h>
 
+#include <rtm.h>
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // Global Variables
@@ -113,8 +115,8 @@
       	 (prog->text_size+prog->data_size==prog->downloaded);
 }
 
-//! run the given program
-static void program_run(unsigned nr) {
+//! run the given program (changed for RTM-Patch)
+int program_run(unsigned nr) {
   if(program_valid(nr)) {
     program_t *prog=programs+nr;
 
@@ -123,7 +125,7 @@
     memcpy(prog->data,prog->data_orig,prog->data_size);
     memset(prog->bss,0,prog->bss_size);
 
-    execi((void*) (((char*)prog->text)
+    return execi((void*) (((char*)prog->text)
 	           + prog->start      ),
 	  0,0,prog->prio,prog->stack_size);
   }
@@ -144,6 +146,10 @@
   packet_len=length;
   packet_src=src;
   sem_post(&packet_sem);
+
+#ifdef CONF_RTM
+  rtm_handler(data, length, src);
+#endif
 }
 
 //! packet command parser task
diff -Naur legOS_orig/kernel/rtm.c legOS/kernel/rtm.c
--- legOS_orig/kernel/rtm.c	Thu Jan  1 01:00:00 1970
+++ legOS/kernel/rtm.c	Wed Apr 17 13:19:40 2002
@@ -0,0 +1,126 @@
+#include <config.h>
+#include <rtm.h>
+
+#ifdef CONF_RTM
+
+#include <lnp.h>
+#include <tm.h>
+#include <dmotor.h>
+#include <conio.h>
+#include <unistd.h>
+#include <semaphore.h>
+#include <string.h>
+#include <dsound.h>
+#include <sys/program.h>
+#include <sys/lcd.h>
+
+#define KILL 66
+#define START 44
+
+
+#if 1
+#define debugs(a) { cputs(a); msleep(500); }
+#define debugw(a) { cputw(a); msleep(500); }
+#else
+#define debugs(a)
+#define debugw(a)
+#endif
+
+
+static sem_t rtm_sem;      	      	  //!< synchronization semaphore
+
+
+int rtm_src;
+int rtm_length;
+char rtm_buf[2];
+
+void rtm_handler(const unsigned char* data, unsigned char length, unsigned char src)
+{
+	if (length <= 2) {
+		rtm_src = src;
+		rtm_length = length;
+		memcpy(rtm_buf, data, length);
+		sem_post(&rtm_sem);
+	}
+}
+
+
+//! check if a given program is valid.
+/*! \return 0 if invalid */
+extern int program_valid(unsigned nr);
+
+int rtm_thread(int argc, char *argv[])
+{
+	while(1) {
+		sem_wait(&rtm_sem);
+		if((rtm_buf[0]==KILL)&&(rtm_length==1))  {
+			debugs("kill ");
+			killall(PRIO_HIGHEST-1);
+
+			debugs("sound");
+			#ifdef CONF_DSOUND
+      			dsound_stop();
+			#endif
+
+			debugs("motor");
+			#ifdef CONF_DMOTOR
+				dm_init();
+			#endif
+			#ifdef CONF_DSENSOR
+
+			debugs("senso");
+				ds_init();
+			#endif
+			debugs("lnp  ");
+			lnp_init();
+
+		
+    		// Send OK back 
+			debugs("ack  ");
+			rtm_buf[1] = '\0';
+			lnp_addressing_write(rtm_buf, strlen(rtm_buf), rtm_src, 0);
+
+			debugs("ready");
+		}
+		if((rtm_buf[0]==START)&&(rtm_length==2)) {
+		  rtm_buf[1]--; // first program is in slot 0!
+			if (program_valid(rtm_buf[1])) {
+				debugs("start");
+				killall(PRIO_HIGHEST-1);
+
+				#ifdef CONF_DSOUND
+				debugs("sound");
+      				dsound_stop();
+				#endif
+				#ifdef CONF_DMOTOR
+				debugs("motor");
+					dm_init();
+				#endif
+				#ifdef CONF_DSENSOR
+				debugs("senso");
+					ds_init();
+				#endif
+				debugs("lnp  ");
+				lnp_init();
+
+				// Run Program 
+				debugs("run  ");
+				program_run(rtm_buf[1]-1);	// Da bei SendPAL die Null nicht übertragen wird sondern als Nullzeichen als Ende des Strings angesehen wird, verscheiben der Programme von 0-7 auf 1-8
+
+				// Send OK 	
+				debugs("ack  ");
+				rtm_buf[1] = '\0';
+				lnp_addressing_write(rtm_buf, strlen(rtm_buf), rtm_src, 0);
+			}
+		}
+	}
+}
+
+void rtm_start()
+{
+	sem_init(&rtm_sem, 0, 0);
+	execi(&rtm_thread, 0, 0, PRIO_HIGHEST, DEFAULT_STACK_SIZE); 
+	// PRIO_HIGHEST -> It won't be killed by killall(PRIO_HIGHEST-1);
+}
+
+#endif
