int __omp_collector_api(void *arg)
{
    
  if(arg!=NULL) {
    message_queue_t pending_requests;
    char *traverse = (char *) arg;

    message_queue_init(&pending_requests);
 
    while((int)(*traverse)!=0) {
      omp_collector_message* req = message_queue_push(&pending_requests);
      req->sz = (int)(*traverse); // todo: add check for consistency    
      traverse+=sizeof(int);
      req->r = (OMP_COLLECTORAPI_REQUEST)(*traverse);  // todo: add check for a valid request
      traverse+=sizeof(int);      
      req->ec= (OMP_COLLECTORAPI_EC *) traverse;  // copy address for response of error code
      traverse+=sizeof(int);    
      req->rsz = (int *)(traverse);
      traverse+=sizeof(int);
      req->mem = traverse;
      traverse+=req->sz-(4*sizeof(int));
    } 

    while(!message_queue_empty(&pending_requests)) {
      omp_collector_message pop_req;
      message_queue_pop(&pending_requests, &pop_req);
      process_top_request(&pop_req);  
    }
    return 0;
  }
  return -1;
}
示例#2
0
void *k_receive_message(int *p_pid) {
	MSG_QUEUE *q;
	MSG *m;
 	q = gp_current_process->message_queue;
	while (message_queue_empty(q)) {
		gp_current_process->state = BLOCKED_ON_RECEIVE;
		k_release_processor();
	}
	m = message_queue_dequeue(q);
	*p_pid = m->sPID;
	return m;
}
示例#3
0
void process_messages(void)
{
    unsigned long msg_idx;
    long delay;
    SYNCDBG(17,"Starting");
    // If already playing, just wait for next time
    if (!speech_sample_playing())
    {
        SYNCDBG(17,"play on");
        message_playing = 0;
        // If no messages are in queue, don't play anything
        if (message_queue_empty())
        {
            SYNCDBG(19,"Finished");
            return;
        }
        // Otherwise remove next message from queue and try to play it
        msg_idx = message_queue[0].msg_idx;
        delay = message_queue[0].delay;
        remove_message_from_queue(0);
        output_message(msg_idx, delay, true);
    }
    SYNCDBG(19,"Finished");
}