void proc6(void) { // OUTPUT PROCESS - gathers data from all the other processes and outputs to //uart0 while (1) { int counter = 0; int total = 5; int i = 0; int asciioffset = 48; //uart0_put_string("G021_test: START\n\r"); //uart0_put_string("G021_test: total ");//uart0_put_char(total+asciioffset);//uart0_put_string(" tests\n\r"); for (i = 1; i < total+1; i++) { //uart0_put_string("G021_test: test "); //uart0_put_char(i+asciioffset); if (is_process_blocked(i)) { //uart0_put_string(" BLOCKED"); } else { if (results[i] == 0) { //uart0_put_string(" FAIL"); } else { //uart0_put_string(" OK"); counter++; } } //uart0_put_string("\n\r"); } //uart0_put_string("G021_test: ");//uart0_put_char(counter+asciioffset);//uart0_put_string("/");//uart0_put_char(total+asciioffset);//uart0_put_string(" tests OK\n\r"); //uart0_put_string("G021_test: ");//uart0_put_char((total-counter)+asciioffset);//uart0_put_string("/");//uart0_put_char(total+asciioffset);//uart0_put_string(" tests FAIL\n\r"); //uart0_put_string("G021_test: END\n\r"); release_processor(); } }
// lowest priority void mem_test_master() { /** * Memory blocking test * * This test consumes all of the memory, then wakes up 2 processes of different * priorities which both request_memory_block(), blocking them both. When this * process returns, it frees a single memory block and verifies that it was given * to the right process. */ void * msg1 = request_memory_block(); void * msg2 = request_memory_block(); void * blocks[30]; // starve the system of memory int i; for (i = 0; are_blocks_available(); i ++) { blocks[i] = request_memory_block(); } for (; i < 30; i ++) { blocks[i] = NULL; } #ifdef _MEM_TEST_DEBUG if (!is_process_blocked(MEM_TEST_BLOCKING1_PID)) { rtx_dbug_outs("MEM TEST ERROR: Blocking1 is not blocked for msg\r\n"); } if (!is_process_blocked(MEM_TEST_BLOCKING2_PID)) { rtx_dbug_outs("MEM TEST ERROR: Blocking2 is not blocked for msg\r\n"); } #endif // wake up blocking1 and blocking2 send_message(MEM_TEST_BLOCKING1_PID, msg1); send_message(MEM_TEST_BLOCKING2_PID, msg2); #ifdef _MEM_TEST_DEBUG if (!is_process_blocked(MEM_TEST_BLOCKING1_PID)) { rtx_dbug_outs("MEM TEST ERROR: Blocking1 is not blocked for mem\r\n"); } if (!is_process_blocked(MEM_TEST_BLOCKING2_PID)) { rtx_dbug_outs("MEM TEST ERROR: Blocking2 is not blocked for mem\r\n"); } #endif // both will block and we'll end up back here release_memory_block(blocks[0]); MessageEnvelope * msgFromB2 = (MessageEnvelope *)receive_message(NULL); if (msgFromB2->tx != MEM_TEST_BLOCKING2_PID) { #ifdef _MEM_TEST_DEBUG rtx_dbug_outs_int("MEM TEST ERROR: Incorrect process was unblocked on memory (1) ", msgFromB2->tx); #endif } else { #ifdef _MEM_TEST_DEBUG rtx_dbug_outs("MEM TEST SUCCESS: Correct process unblocked on memory (1)\r\n"); #endif } release_memory_block(msgFromB2); MessageEnvelope * msgFromB1 = (MessageEnvelope *)receive_message(NULL); if (msgFromB1->tx != MEM_TEST_BLOCKING1_PID) { #ifdef _MEM_TEST_DEBUG rtx_dbug_outs_int("MEM TEST ERROR: Incorrect process was unblocked on memory (2) ", msgFromB1->tx); #endif } else { #ifdef _MEM_TEST_DEBUG rtx_dbug_outs("MEM TEST SUCCESS: Correct process unblocked on memory (2)\r\n"); #endif } // cleanup release_memory_block(msgFromB1); for (i = 1; blocks[i] != NULL; i ++) { release_memory_block(blocks[i]); } }