Changeset 8959


Ignore:
Timestamp:
Mar 30, 2008, 8:13:42 AM (11 years ago)
Author:
gb
Message:

Start to flesh this out for windows; still more work to do here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/lisp-kernel/thread_manager.c

    r8805 r8959  
    117117#ifndef WINDOWS
    118118    sched_yield();
     119#else
     120    Sleep(0);
    119121#endif
    120122  }
     
    413415current_thread_osid()
    414416{
     417  TCR *tcr = get_tcr(false);
     418  LispObj current = 0;
     419
     420  if (tcr) {
     421    current = tcr->osid;
     422  }
     423  if (current == 0) {
     424    DuplicateHandle(GetCurrentProcess(),
     425                    GetCurrentThread(),
     426                    GetCurrentProcess(),
     427                    &current,
     428                    0,
     429                    FALSE,
     430                    DUPLICATE_SAME_ACCESS);
     431    if (tcr) {
     432      tcr->osid = current;
     433    }
     434  }
     435  return current;
    415436}
    416437#else
     
    510531#ifdef WINDOWS
    511532void
    512 os_get_stack_bounds(LispObj q,void **base, natural *size)
    513 {
    514 }
    515 #else
    516 void
    517 os_get_stack_bounds(LispObj q,void **base, natural *size)
    518 {
    519   pthread_t p = (pthread_t)(q);
     533os_get_current_thread_stack_bounds(void **base, natural *size)
     534{
     535  natural natbase;
     536  MEMORY_BASIC_INFORMATION info;
     537 
     538  VirtualQuery((void *)current_stack_pointer, &info, sizeof(info));
     539  natbase = (natural)info.BaseAddress+info.RegionSize;
     540  *size = natbase - (natural)(info.AllocationBase);
     541  *base = (void *)natbase;
     542}
     543#else
     544void
     545os_get_current_thread_stack_bounds(void **base, natural *size)
     546{
     547  pthread_t p = pthread_self();
    520548#ifdef DARWIN
    521549  *base = pthread_get_stackaddr_np(p);
     
    9741002  natural stack_size = 0;
    9751003
    976   os_get_stack_bounds(current_thread_osid(),&stack_base, &stack_size);
     1004  os_get_current_thread_stack_bounds(&stack_base, &stack_size);
    9771005  thread_init_tcr(tcr, stack_base, stack_size);
    9781006  enqueue_tcr(tcr);
     
    10541082#endif
    10551083
     1084void
     1085init_threads(void * stack_base, TCR *tcr)
     1086{
     1087  lisp_global(INITIAL_TCR) = (LispObj)ptr_to_lispobj(tcr);
    10561088#ifdef WINDOWS
    1057 void
    1058 init_threads(void * stack_base, TCR *tcr)
    1059 {
    1060 }
    1061 void *
    1062 lisp_thread_entry(void *param)
    1063 {
    1064 }
    1065 #else
    1066 void
    1067 init_threads(void * stack_base, TCR *tcr)
    1068 {
    1069   lisp_global(INITIAL_TCR) = (LispObj)ptr_to_lispobj(tcr);
     1089  lisp_global(TCR_KEY) = TlsAlloc();
     1090#else
    10701091  pthread_key_create((pthread_key_t *)&(lisp_global(TCR_KEY)), shutdown_thread_tcr);
    10711092  thread_signal_setup();
    1072 
     1093#endif
     1094 
    10731095#ifndef USE_FUTEX
    10741096  count_cpus();
     
    10781100
    10791101
     1102#ifdef WINDOWS
     1103lisp_thread_entry(void *param)
     1104{
     1105}
     1106#else
    10801107void *
    10811108lisp_thread_entry(void *param)
Note: See TracChangeset for help on using the changeset viewer.