Esempio n. 1
0
Int32 System_ipcMsgQDelete()
{
    UInt32 i;
    UInt32 procId;
    Int32 status;

    i=0;

    while(gSystem_ipcMsgQEnableProcId[i]!=SYSTEM_PROC_MAX)
    {
        procId = gSystem_ipcMsgQEnableProcId[i];

        if(procId==System_getSelfProcId())
        {
            /* delete MsgQ */

            status = MessageQ_delete(&gSystem_ipcObj.selfMsgQ);
            UTILS_assert(status==0);

            status = MessageQ_delete(&gSystem_ipcObj.selfAckMsgQ);
            UTILS_assert(status==0);
        }
        else
        {
            status = MessageQ_close(&gSystem_ipcObj.remoteProcMsgQ[procId]);
            UTILS_assert(status==0);

            /* no need to close ack msgq */
        }
        i++;
    }
    return OSA_SOK;
}
Esempio n. 2
0
Int RcmClient_Instance_finalize(RcmClient_Object *obj)
{
    SemThread_Handle semH;
    Int status = RcmClient_S_SUCCESS;


    Log_print1(Diags_ENTRY, "--> "FXNN": (obj=0x%x)", (IArg)obj);

    if (NULL != obj->newMail) {
        List_delete(&obj->newMail);
    }

    if (NULL != obj->recipients) {
        List_delete(&obj->recipients);
    }

    if (NULL != obj->queueLock) {
        semH = SemThread_Handle_downCast(obj->queueLock);
        SemThread_delete(&semH);
        obj->queueLock = NULL;
    }

    if (NULL != obj->mbxLock) {
        semH = SemThread_Handle_downCast(obj->mbxLock);
        SemThread_delete(&semH);
        obj->mbxLock = NULL;
    }

    if (MessageQ_INVALIDMESSAGEQ != obj->serverMsgQ) {
        MessageQ_close((MessageQ_QueueId *)(&obj->serverMsgQ));
    }

    if (NULL != obj->errorMsgQue) {
        MessageQ_delete(&obj->errorMsgQue);
    }

    if (NULL != obj->msgQue) {
        MessageQ_delete(&obj->msgQue);
    }

    if (NULL != obj->sync) {
        SyncSemThread_delete((SyncSemThread_Handle *)(&obj->sync));
    }

    /* destruct the instance gate */
    GateThread_destruct(&obj->gate);

    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status);
    return(status);
}
Esempio n. 3
0
/*
 *  ======== loopbackFxn========
 *  Receive and return messages.
 *  Run at priority lower than tsk1Fxn above.
 *  Inputs:
 *     - arg0: number of the thread, appended to MessageQ host and slave names.
 */
Void loopbackFxn(UArg arg0, UArg arg1)
{
    MessageQ_Msg     getMsg;
    MessageQ_Handle  messageQ;
    MessageQ_QueueId remoteQueueId;
    Int              status;
    UInt16           msgId = 0;
    Char             localQueueName[64];
    Char             hostQueueName[64];

    System_printf("Thread loopbackFxn: %d\n", arg0);

    System_sprintf(localQueueName, "%s_%d", SLAVE_MESSAGEQNAME, arg0);
    System_sprintf(hostQueueName,  "%s_%d", HOST_MESSAGEQNAME,  arg0);

    /* Create a message queue. */
    messageQ = MessageQ_create(localQueueName, NULL);
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n");
    }

    System_printf("loopbackFxn: created MessageQ: %s; QueueID: 0x%x\n",
        localQueueName, MessageQ_getQueueId(messageQ));

    System_printf("Start the main loop: %d\n", arg0);
    while (msgId < NUMLOOPS) {
        /* Get a message */
        status = MessageQ_get(messageQ, &getMsg, MessageQ_FOREVER);
        if (status != MessageQ_S_SUCCESS) {
           System_abort("This should not happen since timeout is forever\n");
        }
        remoteQueueId = MessageQ_getReplyQueue(getMsg);

#ifndef BENCHMARK
        System_printf("%d: Received message #%d from core %d\n",
                arg0, MessageQ_getMsgId(getMsg),
                MessageQ_getProcId(remoteQueueId));
#endif
        /* test id of message received */
        if (MessageQ_getMsgId(getMsg) != msgId) {
            System_abort("The id received is incorrect!\n");
        }

#ifndef BENCHMARK
        /* Send it back */
        System_printf("%d: Sending message Id #%d to core %d\n",
                      arg0, msgId, MessageQ_getProcId(remoteQueueId));
#endif
        status = MessageQ_put(remoteQueueId, getMsg);
        if (status != MessageQ_S_SUCCESS) {
           System_abort("MessageQ_put had a failure/error\n");
        }
        msgId++;
    }

    MessageQ_delete(&messageQ);
    numTests += NUMLOOPS;

    System_printf("Test thread %d complete!\n", arg0);
}
Esempio n. 4
0
void shutdown_message_q()
{
    if(0 != h_receive_queue)
    {
        MessageQ_delete(&h_receive_queue);
        h_receive_queue=0;
    }
}
Esempio n. 5
0
/*
 *  ======== Server_delete ========
 */
