[M3devel] FreeBSD gc stack?

Jay K jay.krell at cornell.edu
Sun Jul 25 12:58:42 CEST 2010


So, my real goal here is I'm reviewing why we can't/don't use pthreads on OpenBSD.
  I have a new system and would rather not do the jmpbuf munging.

OpenBSD has suspend/resume like FreeBSD.
You can inquire as to the stack, but it looks like you get the whole thing, not just the part currently used.

And the FreeBSD code appears similar, and appears to walk it incorrectly (no, see below the code before reading the code)?

void
ThreadPThread__ProcessStopped (m3_pthread_t mt, void *bottom, void *context,
                              void (*p)(void *start, void *limit))
{
  pthread_attr_t attr;
  char *stackaddr;
  WORD_T stacksize;

  /* process the stacks */
  if (pthread_attr_init(&attr) != 0) abort();
  if (pthread_attr_get_np(PTHREAD_FROM_M3(mt), &attr) != 0) abort();
  if (pthread_attr_getstack(&attr, (void **)&stackaddr, &stacksize) != 0) abort();
  if (pthread_attr_destroy(&attr) != 0) abort();
#if 0
  assert(stack_grows_down); /* See ThreadPThreadC.c */
#endif
  assert(context == 0);
  assert((char *)bottom >= stackaddr);
  assert((char *)bottom <= (stackaddr + stacksize));
  p(stackaddr, bottom);
  /* assume registers are stored in the stack */
  /* but call p to simulate processing registers: see RTHeapStats.m3 */
  p(0, 0);
}


ok..it turns out "bottom" is "top"..probably you can define them either way.. it is the highest address.

But still, this does have the unfortunate characteristic of scanning the entire stack, not just the "live" part, right?

It looks the like the same compromise is easy to achieve on OpenBSD.
I think I'll try pthreads there again. I understand it is still usermode and won't run on multiple processors, but it also provides for better portability (no setjmp munging).

 - Jay

 		 	   		  


More information about the M3devel mailing list