Example #1
0
static MsgStore *
allocMsg(MsgMgrPrimRef self)
{
  EBBRC rc;
  MsgStore *msg;  
  spinLock(&self->freelistlock);
  msg = self->freelist;
  if (msg != NULL) {
    self->freelist = msg->next; 
    spinUnlock(&self->freelistlock);
    msg->home = MyEL();
    // lrt_printf("%s:%s found free message\n", __FILE__, __func__);
    return msg ;
  }
  spinUnlock(&self->freelistlock);

  // lrt_printf("%s:%s freelist empty, allocating new msg\n", __FILE__, __func__);

  // need to allocate another message 
  rc = EBBPrimMalloc(sizeof(*msg), &msg, EBB_MEM_DEFAULT);
  LRT_RCAssert(rc);

  msg->home = MyEL();

  return msg;
}
Example #2
0
struct ZObjInstance *
__get_cur_error()
{
	unsigned long thread_id = cur_thread;
	spinLock(&spin_lk);
	struct RBNode *stack = rbSearch(stack_tree, &thread_id);
	spinUnlock(&spin_lk);
	assert(to_stack(stack)->cur_error != NULL);
	return to_stack(stack)->cur_error;
}
Example #3
0
void
__throw(struct ZObjInstance *e)
{
	unsigned long thread_id = cur_thread;
	spinLock(&spin_lk);
	struct RBNode *stack = rbSearch(stack_tree, &thread_id);
	spinUnlock(&spin_lk);
	to_stack(stack)->cur_error = e;
	longjmp(to_stack(stack)->stack_top->jb, 1);
}
Example #4
0
static MsgStore *
MsgMgrPrim_dequeueMsgHead(MsgMgrPrimRef target)
{
  MsgStore *msg;
  spinLock(&target->msgqueuelock);
  msg = target->msgqueue;
  if (msg != NULL) {
    target->msgqueue = msg->next;
  }
  spinUnlock(&target->msgqueuelock);
  return msg;
}
Example #5
0
void
__pop_jmp_point()
{
	unsigned long thread_id = cur_thread;
	spinLock(&spin_lk);
	struct RBNode *stack = rbSearch(stack_tree, &thread_id);
	spinUnlock(&spin_lk);
	struct stack_node *node = to_stack(stack)->stack_top;
	assert(node != NULL);
	to_stack(stack)->stack_top = node->prev;
	free(node);
}	
Example #6
0
static void
freeMsg(MsgMgrPrimRef self, MsgStore *msg)
{
  EBBRC rc;
  MsgMgrPrimRef target; 

  rc = MsgMgrPrim_findTarget(self, msg->home, &target);
  LRT_RCAssert(rc);

  spinLock(&target->freelistlock);
  msg->next = target->freelist;
  target->freelist = msg;
  spinUnlock(&target->freelistlock);
}
Example #7
0
void *
__push_jmp_point()
{
	unsigned long thread_id = cur_thread;
	spinLock(&spin_lk);
	rbInsert(&stack_tree, &thread_id);
	spinUnlock(&spin_lk);
	struct RBNode *stack = rbSearch(stack_tree, &thread_id);
	struct stack_node *new_node = malloc(sizeof(struct stack_node));
	assert(new_node != NULL);
	new_node->prev = to_stack(stack)->stack_top;
	to_stack(stack)->stack_top = new_node;
	return new_node->jb;
}
Example #8
0
static EBBRC
MsgMgrPrim_enqueueMsg(MsgMgrPrimRef target, MsgStore *msg)
{
  uintptr_t queueempty = 1;
  spinLock(&target->msgqueuelock);
  if (target->msgqueue != NULL) {
    queueempty = 0;
  }
  msg->next = target->msgqueue;
  target->msgqueue = msg;
  spinUnlock(&target->msgqueuelock);
  if (queueempty) {
    COBJ_EBBCALL(theEventMgrPrimId, dispatchIPI, target->eventLoc);
  }
  return EBBRC_OK;
}