Int Server_delete()
{
    Int         status;
    GateMPApp_Msg *           msg;
    MessageQ_QueueId    queId;

    Log_print0(Diags_ENTRY, "--> Server_delete:");

    /* wait for inbound message */
    status = MessageQ_get(Module.slaveQue, (MessageQ_Msg *)&msg,
        MessageQ_FOREVER);

    if (status < 0) {
        goto leave;
    }
    Log_print0(Diags_ENTRY, "--> Server_delete: got msg");
    if (msg->cmd != GATEMPAPP_CMD_SHUTDOWN) {
        status = GATEMPAPP_E_UNEXPECTEDMSG;
        goto leave;
    }

    /* send message back to say that GateMP has been cleaned up */
    queId = MessageQ_getReplyQueue(msg); /* type-cast not needed */
    msg->cmd = GATEMPAPP_CMD_SHUTDOWN_ACK;
    MessageQ_put(queId, (MessageQ_Msg)msg);

    /* delete the video message queue */
    status = MessageQ_delete(&Module.slaveQue);
    if (status < 0) {
        Log_print0(Diags_ENTRY, "Server_delete: MessageQ_delete failed");
        goto leave;
    }

    Log_print0(Diags_ENTRY, "Server_delete: MessageQ deleted");

    /* delete slave GateMP */
    status = GateMP_delete(&Module.slaveGateMPHandle);
    if (status < 0) {
        Log_print0(Diags_ENTRY, "Server_delete: GateMP_delete failed");
        goto leave;
    }

    Log_print0(Diags_ENTRY, "Server_delete: slave GateMP deleted");

leave:
    if (status < 0) {
        Log_error1("Server_delete: error=0x%x", (IArg)status);
    }

    /* disable log events */
    Log_print1(Diags_EXIT, "<-- Server_delete: %d", (IArg)status);
    Diags_setMask(MODULE_NAME"-EXF");

    return(status);
}
Esempio n. 6
0
/**
 * Handler for messageq delete API.
 *
 * \param ctp	Thread's associated context information.
 * \param msg	The actual devctl() message.
 * \param ocb	OCB associated with client's session.
 *
 * \return POSIX errno value.
 *
 * \retval EOK		Success.
 * \retval ENOTSUP	Unsupported devctl().
 */
