Ejemplo n.º 1
0
VOID receive_message_trap_handler()
{
	int * sender_ID;
	asm("move.l %d2, g_asmBridge");
	sender_ID = g_asmBridge;
	
	/*
	Check to see if there is a message waiting in the process' message queue.
	If there is a message, pop it from the queue, set the sender_id parameter
	to the process id the message came from, and return a pointer to the block
	of memory that the message resides in to the process.
	If there is no message, set the process state to blocked on message, and
	release processor. When this process receives a message, the process will
	be re-added to the scheduler queue, and the next time it is executed it
	will handle the message as explained above.
	*/
	
	struct s_message *  msg;
	
	if(message_pop(&g_current_process->msg_queue, g_current_process->msg_queue_slots, &msg) == -1){
		g_current_process->m_state = 3;
		release_processor();
		message_pop(&g_current_process->msg_queue, g_current_process->msg_queue_slots, &msg);
	}

	*sender_ID = msg->sender_id;
	

	g_asmBridge = msg;
	asm("move.l g_asmBridge, %d1");
}
Ejemplo n.º 2
0
MESSAGE_HANDLE MESSAGE_QUEUE_pop(MESSAGE_QUEUE_HANDLE handle)
{
    MESSAGE_HANDLE result;
    if (handle == NULL)
    {
        /*Codes_SRS_MESSAGE_QUEUE_17_012: [ MESSAGE_QUEUE_pop shall return NULL on a NULL message queue. ]*/
        LogError("invalid argument - handle(%p).", handle);
        result = NULL;
    }
    else
    {
        /*Codes_SRS_MESSAGE_QUEUE_17_013: [ MESSAGE_QUEUE_pop shall return NULL on an empty message queue. ]*/
        /*Codes_SRS_MESSAGE_QUEUE_17_014: [ MESSAGE_QUEUE_pop shall remove messages from the queue in a first-in-first-out order. ]*/
        /*Codes_SRS_MESSAGE_QUEUE_17_015: [ A successful call to MESSAGE_QUEUE_pop on a queue with one message will cause the message queue to be empty. ]*/
        result = message_pop(handle);
    }
    return result;
}
Ejemplo n.º 3
0
void MESSAGE_QUEUE_destroy(MESSAGE_QUEUE_HANDLE handle)
{
    if (handle == NULL)
    {
        /*Codes_SRS_MESSAGE_QUEUE_17_004: [ MESSAGE_QUEUE_destroy shall not perform any actions on a NULL message queue. ]*/
        LogError("invalid argument handle(NULL).");
    }
    else
    {
		MESSAGE_QUEUE_HANDLE_DATA * mq = (MESSAGE_QUEUE_HANDLE_DATA*)handle;
        MESSAGE_HANDLE message;
        while((message = message_pop(mq)) != NULL)
        {
            /*Codes_SRS_MESSAGE_QUEUE_17_005: [ If the message queue is not empty, MESSAGE_QUEUE_destroy shall destroy all messages in the queue. ]*/
            Message_Destroy(message);
        }
        /*Codes_SRS_MESSAGE_QUEUE_17_006: [ MESSAGE_QUEUE_destroy shall free all allocated resources. ]*/
        free(handle);
    }
}