X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fthread.c;h=32dad36df1bb32e0904b7e05bf9c5470f9ad0d37;hb=eaa8a506790bb6ed627da617247bfd13802eb365;hp=43d551a5d7925c20fc19e992ecd393ca38d1189b;hpb=f78c1fecf191e147ca081026cc11f2683ee80905;p=sbcl.git diff --git a/src/runtime/thread.c b/src/runtime/thread.c index 43d551a..32dad36 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -28,12 +28,16 @@ int dynamic_values_bytes=4096*sizeof(lispobj); /* same for all threads */ struct thread *all_threads; volatile lispobj all_threads_lock; extern struct interrupt_data * global_interrupt_data; +extern int linux_no_threads_p; int initial_thread_trampoline(struct thread *th) { lispobj function; +#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64) lispobj *args = NULL; +#endif + function = th->unbound_marker; th->unbound_marker = UNBOUND_MARKER_WIDETAG; if(arch_os_thread_init(th)==0) return 1; @@ -88,16 +92,15 @@ struct thread * create_thread_struct(lispobj initial_function) { BINDING_STACK_SIZE+ ALIEN_STACK_SIZE+ dynamic_values_bytes+ - 32*SIGSTKSZ - ); - if(!spaces) goto cleanup; + 32*SIGSTKSZ); + if(!spaces) + return NULL; per_thread=(union per_thread_data *) (spaces+ THREAD_CONTROL_STACK_SIZE+ BINDING_STACK_SIZE+ ALIEN_STACK_SIZE); - th=&per_thread->thread; if(all_threads) { memcpy(per_thread,arch_os_get_current_thread(), dynamic_values_bytes); @@ -129,6 +132,7 @@ struct thread * create_thread_struct(lispobj initial_function) { #endif } + th=&per_thread->thread; th->control_stack_start = spaces; th->binding_stack_start= (lispobj*)((void*)th->control_stack_start+THREAD_CONTROL_STACK_SIZE); @@ -191,12 +195,6 @@ struct thread * create_thread_struct(lispobj initial_function) { th->unbound_marker=initial_function; return th; - cleanup: - /* if(th && th->tls_cookie>=0) os_free_tls_pointer(th); */ - if(spaces) os_invalidate(spaces, - THREAD_CONTROL_STACK_SIZE+BINDING_STACK_SIZE+ - ALIEN_STACK_SIZE+dynamic_values_bytes); - return 0; } void link_thread(struct thread *th,pid_t kid_pid) @@ -230,13 +228,15 @@ void create_initial_thread(lispobj initial_function) { #ifdef LISP_FEATURE_SB_THREAD pid_t create_thread(lispobj initial_function) { - struct thread *th=create_thread_struct(initial_function); + struct thread *th; pid_t kid_pid=0; + if(linux_no_threads_p) return 0; + th=create_thread_struct(initial_function); if(th==0) return 0; kid_pid=clone(new_thread_trampoline, (((void*)th->control_stack_start)+ - THREAD_CONTROL_STACK_SIZE-4), + THREAD_CONTROL_STACK_SIZE-16), CLONE_FILES|SIG_THREAD_EXIT|CLONE_VM,th); if(kid_pid>0) { @@ -253,32 +253,6 @@ pid_t create_thread(lispobj initial_function) { } #endif -/* unused */ -void destroy_thread (struct thread *th) -{ - /* precondition: the unix task has already been killed and exited. - * This is called by the parent or some other thread */ -#ifdef LISP_FEATURE_GENCGC - gc_alloc_update_page_tables(0, &th->alloc_region); -#endif - get_spinlock(&all_threads_lock,th->pid); - th->unbound_marker=0; /* for debugging */ - if(th==all_threads) - all_threads=th->next; - else { - struct thread *th1=all_threads; - while(th1 && th1->next!=th) th1=th1->next; - if(th1) th1->next=th->next; /* unlink */ - } - release_spinlock(&all_threads_lock); - if(th && th->tls_cookie>=0) arch_os_thread_cleanup(th); - os_invalidate((os_vm_address_t) th->control_stack_start, - ((sizeof (lispobj)) - * (th->control_stack_end-th->control_stack_start)) + - BINDING_STACK_SIZE+ALIEN_STACK_SIZE+dynamic_values_bytes+ - 32*SIGSTKSZ); -} - struct thread *find_thread_by_pid(pid_t pid) { struct thread *th;