struct thread_struct_wrapper *lwip_system_threads = NULL; // a list of all threads created by lwIP
sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio) {
sys_thread_t newthread;
SYS_ARCH_DECL_PROTECT(old_val);
newthread = malloc(sizeof(struct thread_struct_wrapper)); // allocate the space for the thread wrapper
if (newthread==NULL) return NULL;
SYS_ARCH_PROTECT(old_val); // Need to protect this -- preemption here could be a problem!
newthread.next = lwip_system_threads;
lwip_system_threads = newthread;
SYS_ARCH_UNPROTECT(old_val);
newthread.timeouts = NULL; // initialize the linked list to NULL
my_system_os_create_thread_function(&newthread.thread,