int syslink_messageq_delete(resmgr_context_t *ctp, io_devctl_t *msg, syslink_ocb_t *ocb) {

	MessageQDrv_CmdArgs *		cargs = (MessageQDrv_CmdArgs *) (_DEVCTL_DATA (msg->i));
	MessageQDrv_CmdArgs *		out  = (MessageQDrv_CmdArgs *) (_DEVCTL_DATA (msg->o));
	MessageQ_Handle             temp  = cargs->args.deleteMessageQ.handle;

	out->apiStatus = MessageQ_delete ((MessageQ_Handle *)
                                            &(cargs->args.deleteMessageQ.handle));
    GT_assert (curTrace, (out->apiStatus >= 0));
    if (out->apiStatus >= 0) {
        /* At this call to the list to be cleaned-up */
        remove_ocb_res(ocb, DCMD_MESSAGEQ_DELETE, (int)temp, NULL);
    }

	return (_RESMGR_PTR (ctp, &msg->o, sizeof (msg->o) + sizeof(MessageQDrv_CmdArgs)));

}
Esempio n. 7
0
Int MessageQApp_execute(UInt32 numLoops, UInt16 procId)
{
    Int32                    status = 0;
    MessageQ_Msg             msg = NULL;
    MessageQ_Params          msgParams;
    UInt32                   i;
    MessageQ_QueueId         queueId = MessageQ_INVALIDMESSAGEQ;
    MessageQ_Handle          msgqHandle;
    char                     remoteQueueName[64];
    UInt32                   msgId;

    printf("Entered MessageQApp_execute\n");

    /* Create the local Message Queue for receiving. */
    MessageQ_Params_init(&msgParams);
    msgqHandle = MessageQ_create(MPU_MESSAGEQNAME, &msgParams);
    if (msgqHandle == NULL) {
        printf("Error in MessageQ_create\n");
        goto exit;
    }
    else {
        printf("Local MessageQId: 0x%x\n", MessageQ_getQueueId(msgqHandle));
    }

    sprintf(remoteQueueName, "%s_%s", SLAVE_MESSAGEQNAME,
             MultiProc_getName(procId));

    /* Poll until remote side has it's messageQ created before we send: */
    do {
        status = MessageQ_open(remoteQueueName, &queueId);
        sleep (1);
    } while (status == MessageQ_E_NOTFOUND);

    if (status < 0) {
        printf("Error in MessageQ_open [%d]\n", status);
        goto cleanup;
    }
    else {
        printf("Remote queueId  [0x%x]\n", queueId);
    }

    msg = MessageQ_alloc(HEAPID, sizeof(SyncMsg));
    if (msg == NULL) {
        printf("Error in MessageQ_alloc\n");
        MessageQ_close(&queueId);
        goto cleanup;
    }

    /* handshake with remote to set the number of loops */
    MessageQ_setReplyQueue(msgqHandle, msg);
    ((SyncMsg *)msg)->numLoops = numLoops;
    ((SyncMsg *)msg)->print = FALSE;
    MessageQ_put(queueId, msg);
    MessageQ_get(msgqHandle, &msg, MessageQ_FOREVER);

    printf("Exchanging %d messages with remote processor %s...\n",
           numLoops, MultiProc_getName(procId));

    for (i = 1 ; i <= numLoops; i++) {
        ((SyncMsg *)msg)->numLoops = i;

        /* Have the remote proc reply to this message queue */
        MessageQ_setReplyQueue(msgqHandle, msg);

        status = MessageQ_put(queueId, msg);
        if (status < 0) {
            printf("Error in MessageQ_put [%d]\n", status);
            MessageQ_free(msg);
            break;
        }

        status = MessageQ_get(msgqHandle, &msg, MessageQ_FOREVER);

        if (status < 0) {
            printf("Error in MessageQ_get [%d]\n", status);
            break;
        }
        else {
            /* validate the returned message */
            msgId = ((SyncMsg *)msg)->numLoops;
            if ((msg != NULL) && (msgId != i)) {
                printf("Data integrity failure!\n"
                        "    Expected %d\n"
                        "    Received %d\n",
                        i, msgId);
                break;
            }
        }

        if (numLoops <= 200) {
            printf("MessageQ_get #%d Msg = 0x%x\n", i, (UInt)msg);
        }
        else if ((i % 1000) == 0) {
            printf("MessageQ_get #%d Msg = 0x%x\n", i, (UInt)msg);
        }
    }

    printf("Exchanged %d messages with remote processor %s\n",
        (i-1), MultiProc_getName(procId));

    if (status >= 0) {
       printf("Sample application successfully completed!\n");
       MessageQ_free(msg);
    }

    MessageQ_close(&queueId);

cleanup:
    /* Clean-up */
    status = MessageQ_delete(&msgqHandle);
    if (status < 0) {
        printf("Error in MessageQ_delete [%d]\n", status);
    }

exit:
    printf("Leaving MessageQApp_execute\n\n");

    return (status);
}
Esempio n. 8
0
File: App.c Progetto: yesj/J5_A8
/*
 *  ======== App_delete ========
 *
 *  1. send shutdown event
 *  2. wait for shutdown acknowledgement event
 *
 *  3. close remote resources
 *  4. send close done event
 *  5. wait for remote close done event
 *
 *  6. delete shared resoures
 *  7. send disconnect event (last sent event)
 *  8. wait for disconnect event
 *
 *  9. unregister notify callback
 * 10. delete sync object
 */
