Exemplo n.º 1
0
void ArenaRestoreProtection(Globals globals)
{
  Ring node, next;
  Arena arena;

  arena = GlobalsArena(globals);

  RING_FOR(node, GlobalsRememberedSummaryRing(globals), next) {
    RememberedSummaryBlock block =
      RING_ELT(RememberedSummaryBlock, globalRing, node);
    size_t i;

    for(i = 0; i < RememberedSummaryBLOCK; ++ i) {
      Seg seg;
      Bool b;

      if(block->the[i].base == (Addr)0) {
        AVER(block->the[i].summary == RefSetUNIV);
        continue;
      }
      b = SegOfAddr(&seg, arena, block->the[i].base);
      if(b && SegBase(seg) == block->the[i].base) {
        AVER(IsA(GCSeg, seg));
        SegSetSummary(seg, block->the[i].summary);
      } else {
        /* Either seg has gone or moved, both of which are */
        /* client errors. */
        NOTREACHED;
      }
    }
  }
Thread ThreadRingThread(Ring threadRing)
{
    Thread thread;
    AVERT(Ring, threadRing);
    thread = RING_ELT(Thread, arenaRing, threadRing);
    AVERT(Thread, thread);
    return thread;
}
static void mapThreadRing(Ring threadRing, void (*func)(Thread))
{
  Ring node, next;
  pthread_t self;

  AVERT(Ring, threadRing);

  self = pthread_self();
  RING_FOR(node, threadRing, next) {
    Thread thread = RING_ELT(Thread, arenaRing, node);
    AVERT(Thread, thread);
    if(! pthread_equal(self, thread->id)) /* .thread.id */
      (*func)(thread);
  }
Exemplo n.º 4
0
static void mapThreadRing(Ring threadRing, void (*func)(Thread))
{
  Ring node, next;
  mach_port_t self;

  AVERT(Ring, threadRing);

  self = mach_thread_self();
  AVER(MACH_PORT_VALID(self));
  RING_FOR(node, threadRing, next) {
    Thread thread = RING_ELT(Thread, arenaRing, node);
    AVERT(Thread, thread);
    if(thread->port != self)
      (*func)(thread);
  }
Exemplo n.º 5
0
static void mapThreadRing(Ring threadRing, Ring deadRing, Bool (*func)(Thread))
{
  Ring node, next;

  AVERT(Ring, threadRing);
  AVERT(Ring, deadRing);
  AVER(FUNCHECK(func));

  RING_FOR(node, threadRing, next) {
    Thread thread = RING_ELT(Thread, arenaRing, node);
    AVERT(Thread, thread);
    AVER(thread->alive);
    if (!(*func)(thread)) {
      thread->alive = FALSE;
      RingRemove(&thread->arenaRing);
      RingAppend(deadRing, &thread->arenaRing);
    }
  }
Exemplo n.º 6
0
/*  Map over threads on ring calling f on each one except the
 *  current thread.
 */
static void mapThreadRing(Ring ring, void (*f)(Thread thread))
{
    Ring node;
    DWORD id;

    id = GetCurrentThreadId();
    node = RingNext(ring);
    while(node != ring) {
        Ring next = RingNext(node);
        Thread thread;

        thread = RING_ELT(Thread, arenaRing, node);
        AVERT(Thread, thread);
        if(id != thread->id) /* .thread.id */
            (*f)(thread);

        node = next;
    }
}
Exemplo n.º 7
0
static void mapThreadRing(Ring threadRing, Ring deadRing, Bool (*func)(Thread))
{
    Ring node, next;
    pthread_t self;

    AVERT(Ring, threadRing);
    AVERT(Ring, deadRing);
    AVER(FUNCHECK(func));

    self = pthread_self();
    RING_FOR(node, threadRing, next) {
        Thread thread = RING_ELT(Thread, arenaRing, node);
        AVERT(Thread, thread);
        AVER(thread->alive);
        if (!pthread_equal(self, thread->id) /* .thread.id */
                && !(*func)(thread))
        {
            thread->alive = FALSE;
            RingRemove(&thread->arenaRing);
            RingAppend(deadRing, &thread->arenaRing);
        }
    }
Exemplo n.º 8
0
static Res arenaRememberSummaryOne(Globals global, Addr base, RefSet summary)
{
  Arena arena;
  RememberedSummaryBlock block;

  AVER(summary != RefSetUNIV);

  arena = GlobalsArena(global);

  if(global->rememberedSummaryIndex == 0) {
    void *p;
    RememberedSummaryBlock newBlock;
    int res;

    res = ControlAlloc(&p, arena, sizeof *newBlock);
    if(res != ResOK) {
      return res;
    }
    newBlock = p;
    rememberedSummaryBlockInit(newBlock);
    RingAppend(GlobalsRememberedSummaryRing(global),
      &newBlock->globalRing);
  }
  block = RING_ELT(RememberedSummaryBlock, globalRing,
    RingPrev(GlobalsRememberedSummaryRing(global)));
  AVER(global->rememberedSummaryIndex < RememberedSummaryBLOCK);
  AVER(block->the[global->rememberedSummaryIndex].base == (Addr)0);
  AVER(block->the[global->rememberedSummaryIndex].summary == RefSetUNIV);
  block->the[global->rememberedSummaryIndex].base = base;
  block->the[global->rememberedSummaryIndex].summary = summary;
  ++ global->rememberedSummaryIndex;
  if(global->rememberedSummaryIndex >= RememberedSummaryBLOCK) {
    AVER(global->rememberedSummaryIndex == RememberedSummaryBLOCK);
    global->rememberedSummaryIndex = 0;
  }

  return ResOK;
}