Int App_delete(Void)
{
    Int         status;
    UInt32      event;

    /* 1. send shutdown command (out-of-band) */
    status = Notify_sendEvent(Module.remoteProcId, Module.lineId,
        Module.eventId, App_CMD_SHUTDOWN, TRUE);

    if (status < 0) {
        goto leave;
    }

    /* 2. wait for shutdown acknowledgement */
    do {
        event = App_waitForEvent();

        if (event >= App_E_FAILURE) {
            status = -1;
            goto leave;
        }
    } while (event != App_CMD_SDACK);

    /* 3. close remote resources */
    status = MessageQ_close(&Module.videoQue);

    if (status < 0) {
        goto leave;
    }

    /* 4. send close done event */
    status = Notify_sendEvent(Module.remoteProcId, Module.lineId,
        Module.eventId, App_CMD_CLOSED, TRUE);

    if (status < 0) {
        goto leave;
    }

    /* 5. wait for remote close done event */
    do {
        event = App_waitForEvent();

        if (event >= App_E_FAILURE) {
            status = -1;
            goto leave;
        }
    } while (event != App_CMD_CLOSED);

    /* 6. delete shared resoures */

    /* delete the host message queue */
    status = MessageQ_delete(&Module.hostQue);

    if (status < 0) {
        goto leave;
    }

    /* unregister heap with MessageQ */
    status = MessageQ_unregisterHeap(App_MsgHeapId);

    if (status < 0) {
        goto leave;
    }

    /* delete the message heap */
    status = HeapBufMP_delete(&Module.msgHeap);

    if (status < 0) {
        goto leave;
    }

    /* 7. send disconnect event (last sent event) */
    status = Notify_sendEvent(Module.remoteProcId, Module.lineId,
        Module.eventId, App_CMD_DONE, TRUE);

    if (status < 0) {
        goto leave;
    }

    /* 8. wait for disconnect event (last event received) */
    do {
        event = App_waitForEvent();

        if (event >= App_E_FAILURE) {
            status = -1;
            goto leave;
        }
    } while (event != App_CMD_DONE);

    /* 9. unregister notify callback */
    status = Notify_unregisterEventSingle(Module.remoteProcId, Module.lineId,
        Module.eventId);

    if (status < 0) {
        goto leave;
    }

    /* 10. delete sync object */
    sem_destroy(&Module.semH);

leave:
    return(status);
}
Esempio n. 9
0
Int MessageQApp_execute(UInt32 numLoops, UInt32 payloadSize, UInt16 procId)
{
    Int32                    status     = 0;
    MessageQ_Msg             msg        = NULL;
    MessageQ_Params          msgParams;
    UInt32                   i;
    MessageQ_QueueId         queueId = MessageQ_INVALIDMESSAGEQ;
    MessageQ_Handle          msgqHandle;
    char                     remoteQueueName[64];
    struct timespec          start, end;
    long                     elapsed;
    UInt32                   msgId;

    printf("Entered MessageQApp_execute\n");

    /* Create the local Message Queue for receiving. */
    MessageQ_Params_init(&msgParams);
    msgqHandle = MessageQ_create(MPU_MESSAGEQNAME, &msgParams);
    if (msgqHandle == NULL) {
        printf("Error in MessageQ_create\n");
        goto exit;
    }
    else {
        printf("Local MessageQId: 0x%x\n", MessageQ_getQueueId(msgqHandle));
    }

    sprintf(remoteQueueName, "%s_%s", SLAVE_MESSAGEQNAME,
             MultiProc_getName(procId));

    /* Poll until remote side has its messageQ created before we send: */
    do {
        status = MessageQ_open(remoteQueueName, &queueId);
        sleep (1);
    } while (status == MessageQ_E_NOTFOUND);

    if (status < 0) {
        printf("Error in MessageQ_open [%d]\n", status);
        goto cleanup;
    }
    else {
        printf("Remote queueId  [0x%x]\n", queueId);
    }

    msg = MessageQ_alloc(HEAPID, sizeof(SyncMsg) + payloadSize);
    if (msg == NULL) {
        printf("Error in MessageQ_alloc\n");
        MessageQ_close(&queueId);
        goto cleanup;
    }

    /* handshake with remote to set the number of loops */
    MessageQ_setReplyQueue(msgqHandle, msg);
    ((SyncMsg *)msg)->numLoops = numLoops;
    ((SyncMsg *)msg)->print = FALSE;
    MessageQ_put(queueId, msg);
    MessageQ_get(msgqHandle, &msg, MessageQ_FOREVER);

    printf("Exchanging %d messages with remote processor %s...\n",
           numLoops, MultiProc_getName(procId));

    clock_gettime(CLOCK_REALTIME, &start);

    for (i = 1 ; i <= numLoops; i++) {
        ((SyncMsg *)msg)->numLoops = i;

        /* Have the remote proc reply to this message queue */
        MessageQ_setReplyQueue(msgqHandle, msg);

        status = MessageQ_put(queueId, msg);
        if (status < 0) {
            printf("Error in MessageQ_put [%d]\n", status);
            break;
        }

        status = MessageQ_get(msgqHandle, &msg, MessageQ_FOREVER);

        if (status < 0) {
            printf("Error in MessageQ_get [%d]\n", status);
            break;
        }
        else {
            /* Validate the returned message */
            msgId = ((SyncMsg *)msg)->numLoops;
            if ((msg != NULL) && (msgId != i)) {
                printf("Data integrity failure!\n"
                        "    Expected %d\n"
                        "    Received %d\n",
                        i, msgId);
                break;
            }
        }
    }

    clock_gettime(CLOCK_REALTIME, &end);
    elapsed = diff(start, end);

    if (numLoops > 0) {
        printf("%s: Avg round trip time: %ld usecs\n",
               MultiProc_getName(procId), elapsed / numLoops);
    }

    MessageQ_free(msg);
    MessageQ_close(&queueId);

cleanup:
    status = MessageQ_delete(&msgqHandle);
    if (status < 0) {
        printf ("Error in MessageQ_delete [%d]\n", status);
    }

exit:
    printf("Leaving MessageQApp_execute\n\n");

    return (status);
}
Esempio n. 10
0
static Void * pingThreadFxn(void *arg)
{
    Int                      threadNum = *(int *)arg;
    Int32                    status     = 0;
    MessageQ_Msg             msg        = NULL;
    MessageQ_Params          msgParams;
    UInt16                   i;
    MessageQ_Handle          handle;
    MessageQ_QueueId         queueId = MessageQ_INVALIDMESSAGEQ;

    char             remoteQueueName[64];
    char             hostQueueName[64];

    printf ("Entered pingThreadFxn: %d\n", threadNum);

    sprintf(remoteQueueName, "%s_%d%d", SLAVE_MESSAGEQNAME, threadNum, (threadNum % (MultiProc_getNumProcessors() - 1)) + 1);
    sprintf(hostQueueName,   "%s_%d", HOST_MESSAGEQNAME,  threadNum );

    /* Create the local Message Queue for receiving. */
    MessageQ_Params_init (&msgParams);
    handle = MessageQ_create (hostQueueName, &msgParams);
    if (handle == NULL) {
        printf ("Error in MessageQ_create\n");
        goto exit;
    }
    else {
        printf ("thread: %d, Local Message: %s, QId: 0x%x\n",
            threadNum, hostQueueName, MessageQ_getQueueId(handle));
    }

    /* Poll until remote side has it's messageQ created before we send: */
    do {
        status = MessageQ_open (remoteQueueName, &queueId);
        sleep (1);
    } while (status == MessageQ_E_NOTFOUND);
    if (status < 0) {
        printf ("Error in MessageQ_open [0x%x]\n", status);
        goto cleanup;
    }
    else {
        printf ("thread: %d, Remote queue: %s, QId: 0x%x\n",
                 threadNum, remoteQueueName, queueId);
    }

    printf ("\nthread: %d: Exchanging messages with remote processor...\n",
            threadNum);
    for (i = 0 ; i < numLoops ; i++) {
        /* Allocate message. */
        msg = MessageQ_alloc (HEAPID, MSGSIZE);
        if (msg == NULL) {
            printf ("Error in MessageQ_alloc\n");
            break;
        }

        MessageQ_setMsgId (msg, i);

        /* Have the remote proc reply to this message queue */
        MessageQ_setReplyQueue (handle, msg);

        status = MessageQ_put (queueId, msg);
        if (status < 0) {
            printf ("Error in MessageQ_put [0x%x]\n", status);
            break;
        }

        status = MessageQ_get(handle, &msg, MessageQ_FOREVER);
        if (status < 0) {
            printf ("Error in MessageQ_get [0x%x]\n", status);
            break;
        }
        else {
            /* Validate the returned message. */
            if ((msg != NULL) && (MessageQ_getMsgId (msg) != i)) {
                printf ("Data integrity failure!\n"
                        "    Expected %d\n"
                        "    Received %d\n",
                        i, MessageQ_getMsgId (msg));
                break;
            }

            status = MessageQ_free (msg);
        }

        printf ("thread: %d: Exchanged %d msgs\n", threadNum, (i+1));
    }

    printf ("thread: %d: pingThreadFxn successfully completed!\n", threadNum);

    MessageQ_close (&queueId);

cleanup:
    /* Clean-up */
    status = MessageQ_delete (&handle);
    if (status < 0) {
        printf ("Error in MessageQ_delete [0x%x]\n", status);
    }

exit:

    return ((void *)status);
}
Esempio n. 11
0
void slave_main(void)
{
    process_message_t * p_msg = 0;    
    MessageQ_Handle  h_receive_queue = 0;
    MessageQ_QueueId reply_queue_id = 0;
    HeapBufMP_Handle heapHandle;
    Int status;
    char receive_queue_name[16];

    GET_SLAVE_QUEUE_NAME(receive_queue_name, DNUM);

    /* Open the heap created by the other processor. Loop until opened. */    
    do {        
        status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);
        if (status < 0) { 
            Task_sleep(1);
        }
    } while (status < 0);

    /* Register this heap with MessageQ */    
    MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);
    
    /* Create the local message queue */
    h_receive_queue = MessageQ_create(receive_queue_name, NULL);    
    if (h_receive_queue == NULL) {
        logout("MessageQ_create failed\n" );
		goto close_n_exit;
    }

	for (;;) {
 
		if (MessageQ_get(h_receive_queue, (MessageQ_Msg *)&p_msg, MessageQ_FOREVER) < 0) {
		    logout("%s: This should not happen since timeout is forever\n", receive_queue_name);
		    goto close_n_exit;
		}

        reply_queue_id = MessageQ_getReplyQueue(p_msg);
        if (reply_queue_id == MessageQ_INVALIDMESSAGEQ) {
            logout("receive_queue_name: Ignoring the message as reply queue is not set.\n", receive_queue_name);
            continue;
        }

        //Execute calculation
		#ifdef _TRACE_MC_
        logout("[core_%u] Execute process (processing_type=%u)\n", p_msg->core_id, p_msg->info.processing_type); //trace
		#endif

        switch(p_msg->info.processing_type)
        {
        	case pt_ssd:
        		//Call calculation code
        		exec_ssd(p_msg);
        		break;

        	case pt_ssdJacHess:
        		//Call calculation code
        		exec_ssdJacHess(p_msg);
        		break;

        	case pt_cacheinval:
        		CacheInvalTotalMemory(p_msg);
        		break;

        	case pt_shrink:
        		//Call image shrink code
        		exec_shrinkImage(p_msg);
        		break;

        	default:
        		logout("Invalid IPC processing type: %u", p_msg->info.processing_type);
        }

        /* send the message to the remote processor */
		#ifdef _TRACE_MC_
		logout("[core_%u] Putting slave response to the MessageQ, then going idle again ...\n", p_msg->core_id);
		#endif
        if (MessageQ_put(reply_queue_id, (MessageQ_Msg)p_msg) < 0) {
            logout("%s: MessageQ_put had a failure error\n", receive_queue_name);
        }

	}

close_n_exit:
    if(h_receive_queue) MessageQ_delete(&h_receive_queue);
}